- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following skript creates a new component. There it revolves a curve (witch is done by math) into a surface.
The surface appears as a new body in the component.
Then the skript thickens this surface to a solid. This new body appears in the Root-Component.
But can someone tell me why?
import adsk.core, adsk.fusion, adsk.cam, traceback, math
def run(context):
ui = None
try:
d = 3
width = 1
height = 2
vase = 0.5
pointsOnLine = 48
points = adsk.core.ObjectCollection.create()
for t in range(12, 37):
circ = 2*math.pi*t/(pointsOnLine)
cosWind = math.cos(circ)
sinWind = math.sin(circ)
vas = vase * math.cos(circ*2)*sinWind
y= height*sinWind
x= math.cos(0) * (d+ width*cosWind -vas)
z= math.sin(0) * (d+ width*cosWind -vas)
point = adsk.core.Point3D.create(x, y, z)
points.add(point)
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
# create new component
newOcc1 = rootComp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
revComp = newOcc1.component
revComp.name = 'Revolved_Body'
sketches = revComp.sketches
xzPlane = revComp.xZConstructionPlane
sketch0 = sketches.add(xzPlane)
lineA = sketch0.sketchCurves.sketchFittedSplines.add(points)
prof = revComp.features.createPath(lineA, False)
revolves = revComp.features.revolveFeatures
zAxis = revComp.zConstructionAxis
revInput1 = revolves.createInput(prof, zAxis, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
revInput1.isSolid = False
revAngle = adsk.core.ValueInput.createByReal( 2 * math.pi)
revInput1.setAngleExtent(False,revAngle)
revBody = revolves.add(revInput1)
thickenFeatures = revComp.features.thickenFeatures
inputSurfaces = adsk.core.ObjectCollection.create()
bodies = revBody.bodies
for body in bodies :
inputSurfaces.add(body)
thicknes = adsk.core.ValueInput.createByReal(0.5)
thickenInput = thickenFeatures.createInput(inputSurfaces, thicknes, False, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
thickenFeatures.add(thickenInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.