Help on API custom command to create a sweep through an unchained edge selection

Help on API custom command to create a sweep through an unchained edge selection

2way3dtext
Contributor Contributor
640 Views
2 Replies
Message 1 of 3

Help on API custom command to create a sweep through an unchained edge selection

2way3dtext
Contributor
Contributor

May I receive some advice on adjusting this add-in to be able to select edges as an unchained option? The following code only allows for chained selection of edges.

 

            path_Input = inputs.addSelectionInput('path_Input', 'Path', 'Select path of pipe')

            path_Input.setSelectionLimits(1,1)

            path_Input.addSelectionFilter('Edges')

            path_Input.addSelectionFilter('SketchCurves')

 

 

I was able to use an unchained edge selection with a following code as a script, however the same code does not work as an add-in.

 

        sel = ui.selectEntity('Select a path to create a pipe', 'Edges,SketchCurves')

        selObj = sel.entity

        chainedOption = adsk.fusion.ChainedCurveOptions.noChainedCurves

        path = adsk.fusion.Path.create(selObj, chainedOption)

 

Is there a way to convert the script code to be suitable as an Add-in? Which websites would be recommended when researching specific API lines and sample API codes (including the fusion 360 website) in the future?

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

kandennti
Mentor
Mentor
Accepted solution

Hi @2way3dtext .

 

There are probably two causes.

・・・
def CreateRoundedEndPipe(path, pipeDiameter) :
    try:
        pipeRadius = pipeDiameter/2

        product = _app.activeProduct
        design = adsk.fusion.Design.cast(product)
        
        comp = design.rootComponent
        selObj: adsk.fusion.BRepEdge = path

        # create path
        feats = comp.features
        # chainedOption = adsk.fusion.ChainedCurveOptions.connectedChainedCurves # <- It's here.
        chainedOption = adsk.fusion.ChainedCurveOptions.noChainedCurves
        if adsk.fusion.BRepEdge.cast(selObj):
            chainedOption = adsk.fusion.ChainedCurveOptions.tangentChainedCurves
        path = adsk.fusion.Path.create(selObj, chainedOption)
        # path = feats.createPath(selObj) # <- It's here.
・・・


I've pointed out one of them here.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/help-for-api-script-to-create-a-pipe-with-... 

0 Likes
Message 3 of 3

2way3dtext
Contributor
Contributor

@kandennti

 

Thank you so much for your generous help.

 

When I fixed the code as you have shown me, I was able to select an unchained edge!

 

I am learning more about coding in API thanks to your continued support.

0 Likes