1. #1
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Question Question: Tool Size and position for centralisation

    Yellu,

    it is a matter of...... size!

    I just recently got into Zscripting some things for myself because I am a lazy/efficient (however ya wanna see it ) artist that rather spend time on my art than manually do something that I repeatedly do while working... so I wrote a script! well, a few.
    and..... sillily enough didn't realise the enormous resource and expertise of this forum.

    I've now run into an issue that I cannot really get my head around. (two actually)

    the first one is... I have a startup script to run from the DefaultZScript, and I would potentially like to display an image in there, in the last note that I show.. but I've not found a way to do this. Is it possible?



    the second one is the one that I've been wrangling with the most.
    before I realised that there was a Zscripting forum and Roland had made a nice Axis script, I had made a turn around script for myself.


    I've managed to dynamically change the spacing depending on what document I am currently using, however, now I need to figure out a way to properly center the model and to scale it appropriately so that it doesn't overlap.
    I thought I had solved it, by using the turnaround points.... until I realised that it was working just because my models were all set up properly now...


    As you can notice in the gif above as well, the models all have different center points as well. I would ideally like it to all be on the same line.

    The only way I can think of it right now is to somehow get the information of the X/Y position, for each subtool, looping through to find min/max value of them each and try to use that information to set the transformation with...

    [TransformSet,,,, scaledToolWidth, scaledToolWidth, scaledToolWidth,,,]


    don't really want to mess about with merging, or actually scaling the tool itself, if possible.



    There's another issue I want to solve later on that comes with some models facing the other way.... but that's a laaaaater problem xD (I think Zbrush doesn't inherently save the rotation value as such for the models... so that will be a challenge)

    if anyone has a better idea, or tips or tricks, for any of it... I would gratefully appreciate to hear it!
    Last edited by Elithenia; 4 Weeks Ago at 06:03 AM. Reason: changed Title to be correct

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,284

    Default

    Hi,

    You can display an image in a note like this:

    [Note,"Text line",,5,,,,,,,,,,"image.psd"] //displays a note for 5 secs with an image


    You need all the commas so that the image file name is in the right place. Unfortunately many of the Note parameters are now defunct but you can read about them here:
    http://docs.pixologic.com/user-guide...eference/#Note

    For your second problem there are two ways (that I can think of) that you might go about this. You could do as you suggest and run through the subtools getting the sizes to calculate a bounding box. You'd then need to calculate the rotations so that you can determine the widths and spacing.

    The second way is to use the Transform:Fit function. This will fit the model into the available canvas. So what you could do is temporarily resize the canvas to an eighth of its width, run through the rotations fitting the model each time and recording the scale. Then use the minimum scale you record to place the model on the restored canvas.

    If I can find time in the next few days I'll put together a sample script for this last method so you can adapt to your needs.

    For rotation, there's no way for ZBrush to tell if your model is facing forwards when the rotation is at 0,0,0 - that's something only a human can decide!

    HTH,

  3. #3
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    Thank you Marcus for your reply!

    I will try the note image out once I'm back at the computer!

    I'll have a go with the canvas size as well. I didn't think about that.
    I need to have the canvas a certain width and zoom at the end, so it completely skipped my mind to play around with those.

    haha I meant with z-up vs y-up, but hm, as for the models facing the other way, I should be able to just set their current rotation (if the user places it how they want it) as 0,0,0 and then just increment from there no?
    Sanna
    Character Artist & Evolving TA

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

    Default

    Yes, if you ask the user to place the model upright and facing forward you can grab the values and adjust from there.

    A note on using Transform:Fit. It will be necessary to press the button twice and compare the values because one press of Transform:Fit frames the selected subtool and one frames the whole model.

  5. #5
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    Ooohhh I wasn't aware of that!
    I'll make sure to do that.

    I can just run the IPress command twice then for that, right?

    Silly question I guess. But what's the difference between IClick, IPress, and ISet coupled with values for example to get a certain lighting position.
    IClick works best, but the others only seem to work certain times...
    Sanna
    Character Artist & Evolving TA

  6. #6
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    So I managed to find a bit of time while travelling, so I tried my hand at the second way with the Transform:Fit ... and what I could think of to do.

    [IPress,Transform:Fit] // fit subtool to view
    [IPress,Transform:Fit] // fit tool to view
    [IClick,Transform:Scale] // click scale to get scale info
    [If, [IGet,Transform:Info:X Component] < maxSafeWidth,
    [VarSet,maxSafeWidth,[IGet,Transform:Info:X Component]]
    ,
    ]

    I stuck the above text into a routine that got called every rotation of the model in the new 1/8th sized document, and I've tried it with just about every iteration of scale and size I could find in the program, but I couldn't seem to get any usable information from anywhere that had any bearing on the actual scale of the model for it.

    even tried to set something like this up:

    [VarDef,turnPoint,0]
    [VarSet,turnPoint,(Document:Width / 8) // set turning point of model in turntable
    [VarDef,safeToolSize,0]
    [VarSet,safeToolSize,((Document:Width / 8) - ((Document:Width / 8)*0.25)]

    to use to set the initial size of the model up.
    while I got a change in the model size.. it still didn't really have any bearing on whether the model overlapped or not.

    If/when I get some time free next, I'll try to see what I can do with a bounding box.....
    Sanna
    Character Artist & Evolving TA

  7. #7
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,284

    Default

    You need to actually compare the scale values for the two Transform:Fit presses. There is no way to tell which is the right one otherwise. All eight rotations are then run through, and the minimum scale recorded.

    You can use TransformGet to get the values. I prefer using MTransformGet and MTransformSet as they are simpler when using a lot of different values.

    I've attached a sample script. This seems to work OK but it could probably do with some fine tuning to adjust the scale and position for a more pleasing result. There's no error checking for things like does the user actually have a model loaded.

    Any questions, let me know.

    PlaceModel.txt

  8. #8
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    oh Gosh!
    Thank you so much for that!

    I will go through it and fine tune it when I've figured out what you've written

    What is the difference in using the MTransformGet vs the TransformGet then as you prefer it?
    is it the same while using mem blocks? I thought that was mostly for using that if you wanted to retain the info/variables persistant through a session?
    Sanna
    Character Artist & Evolving TA

  9. #9
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,284

    Default

    In this instance, the memblock is just quicker to write. It's a lot quicker to adjust the offset value (using variable "i") than deal with 90 different variables (or even a list variable of 90 different values) and plug them into [TransformGet] and [TransformSet]. Also, there used to be a size limitation with TransformGet but I've not tested it for a while.

  10. #10
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    Haha yes, looking through your script right now, it is so neat compared to what I was thinking of (with lots of variables)!
    I can definitely see the benefit of using mem blocks!
    Sanna
    Character Artist & Evolving TA

  11. #11
    New Member Follow User Gallery
    Join Date
    Jul 2014
    Location
    United Kingdom
    Posts
    8

    Default

    @marcus

    I've run through your script a few times and it works wonders on 4r7, however, whenever I run it on 4r8/2018 (modifications or your original file) it doesn't seem to scale it properly anymore.
    I cannot figure out why it starts to give me overlap in the newer versions, but not in the old one, unless there's been some change in the way it is handling certain things?
    Sanna
    Character Artist & Evolving TA

  12. #12
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,284

    Default

    It was written for ZBrush 2018 - I've not tested on earlier versions. There's no particular reason why performance should vary though, providing the [IConfig] is set for the correct version. You may need to check the Transform values (e.g. using Notes) to see what is happening.

    It is only a "proof of concept" script though, and you will need to consider a couple of things when refining the script:

    1. The Transform:Fit command fits to the available canvas. This will vary depending on the screen space for your set up and the amount of document zoom. Also, there is a tendency for models to be scaled a little too large using this command, so you might need to adjust for that.

    2. Some assessment of the shape of the model may be necessary. For example, models that are tall and thin may not work so well.

    HTH,

Posting Permissions

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