
Not applicable
05-06-2020
08:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a path that consists of several straight lines rather than just one. I am testing whether the path has successfully been created by creating a loft between two paths. The code below creates a loft between two paths that each consist of one line. I would like for it two loft together two paths that each consist of two lines. Where the paths have been created, I have included some comments that show things I have tried that have not worked.
import adsk.core
import adsk.fusion
import traceback
def run(context):
ui = None
try:
# Get root component and ui
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
root_comp = design.rootComponent
# Get sketches and xy_plane
sketches = root_comp.sketches
xy_plane = root_comp.xYConstructionPlane
# Define points
points1 = []
points1.append(adsk.core.Point3D.create(0, 0))
points1.append(adsk.core.Point3D.create(0, 2))
points1.append(adsk.core.Point3D.create(2, 4))
points2 = []
points2.append(adsk.core.Point3D.create(0, 0, 1))
points2.append(adsk.core.Point3D.create(0, 2, 1))
points2.append(adsk.core.Point3D.create(2, 4, 1))
# Make lines
sketch1 = sketches.add(xy_plane)
sketch_lines = sketch1.sketchCurves.sketchLines
line1 = sketch_lines.addByTwoPoints(points1[0], points1[1])
line2 = sketch_lines.addByTwoPoints(points1[1], points1[2])
sketch2 = sketches.add(xy_plane)
sketch_lines = sketch2.sketchCurves.sketchLines
line3 = sketch_lines.addByTwoPoints(points2[0], points2[1])
line4 = sketch_lines.addByTwoPoints(points2[1], points2[2])
# Create paths
# Need help here
features = root_comp.features
path1 = features.createPath(line1)
path2 = features.createPath(line3)
# path1 = features.createPath([line1,line2])?
# path1 = features.createPath(sketch.sketchCurves)?
# path1 = features.createPath(sketch.sketchCurves.sketchLines)?
# Create loft feature
new_feature = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
loft_features = features.loftFeatures
loft_input = loft_features.createInput(new_feature)
# Add sections
loft_sections = loft_input.loftSections
loft_sections.add(path1)
loft_sections.add(path2)
loft_features.add(loft_input)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
The code above creates the loft shown below. I would like it to loft together the remaining lines too by creating paths that contain multiple lines.
Temba
Solved! Go to Solution.