Message 1 of 4
Bug Report? - How to select which right-click linearMarkingMenu context menus to add my Add-in command into ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)