Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can create loft by some edges.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ho-kou
89 Views, 2 Replies

How can create loft by some edges.

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)

 

 

2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: ho-kou

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
in reply to: ho-kou

Thank you very much for your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report