[SOLVED]DzCreateItemAction Question

LpProjectLpProject Posts: 41


I have my own MxGrassNode class inherited from DzNode,

and his MxGrassNodeAcion class inherited from DzCreateItemAction.

Now I what to show MxGrassNode in "create item" menu only when the some condition is true.

How can I do it?  Please help.

DzAction setOff not helped

Post edited by LpProject on


  • surrealsurreal Posts: 99


    I have only used DzEditAction in the plugins I have made, however I would expect that the same principles would apply for DzCreateItemAction .

    ///////////////////////////////////DzMxGrassNodePluginAction.h /////////////////////////////////class DzMxGrassNodePluginAction : public DzCreateItemAction{	Q_OBJECTpublic:	DzMxGrassNodePluginAction();public slots:	/**	We need to reimplement this virtual function to perform our 'action'.	This gets called whenever the user clicks on our action item.	**/	virtual void	executeAction();protected slots:	void	chkUnhide();};///////////////////////////////////DzMxGrassNodePluginAction.cpp /////////////////////////////////// Menu item to appear in the CREATE item menu action groupDzMxGrassNodePluginAction::DzMxGrassNodePluginAction() : DzCreateItemAction("New MxGrassNode", "Create a new MxGrassNode."){	this->setVisible(false); //Set the initial state	// Create a listener on the change of node selection list	connect(dzScene, SIGNAL(nodeSelectionListChanged()), this, SLOT(chkUnhide()));}// When the action is activated, create a MxGrassNode item in the scenevoid DzMxGrassNodePluginAction::executeAction(){	//TODO: Write code to add a new MxGrassNode item to the scene.}// Hide this menu item if no items selected void	DzMxGrassNodePluginAction::chkUnhide(){	this->setVisible(dzScene->getSelectedNodeList().count() > 0);}


  • LpProjectLpProject Posts: 41
    edited October 2015

    Thanks for reply, but I don't want hide MxGrasNode from viewport,

    I wan't to remove MxGrassNode from "Create" Menu of Daz Studio.

    I need:

    when running Daz Studio , check some condition, to add ( or not add) "New MaxwellGrass" item to the Daz Studio "Create" menu.

    How can I do it?


    Post edited by LpProject on
  • surrealsurreal Posts: 99

    The code above hides or unhides the menu item.

    It does not hide or unhide items/nodes in the viewport (scene).

    The "this->setVisible(false)" statement will set the menu item's initial state to hidden.

    The "connect(..." statement is the 'check some condition'.  In the code above I have used the condition of when something is selected or deselected in the scene. You would change the statement to listen for whatever condition you required in your code. In the code above when anything is selected or deselected it will call the chkUnhide function.

    The chkUnhide function will hide the menu item (i.e. this->setVisible(false)) if there is nothing selected in the scene (i.e. dzScene->getSelectedHodeList().count() > 0 is false), or it will unhide the menu item (i.e. this->setVisible(true)) if there is one or more things selected (i.e. dzScene->getSelectedHodeList().count() > 0 is true).

    You would replace the "dzScene->getSelectedHodeList().count() > 0" with whatever condition function you required in your code.

    Dynamically creating and destroying an Action (menu item) everytime your condition changes would be inefficient. It is simpler to create the action (menu item) when the add-in is loaded and then just hide or unhide it dependant on your condition. If for some reason you did not want to use the hide or unhide, I guess you could go the extra step and write some code to add and remove the item (menu item) from the create group.



  • many thanks

Sign In or Register to comment.