//ZBrush Macro by marcus_civis August 2019
//Save file to Pixologic\ZBrush 2019.1\ZStartup\Macros\Misc folder

[IButton,???,"Set selected ZSphere to Draw Size",
	//Check we have a ZSphere
	[If,[IExists,Tool:Geometry:SDiv],
		[If,[IExists,Tool:AdaptiveSkin:Make Adaptive Skin],
			[If,[IsEnabled,Tool:Adaptive Skin:Preview],,			
			[Exit]
			]
		,			
			[Exit]
		]
	,
		[Exit]
	]
	//OK, get the scale
	[If,[MemGetSize,ZifDSize_Mem],,[MVarDef,ZifDSize_Mem,9,0]]
	[MTransformGet,ZifDSize_Mem,0]
	[VarSet,xScale,[MVarGet,ZifDSize_Mem,3]]
	//get Draw Size
	[VarSet,drwSize,[IGet,Draw:Draw Size]]
	[If,([IModGet,Draw:Draw Size]==1),//Dynamic is on
		[VarSet,zifSize,(drwSize/500)]
		,
		[VarSet,zifSize,(drwSize/(xScale/2))/2]//Dynamic off
	]	
	//Edit ZSpheres
	[ZSphereEdit,		
		[VarSet,clickd,[ZSphereGet,8]]//get last clicked
		[If,clickd > -1,//if we have a selected zsphere	
			[If,[IGet,Transform:Activate Symmetry],		
				[VarSet,tmStmpSel,[ZSphereGet,9,clickd]]//get time stamp			
				[Loop,[ZSphereGet,0],//loop all zspheres
					[VarSet,tmStmp,[ZSphereGet,9,[Val,n]]]//check time stamp				
					[If,(tmStmpSel == tmStmp),//if they're the same 	
						[ZSphereSet,4,[Val,n],zifSize]//adjust size
					]
				,n]//end loop
				,//else symmetry off
				[ZSphereSet,4,clickd,zifSize]//adjust size for selected zsphere
			]//end if symmetry
		]//end if clicked
	,0]	
,,0.5]//button size - half palette width
