ZBrushCentral

IModSet,Tool:SubTool error

Hi, I’m trying to do some simple Macros focus on auto document export pictures.

I’m facing to some errors with the commands :

[IUnPress,Tool:SubTool:test_subtool] [IPress,Tool:SubTool:test_subtool] [IPress,Tool:SubTool:test_subtool2] [IModSet,Tool:SubTool:body9_4,18] [IModSet,Tool:SubTool:body9_2,18] [IPress,Tool:SubTool:body9_3] [IModSet,Tool:SubTool:body9_3,18]

Nothing of those lines are working, and I’ve got an error when I launch the script. Its about hide and show Folders and subtools.

Anyone have find a solution about this?

Hi,

You can’t use those commands on their own, they need to be inside a button. But also they are very specific as far as the subtool names are concerned, so that if those subtool’s don’t exist you will get errors.

If you can explain a bit more what you are trying to do I will see if I can help.

Marcus

Hi, thank you for your response. Actually, those code are generated automatically with the macro tool when I start to create a new one so it take directly the right subtools/folders name.

What I’m doing is not that complex but helps a lot on my job. I am using the timeline to create multiple view of my products to take pictures on many different and specific angles.

There is like 50 views and I save manually the pictures in jpg with the specific name the first time I’m doing the macro. Then, I only have to use the macro to generate the pictures again, I only have to press enter to validate each pictures (I need to try a way to press enter automatically but I maybe just need to add a line beetween each scripted export lines, I need to try). Here is a shorted exemple of a working file :

//ZBRUSH MACRO - Recorded in ZBrush version 2021
[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ëescí key.”,
[IShowActions,0]
[IConfig,2021]
[FileNameSetNext,“C:\test\test\screens_script\head test1.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 2.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 3.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 4.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 5.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 6.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 7.jpg”][IPress,Document:Export]
[IPress,Movie:TimeLine:Go Next]
[FileNameSetNext,“C:\test\test\screens_script\head test2 8.jpg”][IPress,Document:Export]
]

So as you can imagine, sometimes on specific pictures I need to hide and show some folders of subtools, so after the “[IPress,Movie:TimeLine:Go Next]” zbrush is adding “[IUnPress,Tool:SubTool:test_subtool]” but I’ve got an error while I’m trying the macro at this specific lines.

Sorry for my english! If I could make it click enter and hide and show the folders I want, I’ll be the happiyest man on earth!!

Hi,

OK, the macro recording clearly does not work for that. (There is some stuff that it doesn’t work for.)

Here’s a way to do what you want. Here are two routines which you must place above and outside your macro button:

//routine to turn Folder on/off using name
[RoutineDef,ToggleFolder,	
	//loop until a folder is found
	[Loop,[SubToolGetCount],									
		[VarSet,folderIndex,[SubToolGetFolderIndex,[Val,n]]]
		[VarSet,st,[SubToolGetStatus,[Val,n]]]										
		[If,folderIndex > -1,	//if we have a folder	
			//check the folder name is the one we want
			[VarSet,folderName,[SubToolGetFolderName,[Val,n]]]
			[If,(([StrLength,name]==[StrLength,folderName])&&([StrFind,name,folderName]==0)),
				//if it's the folder we want
				[If,turnOn,					
					[If,([Val,st]&0x00 == 0x00),
						[SubToolSetStatus,[Val,n],0x03]
					]
					,//else turn off
					[If,([Val,st]&0x01 == 0x01),
						[SubToolSetStatus,[Val,n],0x00]
					]				
				]	
				//all done, exit loop
				[LoopExit]			
			]//end if same name
		]//end if folder					
	,n]//end loop					
,name,turnOn]


//routine to turn SubTool on/off using name
[RoutineDef,ToggleSubTool,
	[VarSet,activeST,[SubToolGetActiveIndex]]	
	[VarSet,SubToolName,[StrMerge,"Tool:SubTool:",name]]
	[IFreeze,
		[If,[IExists,SubToolName],//if subtool exists
			[IClick,SubToolName]//select it
			[VarSet,id,[SubToolGetActiveIndex]]	
			[VarSet,st,[SubToolGetStatus]]	
			[If,turnOn,					
				[If,([Val,st]&0x00 == 0x00),//if off
					[IClick,SubToolName]//turn on
				]
				,//else turn off
				[If,([Val,st]&0x01 == 0x01),
					[IClick,SubToolName]
				]				
			]
		]	
		[SubToolSelect,activeST]	
	]
,name,turnOn]

They are for turning a folder or a subtool off or on. You just call them using the name of the folder or subtool and then a 1 for turning ON or a 0 for turning OFF. So, for example:

[RoutineCall,ToggleFolder,"test",1]

will turn the folder called “test” ON. To turn off, you would use:

[RoutineCall,ToggleFolder,"test",0]

The same for Subtools:

[RoutineCall,ToggleSubTool,"body9_3",1]

would turn ON the SubTool named “body9_3”.

Make sure you use quotation marks around the names, as I have done.

For exporting the Document as a JPG, there is no way to get rid of having to pressing OK. But if you use a different file format then it will be automatic.

I hope this helps,
Marcus

1 Like

Hi thanks a lot for your help thats working!!! Because I could not press a button while the macro is runing, I just added your two routines inside the macro file and then called it bellow when needed. I just need to look into the docs to add those routines outside the files to not have to add them manually at every new macros. This is the only part not clear yet to me, but I will check again tomorrow after processing this routines things!

Thanks again for your help Marcus :slight_smile:

1 Like