ZBrushCentral

frame model script help

I am not a huge fan on how far zbrush 3.5r3 scales in on the model when the “f” key is pressed.

I liked it better before 3.5 where there was a nice boarder all the way around your model and you could see the entire model when you hit the "f" key. I am trying to figure out a way to get back to the old style of framing. Right now I just have a basic macro that works, but it is very slow. I want the script/macro to just run and not animate the transition. Anyway, here is my zscript so far [IPress,Transform:Fit] [CanvasStroke,(ZObjStrokeV03n36%p3A3B62Cp20CCEA8Pn4109n22C9n-F525s1896C0Es1896C0Es1896C0Ez-16F= YH-2012V-1FF8K4H-2012V-1FF9KXH-2012V-1FFAH-2012V-1FFBH-2012V-1FFCH-2012V-1FFDH-2012V-1FFEH-2012V-1FFFH-2012V-2000H-2012V-2001H-2012V-2002H-2012V-2003H-2011V-2004H-2011V-2005H-2011V-2006H-2011V-2007H-2011V-2008H-2010V-2008H-2010V-2009H-2010V-200AH-2010V-200BH-2010V-200CH-200FV-200DH-200FV-200EH-200FV-200FH-200FV-2010H-200FV-2011H-200FV-2012H-200FV-2013H-200EV-2013H-200EV-2014H-200EV-2015H-200EV-2016H-200EV-2017H-200EV-2017H-200EV-2017)] ] It's ugly I know, but it does the job. Anyway, that is what zbrush spits out if I try to record the macro of me framing the model and then scaling out a big so that there is a decent border around my model. Can anyone help me streamline this? perhaps with a slider that I can set how much zbrush scales out my model with I run the script? Thanks in advance.

Hi Eric,

If you temporarily increase the canvas zoom the mesh will be fitted to that. After resetting the zoom you should get the size you want. This is the idea:


[IButton,Fit,"Fit mesh to view",
[IFreeze,
[VarSet,tmpZoom,[CanvasZoomGet]]
[CanvasZoomSet,tmpZoom*1.1]
[IPress,Transform:Fit]
[CanvasZoomSet,tmpZoom]
]
]

As you’ll know, the [IFreeze is to hide the process from the user. You could add a slider to provide the value that the canvas is enlarged if you wanted.

HTH,

This is different way which makes use of the transform values of the object - essentially the same as your original macro but using zscript commands.


[ISlider,"Fit Value",0.9,.01,0.1,1.5
,"Set value for mesh fit",,,1]

[IButton,FitMesh,"Fit mesh to view",
	[IFreeze,
		[VarSet,fVal,[IGet,zscript:Fit Value]]
		[IPress,Transform:Fit]
		[TransformGet,xPos,yPos,zPos,
                     xScale,yScale,zScale,xRotate,yRotate,zRotate]
		[TransformSet,xPos,yPos,zPos,
                     xScale*fVal,yScale*fVal,zScale*fVal,xRotate,yRotate,zRotate]
	]//end freeze	
]//end button

Hey Marcus,

Thanks a ton for your help! I really appreciate your time :D Your code works beautifully. It is EXACTLY what I was looking for!

But I am afraid I am running into a snag trying to put this into the UI so that I can assign a hotkey to it.

I feel like I am fairly close, possibly just missing some simple syntax?

    [ISubPalette, "Zplugin:TEST"]
    
    [ISlider,"Zplugin:TEST:frame_value",0.9,.01,0.1,1.5
    ,"Set value for mesh fit",,,1]
    
    [IButton,"Zplugin:TEST:frame",FitMesh,
    	[IFreeze,
    		[VarSet,fVal,[IGet,zscript:Fit Value]]
    		[IPress,Transform:Fit]
    		[TransformGet,xPos,yPos,zPos,
    			 xScale,yScale,zScale,xRotate,yRotate,zRotate]
    		[TransformSet,xPos,yPos,zPos,
    			 xScale*fVal,yScale*fVal,zScale*fVal,xRotate,yRotat  e,zRotate]
    	]//end freeze	
    ]//end button

nm!

I think I got it sorted out.

Here is the code I am now using if anyone else wants it

[ISubPalette, "Zplugin:Frame_mesh"]
  
  [ISlider,"Zplugin:Frame_mesh:Frame Value",0.9,.01,0.1,1.5
  ,"Set value for mesh fit",,,1]
  
  [IButton,"Zplugin:Frame_mesh:Frame Mesh",FitMesh,
  	[IFreeze,
  		[VarSet,fVal,[IGet,Zplugin:Frame_mesh:Frame Value]]
  		[IPress,Transform:Fit]
  		[TransformGet,xPos,yPos,zPos,
  					 xScale,yScale,zScale,xRotate,yRotate,zRotate]
  		[TransformSet,xPos,yPos,zPos,
  					 xScale*fVal,yScale*fVal,zScale*fVal,xRotate,yRotat  e,zRotate]
  	]//end freeze   
  ]//end button
  /*
   

THANKS AGAIN MARCUS!:+1:small_orange_diamond:+1:small_orange_diamond:+1:

That’s perfect Eric, I’m glad you got it sorted. :+1:

One further thing that could be added is a check for Edit mode. This would ensure that the resizing only occurred to a model, rather than 2.5D brush strokes. :wink:

Just wrap this code around the [IFreeze block:


[If,(([IsEnabled,Transform:Edit]) && ([IGet,Transform:Edit] != 0)),

//other code here

]//end if

Cheers,

Thanks again Marcus, you are such a huge help here on ZBC!

I played around with your two different code samples a bit on several of my tools and I found the first code sample to be a lot more stable. Even after I added the last bit of code you gave me.

I am not sure if it is something I am doing wrong or what, but the code sample with the slider appears to crash zbrush for me and also frame some of my models oddly when they are partially hidden.

Anyway, I tweaked the first code sample to scale out a bit more with a “1.2” value instead of “1.1” and it appears to be working great so far!

[IButton,Fit,"Fit mesh to view",
   [IFreeze,
   [VarSet,tmpZoom,[CanvasZoomGet]]
   [CanvasZoomSet,tmpZoom*1.2]
   [IPress,Transform:Fit]
   [CanvasZoomSet,tmpZoom]
   ]
   ]

I am extremely happy with this script! Big thanks to you Marcus!

Cheers!

Would it be possible to make such script to zoom in the zone under the cursor ?

That would make a perfect “scale detail mode”…