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: 

I want to get a proxy from the selected profile.

1 REPLY 1
SOLVED
Reply
Message 1 of 2
kandennti
220 Views, 1 Reply

I want to get a proxy from the selected profile.

Hi there.

 

I'm struggling with a lack of understanding about proxy.

 

The data is in this state and is attached.

2.png

I use the following code to select the profile. selectEntity is used to select the profile and then try to get the proxy, but I get an error with each one and cannot get it. (The same is true with SelectionCommandInput)

#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        msg :str = 'Select'
        selFiltter :str = 'Profiles'
        sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
        if not sel: return

        prof :adsk.fusion.Profile = sel.entity

        # test1
        print('test1')
        occ :adsk.fusion.Occurrence = prof.assemblyContext
        try:
            proxy = prof.createForAssemblyContext(occ)
            print('{}:OK'.format(occ.name))
        except:
            print('{}:NG'.format(occ.name))

        # test2
        print('\ntest2')
        for occ in root.allOccurrences:
            try:
                proxy = prof.createForAssemblyContext(occ)
                print('{}:OK'.format(occ.name))
            except:
                print('{}:NG'.format(occ.name))
        a=1

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def selectEnt(
        msg :str, 
        filtterStr :str) -> adsk.core.Selection :

    try:
        sel = _ui.selectEntity(msg, filtterStr)
        return sel
    except:
        return None

 

The result looks like this.

test1
Occurrence1:2:NG

test2
Occurrence1:1:NG
Occurrence1:2:NG

 

Does anyone know how to get the proxy from the user's selected profile?

Best regards.

 

1 REPLY 1
Message 2 of 2
kandennti
in reply to: kandennti

I interpreted it as a proxy if the value could be retrieved by assemblyContext Property.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-911fdac9-e6e7-4e4f-b500-b94bafc347f6 

 

That is, I understood that the elements selected in ui.selectEntity and SelectionCommandInput were proxies.

 

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