Bug Report? - How to select which right-click linearMarkingMenu context menus to add my Add-in command into ?

Bug Report? - How to select which right-click linearMarkingMenu context menus to add my Add-in command into ?

OceanHydroAU
Collaborator Collaborator
466 Views
3 Replies
Message 1 of 4

Bug Report? - How to select which right-click linearMarkingMenu context menus to add my Add-in command into ?

OceanHydroAU
Collaborator
Collaborator
The "Bodies" and "Sketches" control-containers which appear inside components (other than the root one) inside the Browser are not populating the "args" in the MarkingMenuEventHandler
 
I've written an add-in with a "nesting" command (for laying out parts to CNC/laser cut) which makes sense to invoke when the user right-clicks on assorted different things, including:
 
  • The root component in the browser ( adsk::fusion::Component )
  • The "bodies" root entry inside the browser root ( adsk::fusion::BRepBodies )
  • The "sketches" root entry inside a component ( adsk::fusion::Sketches )
  • A sub component in the browser ( adsk::fusion::Occurrence )
  • The "bodies" root entry inside a component ( NoneType )
  • The "sketches" root entry inside a component ( NoneType )
  • An actual body or face in the browser [or the body/face  itself] ( adsk::fusion::BRepBody / adsk::fusion::BRepFace )
  • The root in a flatpattern ( adsk::fusion::FlatPatternComponent ) or the "bodies" entry inside it ( BRepBodies - adsk::fusion::BRepBodies ) or a body in that
  • Any sketch profile ( adsk::fusion::Profile )

 

The point of the right-click is to give them rapid access (preselect + preview) to lay out copies of the shape(s) they've indicated by the right-click.

 

Is there a workaround to identify the "NoneType" browser elements I've highlighted above which they've clicked on and what bodies/profiles they're wanting to nest from there?  Can I "work backwards" from the "NoneType" passed in to me to find the component they clicked in?

 

My code so far (simply prints out what they right-clicked on, to help me work out how to identify the context):-

 

        class MyMarkingMenuHandler(adsk.core.MarkingMenuEventHandler):
            global uiel, handlers, userdata
            def __init__(self, pnlid):
                super().__init__()
                self.pnlid=pnlid 
            def notify(self, args):
                try:

                    if 1:
                        if args.selectedEntities.size:
                            myt=args.selectedEntities.front().__class__.__name__
                        if myt != 'NoneType':
                            try:
                                t=args.selectedEntities.front()
                                myt = f"{myt} - {t.classType()}"
                                myt = f"{myt} '{getattr(t,'name')}'"
                                myt = f"{myt} 'id={getattr(t,'id')}'"
                            except: pass
                            try:
                                myt = f"{myt}: {args.front()._get_name()}"
                            except: pass
                        elif getattr(args,'linearMarkingMenu'):
                            try:
                                mnu=args.linearMarkingMenu
                                ctrl=mnu.controls
                                for m in ctrl:
                                    if m.isVisible:
                                        eprint(f"\t{m.id}")
                            except: pass

                        eprint(myt)

 

 

0 Likes
467 Views
3 Replies
Replies (3)
Message 2 of 4

OceanHydroAU
Collaborator
Collaborator

See also my bug report in the correct forum which has more details (same bug affects commands as well as menu creation):  https://forums.autodesk.com/t5/fusion-support/bug-report-arguments-in-markingmenueventhandler-are-mi...

0 Likes
Message 3 of 4

BrianEkins
Mentor
Mentor

When NoneType is returned, in this case, something is selected for which the API doesn't have an object that represents the selection. What's selected only exists in the browser as a convenience to group a set of entities. The API will need to expose some kind of browser-related functionality before something useful can be returned. Right now, I can't think of a feasible workaround.

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

OceanHydroAU
Collaborator
Collaborator

The closest I could get to a "workaround" was to look through the entries within the menu they've clicked on, to guess what kind of thing it was.  Kindof works, but if there's 2+ components in the design, you still can't find *which* of those components the click happened on.

 

I also experimented with SelectionCommandInput - this works fine for individual things (Bodies, sketch profiles, etc):-

pic_2024-04-04_09.19.40_429.png

and happily lets me know what they clicked on

pic_2024-04-04_09.13.31_428.png

 

but frustratingly, even with every possible criteria enabled (*all* of these), while it lets me click on what I want:

pic_2024-04-04_09.21.06_430.png

and tricks me into thinking that worked:-

pic_2024-04-04_09.21.42_431.png

in reality, it only gives me the design root component (if "RootComponents" was in my selection criteria, otherwise I get the component's Occurrence with "Occurrences" my criteria) every time:

pic_2024-04-04_09.27.05_433.png

pic_2024-04-04_09.22.21_432.png

Neither of which was the group of bodies I clicked on and wanted to select all-at-once (and without  'RootComponents' /'Occurrences' selectable, nothing in the browser can be selected)

 

Oh well... could be worse... at least users can shift-click on things to manually select them all I suppose...

0 Likes