Part: tube object, add method to simplify to add it to the document
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user