[SOLVED]DzCreateItemAction Question
LpProject
Posts: 41
HI.
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
Comments
Hi,
I have only used DzEditAction in the plugins I have made, however I would expect that the same principles would apply for DzCreateItemAction .
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?
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