1. #1
    Senior Member Follow User Gallery
    Join Date
    Oct 2005
    Location
    USA
    Age
    35
    Posts
    1,066

    Default 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%p1CC7800p19BFD00PNN1 NsC9840DsC9840DsC9840Dz4000=Yh-2193C1v-1FD5B7K4Xh-2193C1v-1FD5B7)]
    ,]
    Last edited by --E--; 09-05-06 at 03:19 PM.

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

    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.

    [CODE][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]

    ,][/CODE]
    Mark

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Oct 2005
    Location
    USA
    Age
    35
    Posts
    1,066

    Default

    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!
    Last edited by --E--; 09-01-06 at 01:02 AM.

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    TVeyes,
    Shouldn't that be
    [CODE][IShowActions, -1][/CODE]
    ?

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

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

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

    Strangely the code works just fine.
    Mark

  6. #6
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Quote Originally Posted by TVeyes
    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.

  7. #7
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

    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.
    Mark

  8. #8
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Ah, all revealed.

  9. #9
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

    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?
    Mark

  10. #10
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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?

  11. #11
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

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

    Back to the dungeon I go.
    Mark

  12. #12

    Default

    TVeyes -

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

    Thanks!

    r
    UArtsy - the Online Art School

  13. #13
    Senior Member Follow User Gallery
    Join Date
    May 2005
    Posts
    737

    Default hey

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

  14. #14
    Senior Member Follow User Gallery
    Join Date
    Jul 2002
    Location
    Copenhagen
    Age
    45
    Posts
    2,561

    Default

    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.
    Attached Files Attached Files
    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •