ZBrushCentral

[IModGet] problem

Hi everyone :)!
I am working on a script that is supposed to help the user making changes to subtools based on visibility (e.g. apply color to all subtool, rename visible subtools,…)

To check the visibility I used the “mod-check” technique described by marcus_civis (thanks for the awesome help!)
Unfortunately I ran into a problem when combining [IModGet] with the rename function that came as part of the ZFileUtils. At some point the mod of the subtools gets messed up.
Here a little gif that illustrates that behavior (the number is the mod of the current subtool).

I also talked with Nick Miller (awesome guy!) on Polycount about this. His best guess was, that probably the DLL is causing the problem.
Now I have come here to ask, if one of you knows of a different reason that might have caused this, or if there is a way to fix the DLL (if broken).

Here is a link to the plugin if you want to see for yourself:
https://drive.google.com/open?id=0B9kN79m1QbR7QmRTek5JbXJYVlE

Attachments

2m5q0pi2qu4a.gif

You’ve got some redundant code in there which seems to be causing the problem - you are using SubToolSelect and also SubTool Select down. You don’t need both. And SubToolSelect should be at the top of the loop to make sure you are testing the right subtool. Also, bear in mind that your code renames subtools with the same name and this could cause problems if you re-run your code on the same set of subtools.

[Loop,totalSubTools,

[SubToolSelect,[Val,pos]] //selects the subtool by number

[If,pos < 8,

[VarSet,subTName,[IGetTitle,Tool:ItemInfo]] //gets the tool name

[VarSet,subTName,[StrExtract,subTName,0,[StrLength,subTName]-2]] //trims off period at the end

[VarSet,subTstate,[IModGet,[StrMerge,“Tool:Sub Tool:”,#subTName]]]

[If,[Val,subTstate]>=16, //checks for state; <15 = hidden

[FileExecute,dllPath,“PasteText”,#newName]//renames current subtool

[IPress,Tool:SubTool:Rename]//renames current subtool

//[Note, [Val,subTstate] ,2]

,

//[Note, [Val,subTstate] ,2]

]//ifend

]//ifend

,pos]//loop end

Thank you so much Marcus!
Preventing multiple subtools with the same name, really did the trick.

Here’s a different method for checking subtool visibility when looping through all subtools. This doesn’t use the name of the subtool, so should avoid problems associated with names.

[IButton,“Do Visible”,“Show which subtools are visible”,
[VarSet,activST,[SubToolGetActiveIndex]]//get active subtool
[Loop,[SubToolGetCount],

[SubToolSelect,[Val,n]]

[If,[Val,n] < 7,

[VarSet,stID,[Val,n]]

,

[VarSet,stID,7]

]

[If,[IModGet,[StrMerge,"Tool:Sub Tool ",stID]]>=16,

//code for visible subtools here

[Note,[StrMerge,“SubTool #”,[Val,n]," is VISIBLE"],1]

,

//code for hidden subtools here

[Note,[StrMerge,“SubTool #”,[Val,n]," is HIDDEN"],1]

]

,n]
[SubToolSelect,activST]//reselect active subtool
]

And for checking the visibility of a single subtool (the selected subtool) you can use:

[IButton,“Get Visible”,“Get visibility of selected subtool”,
[VarSet,activST,[SubToolGetActiveIndex]]
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,([SubToolGetCount]-(activST+1))]
[If,[IModGet,“Tool:Sub Tool 0”]>=16,

[Note,“Selected subtool is VISIBLE”,1]

,

[Note,“Selected subtool is HIDDEN”,1]

]
]

Awesome that would be even better :), I’ll try to change to approach that right away!
Thanks again!