Message 1 of 3

Not applicable
02-18-2018
06:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I'm very new to python and scripting, and I have a goal. I want to create a surface loft, using 2 sketches. Later on, I want to create more complex things, but I'm unable to make the loft, and I have no idea why. Can someone tell me what I'm doing wrong and why?
Here's what the end result should look like:
Here's my code:
import adsk.core, adsk.fusion app = adsk.core.Application.get() ui = app.userInterface design = app.activeProduct # Get the root component of the active design. rootComp = design.rootComponent ###### # Create a new sketch on the xy plane. sketches = rootComp.sketches xyPlane = rootComp.xYConstructionPlane sketch = sketches.add(xyPlane) # Create an object collection for the points. points = adsk.core.ObjectCollection.create() Steps = 10 #How many fibonacci steps to go through R = Steps - 2 points.add(adsk.core.Point3D.create(0, 0, 0)) # This plots the origin Bin1 = range(0, R, 2) Bin2 = range(1, R, 2) xCoord = 0 yCoord = 0 hossz = 1 for i in range(R): if i in Bin1: xCoord = xCoord yCoord = yCoord + hossz points.add(adsk.core.Point3D.create(xCoord, yCoord, 0)) if i in Bin2: xCoord = xCoord + hossz yCoord = yCoord points.add(adsk.core.Point3D.create(xCoord, yCoord, 0)) # Create the spline. spline1 = sketch.sketchCurves.sketchFittedSplines.add(points) #create second sketch planes = rootComp.constructionPlanes #### # Create construction plane input planeInput = planes.createInput() # Add construction plane by offset offsetValue = adsk.core.ValueInput.createByReal(5.0) planeInput.setByOffset(rootComp.xYConstructionPlane, offsetValue) planeOne = planes.add(planeInput) sketch2 = rootComp.sketches offsetplane = planeOne sketch = sketch2.add(offsetplane) lines = sketch.sketchCurves.sketchLines; line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(4, 4, 0)) ########LOFT openProfile1 = rootComp.createOpenProfile(spline1) openProfile2 = rootComp.createOpenProfile(line1) # Create loft feature input loftFeats = rootComp.features.loftFeatures loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation) loftSectionsObj = loftInput.loftSections loftSectionsObj.add(openProfile1) loftSectionsObj.add(openProfile2) loftInput.isSolid = False # Create loft feature loftFeats.add(loftInput)
Thanks in advance!
Solved! Go to Solution.