Hey polycounters!
I’m currently working on a Zbrush script to speed up my pipeline to Substance, but ran into an anomaly I can’t wrap my head around.
Chances are this is a no-brainer, since I’m completely new to Zscript and not the biggest scripter in the first place. So please DO state the obvious.
The script is supposed to rename all visible subtool and cycles through all subtools checking their state using [IModGet]. When visible it renames them, other wise it doesn’t.
From my understanding [IModGet] returns a value smaller than 15 when invisible and a greater value if otherwise.
This works just fine, but after running the script a few times and changing visibility. Zbrush returns a value of 1 even for visible subtools and I can only fix that by hiding/unhiding all subtools, which seems to reset their state.
Does anyone of you know of this problem?
Maybe
@nyx702 could help
, you seem to be an Zscript archwizard
My code sofar (with out the
CheckSystem routine):
<code>[VarDef,subTName,""] //defines variable as empty string<br>[RoutineCall, CheckSystem]<br>[VarDef, newName,""] <br><br>[IButton,"RenameAllVisible","Renames all visible subtools",<br>[VarSet,totalSubTools,[SubToolGetCount]] //the total number of subtools<br>[VarSet,activeSubT,[SubToolGetActiveIndex]] //record the active subtool<br><br>[VarSet, newName,[StrAsk, "Type text in here", "Please enter a file name"]] //new name<br> [If, [StrLength, newName] < 2, //check if the name is valid<br> [Note, "Name must at least have 2 characters",2]<br> [Exit]<br> ,<br> ]<br> <br> [If,activeSubT==0,[SubToolSelect,1]] //this stops an error <br> <br> [Loop,totalSubTools,<br> [SubToolSelect,[Val,n]] //selects the subtool by number<br> [VarSet,subTName,[IGetTitle,Tool:ItemInfo]] //gets the tool name<br> [VarSet,subTName,[StrExtract,subTName,0,[StrLength,subTName]-2]] //trims off period<br> [If,[IModGet,[StrMerge,"Tool:Sub Tool:",#subTName]]>=16, //checks for state <br> [FileExecute,dllPath,"PasteText",#newName]//renames current subtool<br> [IPress,Tool:SubTool:Rename] //renames current subtool<br> ]<br> ,n]<br>]
(Props to
marcus_civis of zbrushcentral at this point, it’s 80% his code)
Replies
I'm pretty sure the issue is that you can't get info from IMod if the interface element is not visible. So you need to move the subtool list down to get that info if you have more than 8 subtools. There are multiple ways to do this involving the scroll bar but I think its easier to just select the 8th subtool. Try something like this (also bastardized from Marcus)
Let me know if that doesn't work...
This is nothing I would have ever thought of.
If I recall correctly this also happened with fewer (only ~5) stubtools though. I'll test it once I get home from work.
I'll also upload a working script
Thanks again, for taking the time!
Could be checking as a string instead of the intended integer since you are using StrMrg. Trying setting the whole thing to a Var beforehand and using [Val, variable] to make sure its a number in the If statement. I didn't use Val in my example and it still works... but Val is good for error checking because it forces it to be an number.
Here is a gif to illustrate the behavior:
Once I hide a subtool everything below is messed up, to a degree where even the state is displayed wrong, like so:
Does that ring any bell with you?
I uploaded the working script (the main script & a checkbutton). If you can find some time, some brainpower would be much appreciated!
https://drive.google.com/open?id=0B9kN79m1QbR7QmRTek5JbXJYVlE
P.s:
I even tried to save the state in a .zvr file before loading and reloading after, but with no luck .
The only other way I know to rename things is by sending the active tool to the top of the stack and using [ToolSetPath,, newName]. You dont need to use the DLL for this either which makes everything simpler.
Thank you so much though, for taking the time and get to the core of the problem!
I will try to get a hold of Marcus and will post here if there are any news.
As a last resort your idea sounds fine, but I’d hate to mix up the subtool order,..
I created a thread over at zbrushcentral, described the issue and will see if someone can make this work.
But if nothing comes of it, I'll use your solution !
Having multiple subtools with the same name caused problems when rerun.
Here is link to said post for the intressted reader/google user.
http://www.zbrushcentral.com/showthread.php?206627-IModGet-problem&p=1207707#post1207707
As a note to future me: "Read the fucking manual"
Thanks again for taking the time and show me some tricks!
Using the IDs of the subtools seems like a better/faster way. I will have to integrate that in. SubtoolSelect and SubtoolGetActiveIndex are relatively new to the Zscript lexicon. Most of my script were written before ST indexes were a thing.