Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have written a simple program to loft two lines but I cannot correctly obtain the path for lofting, any assistance most welcome. Creating the planes, sketches and lines work fine however the lines below don't work so I assume I am missing something basic ? Thanks.
path1 = rootComp.features.createPath(line1)
path2 = rootComp.features.createPath(line2)
def createNewComponent(rootComp😞
allOccs = rootComp.occurrences
newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create())
return newOcc.component
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct # active design
rootComp = design.rootComponent # root component of active design, top level in browser
hullComponent = createNewComponent(rootComp) # create a new hull component
hullComponent.name = "hull"
planesObj = hullComponent.constructionPlanes # returns planes object
xyPlane = hullComponent.xYConstructionPlane # variable representing the xy plane
# add construction plane 1, add sketch and line
planeInput1 = planesObj.createInput() # create construction planes
offsetValue1 = adsk.core.ValueInput.createByReal(1.0)
planeInput1.setByOffset(xyPlane, offsetValue1)
plane1 = planesObj.add(planeInput1)
plane1.name = "bulkhead 1"
sketchesObj = hullComponent.sketches # returns sketches object
sketch1 = sketchesObj.add(plane1)
sketch1.name = "bulkhead 1 sketch 1" # create sketch on construction plane
lines1 = sketch1.sketchCurves.sketchLines
line1 = lines1.addByTwoPoints(adsk.core.Point3D.create(2.0, 3.0, 0.0),adsk.core.Point3D.create(4.0, 5.0, 0.0))
# add construction plane 2, add sketch and line
planeInput2 = planesObj.createInput()
offsetValue2 = adsk.core.ValueInput.createByReal(3.0)
planeInput2.setByOffset(xyPlane, offsetValue2)
plane2 = planesObj.add(planeInput2)
plane2.name = "bulkhead 2"
sketch2 = sketchesObj.add(plane2)
sketch2.name = "bulkhead 2 sketch 1" # create sketch on construction plane
lines2 = sketch2.sketchCurves.sketchLines
line2 = lines2.addByTwoPoints(adsk.core.Point3D.create(3.0, 4.0, 0.0),adsk.core.Point3D.create(5.0, 6.0, 0.0))
# everything above works fine, so lets try a loft between these two lines
path1 = rootComp.features.createPath(line1)
path2 = rootComp.features.createPath(line2)
#I also tried as below ?
#path1 = adsk.fusion.Path.create(line1, adsk.fusion.ChainedCurveOptions.noChainedCurves)
#path2 = adsk.fusion.Path.create(line2, adsk.fusion.ChainedCurveOptions.noChainedCurves)
# create a surface loft feature between the two lines
new_feature = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
loft_features = rootComp.features.loftFeatures
loft_input = loft_features.createInput(new_feature)
loft_sections = loft_input.loftSections
loft_sections.add(path1)
loft_sections.add(path2)
loft_features.add(loft_input)
Solved! Go to Solution.