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)
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...
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.
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):-
and happily lets me know what they clicked on
but frustratingly, even with every possible criteria enabled (*all* of these), while it lets me click on what I want:
and tricks me into thinking that worked:-
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:
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...
Can't find what you're looking for? Ask the community or share your knowledge.