I want to get a proxy from the selected profile.

I want to get a proxy from the selected profile.

kandennti
Mentor Mentor
469 Views
1 Reply
Message 1 of 2

I want to get a proxy from the selected profile.

kandennti
Mentor
Mentor

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.

 

Accepted solutions (1)
470 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor
Accepted solution

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.

 

0 Likes