Search - User list
Full Version: Running a MEL script from HDA button
Root » Houdini Engine for Maya » Running a MEL script from HDA button
christianmarzy
Hey Guys,
I would like to make an HDA in Maya to have certain "Asset Options" set by default. Typing the following in the MEL script editor works:

setAttr myHdaName1.splitGeosByGroup 1

If i type the following in the Python script editor it also works:

cmds.setAttr("myHdaName1.splitGeosByGroup", 1)

Now, I would like the HDA to set that automatically, or have a button on the HDA that sets it for the user. There is some documentation, but I guess I am missing some basic steps. Here is what I tried:


Adding Callback script to button:
hou.phm().turnToggleOn()





#Button needs Callback Script: #hou.phm().turnToggleOn()
def turnToggleOn():

    me = hou.pwd()
    me.setParms({"myToggle": 1})
    print ("Turned Toggle on")




It works for the areas in green, but does not for the red area.

How can I do this with the "Asset Option" splitGeosByGroup?

I tried a lot of uneducated nonsense here, none of that worked for me:
    
def groupToggle():
import maya.cmds as cmds
import maya.mel as mel
import hou

cmds.setAttr("TA_cmarzy__maya__groups_example__1_21.splitGeosByGroup", 1)
mel.setAttr("TA_cmarzy__maya__groups_example__1_21.splitGeosByGroup", 1)

As you can see I did not even figure out how to reference the current HDA itself. The documentation on https://www.sidefx.com/docs/maya/_maya__scripting.html [www.sidefx.com] does not convey the basic steps to me. Could anyone explain what I am doing wrong?
johnmather
Nodes are cooked in a separate Houdini process, not within Maya. Because of this, the code you have placed in your HDA is run inside Houdini - not Maya, so it has no effect. Currently there is no way to achieve what you want without resorting to some hackery with the HoudiniAsset AEtemplate files. Some clients have attempted to open a command port in Maya and then communicate with it from within their HDA with limited success. I'll have a think and see if there is a clean way to expose this functionality for you.
christianmarzy
Thank you for your reply. I accepted that there is no way to achieve what I want without resorting to some hackery and asked the users to do that manually every time they use the tool.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB