1. #1
    Member Follow User Gallery
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    30

    Default Question: How do I put the Active Points of a subtool in a variable?

    I'm trying to access the Active Point count of the currently selected subtool. I'd also like to access the Total Point count for the tool. How do I do this? Seems like an easy thing to do but I'm obviously missing something

    I tried this with no luck ...

    [VarSet,pointCount,[Preferences:Misc:ActivePoints]]

    I also tried using these commands in various ways with no luck.
    Mesh3DGet
    IGetSecondary
    IGet

    I suspect Mesh3DGet is my best chance. In my code below, when I use Mesh3DGet it returns 0 indicating that the command executed successfully. But it doesn't tell me the actual Point count so I'm not sure what it's actually doing. I'm unclear on how to actually access the Active Points and put it in a variable. The Command Reference says [Mesh3DGet,0] will return the number of vertices. Here's one of the things I've tried ... (am I barking up the wrong tree?)

    [CODE]
    //Create button[IButton,"test","test",
    [IFreeze,
    [IShowActions,0]


    //Select top subtool
    [IPress,Tool:Subtool:Subtool 0]


    //put subtool Active Points in a variable
    [VarDef,pointCount,0]
    [VarSet,pointCount,[Mesh3DGet,0]]


    //show point count
    [Note,pointCount,,5]

    ]//end freeze
    [IShowActions,-1]
    ]//end button
    [/CODE]

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

    Default

    You need to put a variable inside the Mesh3DGet command to receive the value:
    [CODE]
    [VarDef,pointsCount,0]

    [Mesh3DGet,0,,,pointsCount]
    [Note,pointsCount][/CODE]

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Aug 2011
    Location
    Mebane, NC
    Posts
    4,194

    Default

    This has possibilities. Please holler if you get it working and wanna share.

  4. #4
    Member Follow User Gallery
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    30

    Default

    Sure I don't mind sharing.

    So marcus_civis explained how to put the Active Points in a variable:

    [VarDef,pointCount,0]
    [Mesh3DGet,0,,,pointCount]

    Here's how I used it:

    MY "IDEAL" SETUP
    I wanted to automate Decimation Master and 3D Print Exporter down to 1 button click. I work with a team of 6 guys. We're constantly sending models off for 3d prints. So I thought I'd streamline the decimation and export process.

    Here is what I wanted (there is one big reason this won't work, explained later):
    1. Pre-Process All subtools through Decimation Master
    2. Cycle through every subtool, check the active point count. If the point count is over 75k then decimate it down to 75k. Otherwise, leave it alone and go to the next subtool. Repeat the process
    3. Export subtools using 3D Print Exporter found in zbrush

    The reason this won't work is, as soon as my code clicks the Pre-Process All button in Decimation Master, my script exits because Decimation Master is a plugin that calls it's own scripts. So as soon as the Decimation Master script starts my scripts ends. I really wish this wasn't the case. It would be very useful since I can't access the code for Decimation Master.

    [CODE]//<<WARNING: THIS WON'T WORK BECAUSE AS SOON AS A BUTTON FROM ANOTHER PLUGIN IS CALLED MY SCRIPT EXITS//Create button
    [IButton,"Decimate All to 75k","Decimate All subtools to 75k",
    // [IFreeze,
    // [IShowActions,0]


    //Variables
    [VarDef,totalSubtools,0]
    [VarDef,pointCount,0]


    //put total number of subtools in a variable
    [VarSet,totalSubTools,[SubToolGetCount]]

    //Decimation Master Pre-Process All subtools
    // [IPress,ZpluginecimationMaster:Pre-process All]
    // This script stops working at this point!!!
    //Scroll to bottom of subtool menu
    [ISet,Tool:SubTool:Subtool Scrollbar,0,0]
    //Select top subtool
    [IPress,Tool:Subtool:Subtool 0]

    [Loop,#totalSubtools,

    //put Subtool Point Count in a variable
    [Mesh3DGet,0,,,pointCount]

    //reduce active point count down to 75,000
    [If,(pointCount < 75000),
    //than
    [ISet,Zpluginecimation Master:% of decimation,100]
    ,//else
    [VarDiv,pointCount,75000]
    [ISet,Zpluginecimation Master:% of decimation,pointCount]
    ]//end IF

    //Decimate current subtool
    [IPress,ZpluginecimationMasterecimateCurrent]


    //select next subtool above
    [IPress,Tool:Subtool:SelectUp]

    ]//end LOOP

    // ]//end freeze
    // [IShowActions,-1]

    ,,1//button size
    ]//end button[/CODE]


    MY "REALITY BITES" SETUP
    I still found a way for this to be semi useful. Here are the steps:
    1. I click Pre-Process All in Decimation Master.
    2. I select a subtool
    3. Run my script ... subtool is decimated to 75k.
    4. I select next subtool
    5. run my script, etc
    6. The 3d Print Exporter process can't be streamlined, so I export everything manually.

    Not ideal but at least it speeds up the process a little.

    Here is what I ended up with:
    [CODE]
    //Create button
    [IButton,"Decimate to 75k","Decimate selected subtool to 75k (You need to run a Pre-Process first)",
    [IFreeze,
    [IShowActions,0]


    //put Subtool Point Count in a variable
    [Mesh3DGet,0,,,pointCount]


    //reduce active point count down to 75,000
    [If,(pointCount < 75000),
    //than
    [ISet,Zpluginecimation Master:% of decimation,99.99]
    ,//else
    [VarSet,percent,[Val,75000 / pointCount]]
    [VarSet,percent,[Val,percent * 100]]
    [ISet,Zpluginecimation Master:% of decimation,percent]
    ]//end IF


    //Decimate current subtool
    [IPress,ZpluginecimationMasterecimateCurrent]

    ]//end freeze
    [IShowActions,-1]


    ,,1//button size
    ]//end button
    [/CODE]

    QUESTION

    Concerning 4R5 ...

    All of the plugins now have this listed under them in the ZBrush Plugins Download Center: *This plugin is included with a default installation of ZBrush 4R5. See here: http://www.pixologic.com/zbrush/downloadcenter/zplugins/

    Does this mean the plugins are now integrated into zbrush? Or do they still reside under the Plugin menu?

    I'd prefer them to actually be truly integrated into zbrush so I can call them in my own scripts.
    Last edited by ijacobs; 02-21-13 at 02:22 PM.

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

    Default

    The plugins are essentially the same but are provided as part of the ZBrush installer rather than as a download.

  6. #6
    Member Follow User Gallery
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    30

    Default

    Any chance these will be truly integrated into ZBrush in the future? Rather than plugins.

  7. #7
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Question

    Hey guys

    Since Mesh3DGet returns only the subtools' point count, do you have any suggestions on how to get to Total Points count as shown in Preferences:Misc:Total Points Count ?
    If I try with [IGet,Preferences:Misc:Total Points Count] it returns 0 both on Total and Active...

    Thanks in advance

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

    Default

    Hi,

    You can parse the info string (the text in the pop-up when you have the cursor over the large "Current Tool" thumbnail) like this:

    [IButton,GetPoints,"Get the total number of points",
    [VarSet,totalPoints,0]
    [If,[SubToolGetCount]>1,
    [VarSet,InfoStr,[IGetInfo,Tool:Current Tool]]
    [Loop,6,//find sixth '='
    [VarSet,offset,[StrFind,"=",InfoStr]]
    [VarSet,InfoStr,[StrExtract,InfoStr,offset+1,256]]
    ]
    [VarSet,offset,[StrFind,[StrFromAsc,10],InfoStr]] //find line break
    [VarSet,InfoStr,[StrExtract,InfoStr,0,offset-1]]
    [VarSet,totalPoints,InfoStr]
    ,//else only one subtool
    [Mesh3DGet,0,,,totalPoints]
    ]
    [Note,totalPoints]
    ]


    This looks for the relevant '=' in the string, and then gets the appropriate substring. By using the '=' it should work whatever language ZBrush is set to.

    Note that this doesn't check for ZSpheres or Primitives etc. which will return an error or not work!

  9. #9
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Thumbs up

    Ah, Marcus, thanks!!! This works great.

    I managed to print out in a note something like "10.33 Mil" using StrMerge, but I failed at putting it inside a disabled button like the Total Points Count one. Any suggestions?

    I tried putting the name of a variable in an IButton name, but to no luck...

    [IButton,GetPoints,"Get the total number of points",
    [VarSet,totalPoints,0]
    [If,[SubToolGetCount]>1,
    [VarSet,InfoStr,[IGetInfo,Tool:Current Tool]]
    [Loop,6,//find sixth '='
    [VarSet,offset,[StrFind,"=",InfoStr]]
    [VarSet,InfoStr,[StrExtract,InfoStr,offset+1,256]]
    ]
    [VarSet,offset,[StrFind,[StrFromAsc,10],InfoStr]] //find line break
    [VarSet,InfoStr,[StrExtract,InfoStr,0,offset-1]]
    [VarSet,totalPoints,InfoStr]
    ,//else only one subtool
    [Mesh3DGet,0,,,totalPoints]
    ]

    [VarSet,totalmils, [StrExtract,totalPoints,0,1]]
    [VarSet,totalthous, [StrExtract,totalPoints,2,3]]
    [VarSet,Merged,[StrMerge, totalmils,".",totalthous," Mil"]]
    ]

    [IButton,[StrMerge, totalmils,".",totalthous," Mil"],"Total Points Count",
    ,1,1]

    When I try it this way it puts the two new variable names inside the button, not their values.

    I'm sorry for shooting one question at a time, but I wasn't sure if I can formulate all of my thoughts in one single post

    Thanks again for your time!
    Colendro.

  10. #10
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Default P.s.

    I'm going at this the wrong way...

    I realized that the StrMerge will give me wrong numbers when the amount of digits is less or more in the Current Tool.

    I guess my real question is how do I properly get the numbers to print out with the decimals and abbreviated with "Mil" when needed?

    Cheers.

  11. #11
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Default

    Hi, Marcus

    Very sorry to bother you again, but do have an idea how I can properly get the numbers to print out with the decimals and abbreviated with "Mil" when needed?

    Thanks,
    Colendro

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

    Default

    Hi colendro,

    Sorry, I've been really busy. You can do it like this:

    [If,totalPoints>1000000,
    [VarSet,milPts,INT(totalPoints/1000000)]
    [VarSet,milFract,FRAC(totalPoints/1000000)]
    [VarSet,milFract,[StrExtract,milFract,2,4]]//3 places
    [VarSet,pointsStr,[StrMerge,milPts,".",milFract]]
    [Note,pointsStr]
    ]


    In answer to your previous question, I'm afraid it's not practical to update a button name with the points count. The zscript needs to be reloaded every time and this would lead to problems.

    HTH,

  13. #13
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Default

    Hi Marcus,

    "In answer to your previous question, I'm afraid it's not practical to update a button name with the points count. The zscript needs to be reloaded every time and this would lead to problems. "

    So it turns out that it is not OK if I try to make an exact copy of the Misc:Total Points Count button in my plug-in, right?

    If this is true, and I need to show the total points in the plug-in for pure informational purposes, how should I proceed?

    Many Thanks again for your time!!!

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

    Default

    The simplest method would be to show the points count in a Note that pops up when the user presses a button (or at some relevant time during your plugin operation).

    There are two problems with trying to duplicate the points count button:

    1. Renaming a plugin button during a ZBrush session is tricky involving "closing" the button and then reloading the plugin. This can lead to ZBrush becoming unstable.

    However, it occurred to me that you could probably use the dropdown (similar to the Text Edit plugin font picker but with just one entry) that is possible using the ZFileUtils here:
    http://docs.pixologic.com/user-guide...ng/zfileutils/

    But that still leaves this second problem:

    2. It's not possible for a plugin to monitor what ZBrush is doing, so your points count display won't update automatically. In other words, you'd need a "Refresh" button or some other method to allow the user to see the correct points count value in your plugin. So you might as well just use the Note as I suggest at the top of the post.

    HTH,

  15. #15
    New Member Follow User Gallery
    Join Date
    Jun 2018
    Location
    Bulgaria
    Posts
    6

    Default

    As always, your help is greatly appreciated. Many thanks, Marcus!

    Colendro.

Posting Permissions

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