custom zscript set pivot and zoom extents on object:need help

I am brand new to zscripting and really have no idea what I am doing, I am basically just hitting record and then reverse engineering it…

I am trying to make my own hotkey for this, I hate having to set my local pivot and then either hitting delete or ctrl + clicking on the canvas to make the model fill up the canvas I got pretty far, but the part that I cannot get past is the last step, I cant figure out how to keep the models rotation when I zoom in on it. I know that the code that sets the models rotation and position is in the last row, but there is just a garble of numbers that I have no idea what they are and I cant find info on it anywhere. Anyone have any thoughts? I wish I could figure out the command that zbrush runs when you hit the "delete" button. I think that might solve my problem [ISubPalette, "Zplugin:E"] [IButton, "Zplugin:E:Pivot_center","pivot_center", [IPress,Transform:Quick 3D Edit] [IPress,Transform:SetPvt] [CanvasStroke,(ZObjStrokeV03n2%p1CC7800p19BFD00PNN1NsC9840DsC9840DsC9840Dz4000=Yh-2193C1v-1FD5B7K4Xh-2193C1v-1FD5B7)] ,]

Curious. I was just about to post a similar script on CGTalk.

You nearly have it E. Recording a zscript and looking at the commands is one of the steps you can take to making your own script. However there will most likely be commands in the recording that you do not need so a understanding of the commands is neccesary. A little practice and you should be able to write a script without using a recording as the basis.

For example, the CanvasStroke command in your recording is not needed. It is mouse data from when you clicked and dragged on the canvas. Similarly the pressing of Quick 3D Edit is not needed for this function.

The following code is similar to your intended script except it sets the pivot point based on the current masking. If you examine the code I am sure you can remove the lines not needed for your script.

[ISubPalette, "ZPlugin:Misc Utilities"]

[IButton, "ZPlugin:Misc Utilities :Pivot by Mask","Sets the current Pivot Point to the masked areas and scales the geometry.",

[IShowActions, 0]
[Ipress, Tool:Masking:HidePT]
[IPress, Transform:SetPvt]
[Iclick, Transform:Move Edit]
[Iclick, Transform:Move Edit]
[Ipress, Tool:Masking:ShowPT]
[Ipress, Tool:Masking:Clear]

[IShowActions, 1]


BAM! thank you so much for helping me out! I knew it was much simpler than what I was doing

[ISubPalette, “Zplugin:E”]
[IButton, “Zplugin:E:Pivot_center”,“pivot_center”,
[Iclick, Transform:Move Edit]

I am very pleased with this script, now that it is assigned to a hotkey I use it constantly while modeling!

Shouldn’t that be

[IShowActions, -1]


Setting to a positive number turns Show Actions ON; a negative number restores the setting to that before the script was run.

I normaly I do use -1, I guess I am a little rusty with scripting :smiley:

Strangely the code works just fine.

Actually, I don’t bother with the second command at all. The [IShowActions,0] seems to work as a temporary switch. :slight_smile:

I looked up a message from God where he explains that [IShowActions, 1] is not necessary at the end of a script as ShowActions is reset when the script ends.

He explains other things in that message. Message from God.

Ah, all revealed. :slight_smile:

I just had a thought (which is unusual). Would it not be good practice to always match an [IShowActions, 0] with an [IShowActions, 1]? For a simple tutorial script you could leave it out but for utilities you should always pair them up. I am thinking of the Zscript recording where the ShowActions count might get shifted when the recording is played back. Projection Master uses [IShowActions,…] pairs, perhaps for zscript recording reasons?

Interesting point. There’d certainly be no harm in doing it and perhaps it should be regarded as ‘best practice’. But doesn’t the recording add in a [IShowActions,-1] whenever a plugin/zscript is exited, so in the end it wouldn’t make any difference, would it?

Hmm, you are right. The recording even filters out [IShowActions, 1] from the above script code.

Back to the dungeon I go.

TVeyes -

Great script. A studio was just asking for something like this!

Thanks! :+1: :+1: :+1:


could some one post the zscript with the button already made so i can just move the shortcut to my desktop thanks!

Sure, but there is not much to it. You simply save the source code in a text file (.txt) and place it in the /Zstartup/Zplugs directory. In ZBrush you then need to load the script once and after that it will load automatically each time you load ZBrush.

The file below is a compiled script and will load automatically when put in /ZStartup/Zplugs. The button will appear in the Zplugins > Misc Utilities subpalette.

Thanks Ryan, I might add some options tomorrow such as clear / keep mask and zoom / zoom distance.