Jump to content

(SOLVED)Houdini Menu <ScriptPath> run specific function in Py Script.


Recommended Posts

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 by shadowst17
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...