How can create loft by some edges.

How can create loft by some edges.

ho-kou
Advocate Advocate
379 Views
2 Replies
Message 1 of 3

How can create loft by some edges.

ho-kou
Advocate
Advocate

hi, veryone.

I want to use some edges(Picture1) to create a loft (Picture2).

But use my code can't do it.

Thank your for your help.

 

 

 

 

Here is my code:

 

 

        colChnagedEdge_1 = adsk.core.ObjectCollection.create()
        colChnagedEdge_1.add(edge1)
        colChnagedEdge_1.add(edge2)

        colChnagedEdge_2 = adsk.core.ObjectCollection.create()
        colChnagedEdge_2.add(edge3)
        
        loftFeats = _rootComp.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftSectionsObj = loftInput.loftSections

  
        path1 = adsk.fusion.Path.create(colChnagedEdge_1, adsk.fusion.ChainedCurveOptions.connectedChainedCurves)
        section1 = loftInput.loftSections.add(path1)
        section1.setTangentEndCondition(adsk.core.ValueInput.createByReal(1.0))

        path2 = adsk.fusion.Path.create(colChnagedEdge_2, adsk.fusion.ChainedCurveOptions.connectedChainedCurves)
        section2 = loftInput.loftSections.add(path2)
        section2.setTangentEndCondition(adsk.core.ValueInput.createByReal(1.0))

      
        loftInput.isSolid = True
        loftInput.isClosed = False
        loftInput.isTangentEdgesMerged = False
        loftFeats.add(loftInput)

 

 

0 Likes
Accepted solutions (1)
380 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

I tested your code, and it worked for me. Are you sure your edge1, edge2, and edge3 variables are being set correctly? Here's my full code. I select the edges first and then run the script. The edges are retrieved in the same order they're selected, so the two connected edges must be selected first, and then the third individual edge.

 

def LoftSample():
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        des: adsk.fusion.Design = app.activeProduct
        _rootComp = des.rootComponent
        edge1 = ui.activeSelections[0].entity
        edge2 = ui.activeSelections[1].entity
        edge3 = ui.activeSelections[2].entity

        colChnagedEdge_1 = adsk.core.ObjectCollection.create()
        colChnagedEdge_1.add(edge1)
        colChnagedEdge_1.add(edge2)

        colChnagedEdge_2 = adsk.core.ObjectCollection.create()
        colChnagedEdge_2.add(edge3)
        
        loftFeats = _rootComp.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
  
        path1 = adsk.fusion.Path.create(colChnagedEdge_1, adsk.fusion.ChainedCurveOptions.connectedChainedCurves)
        section1 = loftInput.loftSections.add(path1)
        section1.setTangentEndCondition(adsk.core.ValueInput.createByReal(1.0))

        path2 = adsk.fusion.Path.create(colChnagedEdge_2, adsk.fusion.ChainedCurveOptions.connectedChainedCurves)
        section2 = loftInput.loftSections.add(path2)
        section2.setTangentEndCondition(adsk.core.ValueInput.createByReal(1.0))
      
        loftInput.isSolid = True
        loftInput.isClosed = False
        loftInput.isTangentEdgesMerged = False
        loftFeats.add(loftInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

ho-kou
Advocate
Advocate

Thank you very much for your help.

0 Likes