Message 1 of 3

Not applicable
ā02-27-2018
09:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I've been trying to create a loft between two sketches, and I'd like to set the loft to be driven by the direction of the first spline.
I know I should be using
returnValue = loftSection_var.setDirectionEndCondition()
but I have no idea where I should put it. I've been trying all day. I am new to this and I feel like something very basic is missing from my understanding.
Here's my code:
""" Created on Sun Feb 25 15:52:28 2018 @author: balintgabor """ import adsk.core, adsk.fusion, traceback def run(context): ui = None try: 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 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 + 1 yCoord = 0 + hossz points.add(adsk.core.Point3D.create(xCoord, yCoord, 0)) if i in Bin2: xCoord = xCoord + 1 yCoord = 0 - hossz 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(8, 0, 0)) ########LOFT openProfile1 = adsk.fusion.Path.create(spline1, adsk.fusion.ChainedCurveOptions.noChainedCurves) openProfile2 = adsk.fusion.Path.create(line1, adsk.fusion.ChainedCurveOptions.noChainedCurves) # 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) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
any help welcome!loft looks like this now
it should look like this
Solved! Go to Solution.