- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I use loft in my plugins. After last Fusion update this funcitionality doesn't work as before, I mean clients get errors, no matter loft is through profiles with rails or not. Making loft by UI works (but for rails I need to turn off "Chain selection" checkbox).
I prepared sample script to show one of the case. There's no error messages but lofts are not as expected:
It seems that loft starts from middle profile
Script:
import adsk.core, adsk.fusion
def run(context):
app = adsk.core.Application.get()
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
# Example 1 - same size of profiles but different Z
sketch1 = rootComp.sketches.add(rootComp.xYConstructionPlane)
# First profile
p11 = adsk.core.Point3D.create(0, 2, 0)
p12 = adsk.core.Point3D.create(2, 0, 0)
p13 = adsk.core.Point3D.create(0, -1.3, 0)
p14 = adsk.core.Point3D.create(-1.8, 0, 0)
p15 = adsk.core.Point3D.create(-1.2, 1, 0)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p11, p12)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p12, p13)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p13, p14)
points = adsk.core.ObjectCollection.create()
points.add(p14)
points.add(p15)
points.add(p11)
sketch1.sketchCurves.sketchFittedSplines.add(points)
# Second profile
p21 = adsk.core.Point3D.create(0, 2, 4)
p22 = adsk.core.Point3D.create(2, 0, 4)
p23 = adsk.core.Point3D.create(0, -1.3, 4)
p24 = adsk.core.Point3D.create(-1.8, 0, 4)
p25 = adsk.core.Point3D.create(-1.2, 1, 4)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p21, p22)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p22, p23)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p23, p24)
points = adsk.core.ObjectCollection.create()
points.add(p24)
points.add(p25)
points.add(p21)
sketch1.sketchCurves.sketchFittedSplines.add(points)
# Third profile
p31 = adsk.core.Point3D.create(0, 2, 10)
p32 = adsk.core.Point3D.create(2, 0, 10)
p33 = adsk.core.Point3D.create(0, -1.3, 10)
p34 = adsk.core.Point3D.create(-1.8, 0, 10)
p35 = adsk.core.Point3D.create(-1.2, 1, 10)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p31, p32)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p32, p33)
sketch1.sketchCurves.sketchLines.addByTwoPoints(p33, p34)
points = adsk.core.ObjectCollection.create()
points.add(p34)
points.add(p35)
points.add(p31)
sketch1.sketchCurves.sketchFittedSplines.add(points)
# Create loft
loftFeatures = rootComp.features.loftFeatures
loftInput = loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
for ip in range(sketch1.profiles.count):
loftInput.loftSections.add(sketch1.profiles.item(ip))
loftInput.isSolid = True
loft = loftFeatures.add(loftInput)
# Example 2 - different sizes of profiles
sketch2 = rootComp.sketches.add(rootComp.xYConstructionPlane)
xShift = 10
# First profile
p11 = adsk.core.Point3D.create(0 + xShift, 2, 0)
p12 = adsk.core.Point3D.create(2 + xShift, 0, 0)
p13 = adsk.core.Point3D.create(0 + xShift, -1.3, 0)
p14 = adsk.core.Point3D.create(-1.8 + xShift, 0, 0)
p15 = adsk.core.Point3D.create(-1.2 + xShift, 1, 0)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p11, p12)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p12, p13)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p13, p14)
points = adsk.core.ObjectCollection.create()
points.add(p14)
points.add(p15)
points.add(p11)
sketch2.sketchCurves.sketchFittedSplines.add(points)
# Second profile
p21 = adsk.core.Point3D.create(0 + xShift, 4, 4)
p22 = adsk.core.Point3D.create(4 + xShift, 0, 4)
p23 = adsk.core.Point3D.create(0 + xShift, -2.6, 4)
p24 = adsk.core.Point3D.create(-3.6 + xShift, 0, 4)
p25 = adsk.core.Point3D.create(-2.4 + xShift, 2, 4)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p21, p22)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p22, p23)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p23, p24)
points = adsk.core.ObjectCollection.create()
points.add(p24)
points.add(p25)
points.add(p21)
sketch2.sketchCurves.sketchFittedSplines.add(points)
# Third profile
p31 = adsk.core.Point3D.create(0 + xShift, 3, 10)
p32 = adsk.core.Point3D.create(3 + xShift, 0, 10)
p33 = adsk.core.Point3D.create(0 + xShift, -1.95, 10)
p34 = adsk.core.Point3D.create(-2.7 + xShift, 0, 10)
p35 = adsk.core.Point3D.create(-1.8 + xShift, 1.5, 10)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p31, p32)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p32, p33)
sketch2.sketchCurves.sketchLines.addByTwoPoints(p33, p34)
points = adsk.core.ObjectCollection.create()
points.add(p34)
points.add(p35)
points.add(p31)
sketch2.sketchCurves.sketchFittedSplines.add(points)
# Create loft
loftFeatures = rootComp.features.loftFeatures
loftInput = loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
for ip in range(sketch2.profiles.count):
loftInput.loftSections.add(sketch2.profiles.item(ip))
loftInput.isSolid = True
loft = loftFeatures.add(loftInput)
When I do this by UI it works:
Order is ok
What should I do to make this work by API?
There's also another problem in case of using rails because I cannot find an equivalent of "Chain Selection" in API. Is it accessible or is it performed on much higher level?
Solved! Go to Solution.