ZBrushCentral

ZScript Help - Dynamic Subdivision Toggle

Hello, I have just finished my first zplugin and as the title suggests, it is pretty simple.
I learned zscript as I went so I am sure I am not following the best coding practices yet.

It works for my current workflow but now that I’m done with it, I have several questions.

I created the following buttons:
dynSubd

My idea is that it will only affect subtools that have a specific prefix, in this case “dyn”.
I also wanted to turn dynamicSubd on and off on visible subtools only, hence the switch there as one more “filter”.
The “add prefix” button is just that so I don’t have to type it everytime, and it works fine for me.

So my questions are:

  1. Is there a way to make it so in a way that zbrush doesn’t go through all the subtools everytime? Even with IFreeze in the code, it still takes more time than Tool: Subtool: All High and Tool: Subtool: All Low standard actions. What I have right now is just a loop that checks the switch, the prefix and if the tool has dynSubd on (when it turns it all off).

  2. I’ve tried adding a percentage progress NoteBar to make it a bit fancier, but even with IFreeze, all I see are the “Switching to Subtool” notes for each subtool it goes through. How can I properly implement it during the looping operation?

  3. Is it possible to make a ISubPalette that’s inside the main ISubPalette be open by default? Maybe I will just use a separator instead. I’m thinking about future plugins I make in the future.

  4. I’ve found two problems that it took me so long to fix. They were affecting the checks in the loop: Folders and Polypaint. Anything above the folders got ignored and the visibility check always returned 1 if the subtool had polypaint. So what I did was turn off “Show Subtools Folders” and Polypaint before the loop and turn it back on after the loop. It feels like a weird workaround. Is that ok to do? Are things taking longer because of this?

Thank you!

Hi,

Sorry for the delay in replying - it’s been a busy week!

  1. If you want to check the subtool name and other settings like Dynamic Subdiv you need to actually select the subtool in your code so there’s no alternative, sadly.

  2. Yes, I couldn’t get this to work either. (I think it used to, so not sure why it has stopped.) I will investigate further when I have time.

  3. I don’t think so. Some sort of separator - such as a disabled ISwitch - needs to be used instead.

  4. Here’s some code that may help:

     [RoutineDef,DoIt,
     	[If,[IExists,Tool:Polypaint:Colorize],
     		[If,[IsEnabled,Tool:Polypaint:Colorize],
     			[If,[IGet,Tool:Polypaint:Colorize]==1,
     				[Note,"Polypaint is ON for this SubTool!",,2]
     			]
     		]
     	]
     ]
    
     [RoutineDef,DoVisible,//routine to select visible subtools
     	[VarSet,activeSubT,[SubToolGetActiveIndex]]		
    
     	[If,([IGet,Transform:Solo] == 1),//if Solo mode on
     		[RoutineCall,DoIt]	
     	,//else Solo off, do all subtools	
     		[If,(notFoldr == 1),//all subtools	
     			[VarSet,iD,0]
     			[Loop,[SubToolGetCount],						
     				[VarSet,isVis,0]		
     				[VarSet,actIndex,[Val,iD]]
     				[VarSet,st,[SubToolGetStatus,actIndex]]
     				[VarSet,fInd,[SubToolGetFolderIndex,actIndex]]
     				[If,((allVis)||(actIndex == activeSubT)),//active subtool
     					[VarSet,isVis,1]
     					,	
     					[If,(fInd > -1),//it's in a folder		
     						[VarSet,stFld,[SubToolGetStatus,fInd]]	//get folder visibility			
     						[If,([Val,stFld]&0x2 == 0x2)&&([Val,st]&0x1 == 0x1),									
     							[VarSet,isVis,1]							
     						]
     					,	//else no folder
     						[If,([Val,st]&0x1 == 0x1),		
     							[VarSet,isVis,1]						
     						]
     					]
     				]
     				[If,(isVis == 1),
     					[SubToolSelect,[Val,iD]]		
     					[RoutineCall,DoIt]
     				]											
     				[VarInc,iD]
     			]
     		,//else Folder only
     			[VarSet,folderIndex,[SubToolGetFolderIndex]]
     			[If,folderIndex > -1,	//if we have a folder						
     				[VarSet,iD,folderIndex]					
     				[Loop,[SubToolGetCount],								
     					[VarSet,status,[SubToolGetFolderIndex,[Val,iD]]]
     					[VarSet,st,[SubToolGetStatus,[Val,iD]]]										
     					[If,(status == folderIndex),
     						[If,(allVis)||([Val,st]&0x1 == 0x1)||([Val,iD]==activeSubT),//if it's visible or active
     							[SubToolSelect,[Val,iD]]	
     							[RoutineCall,DoIt]							
     						]
     						,//else end of folder				
     						[LoopExit]
     					]					
     					[VarInc,iD]			
     				]				
     				,
     				[Note,"\Cff9923No folder selected. Operation cancelled"]
     			]
     		]//end all subtools
     	]//end if Solo mode on
     	[SubToolSelect,activeSubT]
     ,notFoldr,allVis]//end routine
    
    
     [IButton,CheckVisible,"Do it",
     	[RoutineCall,DoVisible,1,0]
     ]
    
     [IButton,CheckFolder,"Do it",
     	[RoutineCall,DoVisible,0,0]
     ]
    

-Marcus

1 Like