ZBrushCentral

XYZ Size for a ZTool?

Is there a simple way to get the TOOL’s(not subtool) xyz size from Zscript? I noticed when looking at scale master’s operation it’s getting it from somewhere, and the DLLs dont look like they have custom functions for scale in them… any ideas how this was done?

I’ve got a lot of functions that I’ve been using a scale modifier calculated by merging visible Subtools and then storing the merged models XYZ size before deleting it and using the modifier in the remainder of the script. It’s messy and I can imagine on complex scenes it’d be a trainwreck.

Any heros out there?

Yes, you can use Mesh3DGet:

// Calculates the XYZ bounding box size for all subtools
[RoutineDef,gAllSubToolsBoundingBox,

	[VarSet, xmin, 0]
	[VarSet, ymin, 0]
	[VarSet, zmin, 0]
	[VarSet, xmax, -1]
	[VarSet, ymax, -1]
	[VarSet, zmax, -1]
	
	[If,visibleonly,
		[VarSet,Opt,2]
	,
		[VarSet,Opt,3]
	]

	// Get bounding box of all Subtools
	[Mesh3DGet, 2, Opt,, xmin, ymin, zmin, xmax, ymax, zmax]
	[VarSet,xsize,ABS(xmin-xmax)]
  	[VarSet,ysize,ABS(ymin-ymax)]
  	[VarSet,zsize,ABS(zmin-zmax)]
  	[VarSet,xyzsize,MAX(xsize,ysize)]
  	[VarSet,xyzsize,MAX(xyzsize,zsize)]

,visibleonly,xyzsize,xsize,ysize,zsize]

-Marcus

Marcus I could kiss you. MY HERO!

1 Like

The truth is the docs for mesh3dget could be clearer ! I didnt know it was bounding positions! was sitting here with a debug plugin trying to figure out wtf the values were haha

1 Like

Yes, I will try and improve the documentation when I have a moment!