From ace7231e977dae92d8a75d723792bf0e34b7ac0a Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 23 Jun 2021 09:39:21 +0200 Subject: [PATCH] Part: tube object, add method to simplify to add it to the document --- src/Mod/Part/BasicShapes/Shapes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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