Part: tube object, add method to simplify to add it to the document

This commit is contained in:
Bernd Hahnebach
2021-06-23 09:39:21 +02:00
parent 5512e41d06
commit ace7231e97

View File

@@ -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