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…
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]
[Ifreeze,
[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”,
[IPress,Transform:SetPvt]
[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!
TVeyes,
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
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.
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.
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!
r
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.