diff --git a/src/Mod/Part/BasicShapes/Shapes.py b/src/Mod/Part/BasicShapes/Shapes.py index b4bbb5167a..bb04b21bf7 100644 --- a/src/Mod/Part/BasicShapes/Shapes.py +++ b/src/Mod/Part/BasicShapes/Shapes.py @@ -26,8 +26,10 @@ __url__ = "http://www.freecadweb.org" __doc__ = "Basic shapes" +import FreeCAD import Part + def makeTube(outerRadius, innerRadius, height): outer_cylinder = Part.makeCylinder(outerRadius, height) shape = outer_cylinder @@ -49,3 +51,14 @@ class TubeFeature: if fp.InnerRadius >= fp.OuterRadius: raise ValueError("Inner radius must be smaller than outer radius") fp.Shape = makeTube(fp.OuterRadius, fp.InnerRadius, fp.Height) + + +def addTube(doc, name="Tube"): + """addTube(document, [name]): adds a tube object""" + + obj = doc.addObject("Part::FeaturePython", name) + TubeFeature(obj) + if FreeCAD.GuiUp: + from . import ViewProviderShapes + ViewProviderShapes.ViewProviderTube(obj.ViewObject) + return obj