Help: Can't trigger action

laikennuslaikennus Posts: 9
var mgr = MainWindow.getActionMgr();func = mgr.findAction("DzBindingGeneralMapAction")func.trigger();

 

The output for this is: (line 5) TypeError: Result of expression 'func' [null] is not an object. So I guess it can't find DzBindingGeneralMapAction.

Is there a way to execute that action?

Reference: http://ut1-webvirt-wiki.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/interface/inline/weight_map_brush/dzbindinggeneralmapaction

Post edited by laikennus on

Comments

  • OmnifluxOmniflux Posts: 250

    For some reason, some actions have a name of DzAction, and so cannot be found this way.

    Try this

    var oMgr = MainWindow.getActionMgr();var nActions = oMgr.getNumActions();for (var i = 0; i < nActions; i++){	oAction = oMgr.getAction (i);	if (oAction.text == "General Map")		oAction.trigger();}

     

  • Omniflux said:

    For some reason, some actions have a name of DzAction, and so cannot be found this way.

    Try this

    var oMgr = MainWindow.getActionMgr();var nActions = oMgr.getNumActions();for (var i = 0; i < nActions; i++){	oAction = oMgr.getAction (i);	if (oAction.text == "General Map")		oAction.trigger();}

     

     

    Thank you very much Omniflux! That did it!

  • Rob has a script to help with finding the names to use for actions http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/actions/action_find_classname/start

    Unfortunately the documentation you link to is using an older classname.

  • OmnifluxOmniflux Posts: 250

    Thanks Rob!

    With that information, your original code can be used as such:

    var mgr = MainWindow.getActionMgr();var func = mgr.findAction ("DzNodeWeightGeneralMapAction")func.trigger();

     

  • Omniflux said:

    For some reason, some actions have a name of DzAction, and so cannot be found this way.

    Try this

    var oMgr = MainWindow.getActionMgr();var nActions = oMgr.getNumActions();for (var i = 0; i < nActions; i++){	oAction = oMgr.getAction (i);	if (oAction.text == "General Map")		oAction.trigger();}

     

    Do note that DzActionMgr::findAction() uses the action's classname, not its name.

  • That's great! Thank you very much Omniflux and Richard!

     

Sign In or Register to comment.