shadowst17 Posted October 11, 2022 Share Posted October 11, 2022 (edited) Hello, I'm trying to add a few buttons in the menu when you right click a node. I could just make separate scripts but I'm curious if it's possible to add something that will allow me to run a specific function and it's required parms in the python file I have supplied it with? <menuDocument> <menu> <separatorItem/> <subMenu id="otl_manager"> <label>OTL Tools</label> <scriptItem id="create_otl"> <label>Create OTL</label> <scriptPath>E:\...\create_otl_v02.py</scriptPath> </scriptItem> </subMenu> </menu> </menuDocument> EDIT: I'm an idiot, I somehow overlooked a very obvious line about how to do this. Quote <scriptArgs> (Optional) An argument string to pass to the script when it’s called. In the script you can retrieve these arguments using the sys.argv list. This lets you use a single script for multiple menu items and vary its behavior based on the parameters. menuDocument> <menu> <separatorItem/> <subMenu id="otl_manager"> <label>OTL Tools</label> <scriptItem id="create_otl"> <label>Create OTL</label> <scriptPath>E:\...\create_otl_v02.py</scriptPath> <scriptArgs>-ma</scriptArgs> </scriptItem> </subMenu> </menu> </menuDocument> I just needed to approach my scripts differently by importing "sys" and storing sys.argv in a list which will put each spaced string in it. First one being the path of the script. Edited October 11, 2022 by shadowst17 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.