ZBrushCentral

How to use zscripts to solve the exact problem of extracting values


How to use zscripts to solve the exact problem of extracting values

I’m not sure I understand your question. You can use zscript to set the value by using:

[ISet,Tool:SubTool:Thick,0.0628]

Does that not give you the value you want?

I’m sorry you didn’t understand what I mean, but thank you very much for your reply, I mean why zbrush Extract can not extract the same thickness repeatedly, for example, my ideal size is 0.2. The first time is accurate 0.2, but the second It’s not 0.2 this time, why?

OK, I see the problem now. This may be a bug in the program I will look into it further.

alright, thank you very much

Hello to bother you, can you get a solution to this problem now, thank you

I don’t have a solution. This is clearly a bug in ZBrush and will need fixing. There may be a way to reset the slider using zscript so that it produces the thickness you want but I have not found it. There appears to be some regularity to the extra thickness - for example, if you extract a thickness of 0.5 then the extra will seem be 0.25, 0.125, and so on but this doesn’t exactly transfer to other values, apart from the higher the value the greater the extra amount. With a setting of 1, the second extract is very nearly twice the thickness but not quite.

Thank you very much for your hard work

OK, I have found a solution. It turns out that the amount of extract is related to the bounding box of all the subtools. That is why the second extract is always different from the first - because the first extract extends the bounding box of all subtools.

I suppose it would be possible to calculate a correct extraction value based on the bounding box. But here is a simpler solution - the selected subtool is cloned, the extraction carried out on the clone and then the result appended back to the original tool. This gives consistent results.

[IButton,Extract,"Do accurate extract for selected subtool",
	[If,[IExists,Tool:Geometry:Del Lower], //if this is a polymesh
		[VarSet,toolID,[IGet,Tool:Item Info]] //store selected tool ID
		[IPress,Tool:Clone]
		[VarSet,cloneID,[IGetMax,Tool:Item Info]] //get clone ID
		[ISet,Tool:Item Info,cloneID]
		[IKeyPress,'1',[IPress,Tool:SubTool:Extract]] //extract even if no mask
		[IPress,Tool:SubTool:Accept]
		[VarSet,extractName,[IGetTitle,Tool:Current Tool,0]]
		[ISet,Tool:Item Info,toolID]
		[IPress,Tool:SubTool:Insert]
		[IPress,[StrMerge,"PopUp:",[Var,extractName]]]
		[ISet,Tool:Item Info,cloneID]
		//delete the clone and its extract
		[IKeyPress,'2',[IPress,Tool:SubTool:Delete]]
		[IKeyPress,'2',[IPress,Tool:SubTool:Delete]]
		//switch back to original tool
		[ISet,Tool:Item Info,toolID]
	]		
]

HTH,
Marcus

Here’s the alternative way, which calculates a revised Thick setting based on the XYZ Size of all the subtools:

[IButton,Extract2,"Do accurate extract for selected subtool",
	//get the selected subtool's size
	[VarSet,sizeCurrent,[IGet,Tool:Geometry:XYZ Size]]
	[VarSet,thickSetting,[IGet,Tool:SubTool:Thick]]
	[VarSet,thickness,sizeCurrent * 0.5 * thickSetting]
	//get bounding box size of all subtools
	[VarSet,sizeAll,sizeCurrent]
	[VarSet,activeSubTool,[SubToolGetActiveIndex]]
	[Loop,[SubToolGetCount],
		[SubToolSelect,[Val,n]]
		[If,[IGet,Tool:Geometry:XYZ Size]>sizeAll,
			[VarSet,sizeAll,[IGet,Tool:Geometry:XYZ Size]]
		]
	,n]
	//reselect selected subtool
	[SubToolSelect,activeSubTool]
	[VarSet,thicknessAll,sizeAll * 0.5 * thickSetting]
	[ISet,Tool:SubTool:Thick,thickSetting*(thickness/thicknessAll)]
	[IKeyPress,'1',[IPress,Tool:SubTool:Extract]]//extract even if no mask
	[IPress,Tool:SubTool:Accept]
	//reselect original subtool
	[SubToolSelect,activeSubTool]
	//reset Thick slider to original value
	[ISet,Tool:SubTool:Thick,thickSetting]
	//select the new Extract subtool
	[SubToolSelect,[Val,activeSubTool+1]]		
]

-Marcus

Thank you, I tested it, the first method is perfectly explained, the second method still has bugs, it doesn’t matter, thank you so much

Hello, oh can you add a password to the plug-in, because someone will sell it

Hi,

There’s no password protection built into zscript plugins. You will have to work out some security arrangement for yourself.

alright, thank you very much