ZBrushCentral

making one slider a function of a custom scripted slider

sooooo, without boring everyone with too many details, I’m trying to make a script (hopefully a plugin) that will offset a surface by a specific amount and I’m not very good with scripting yet. I know I could use Extract or Panel loops, but for the specific thing I’m trying to do those aren’t working. So what does work is the Inflate deformer. I have found that inflating to 100 offsets a surface by 0.125 units. What I would like to do is create a custom slider such that I can set it to exactly the distance I want and then the inflate deformer gets set to the right number to give me that offset. So if I set my custom slider to .25 units of offset, it would run inflate the right number of times (and/or the right amount) to give me that offset (in this case, 2 rounds of 100)

Anybody that can help me figure this out? :slight_smile:

Record your actions and then save the script. Open it with something like Notepad and see what you have. There are docs posted on scripting.

Hi Ryan,

You can do something like this:

[ISlider,“Apply Inflate”,0,0.1,0,5
,“Inflate by distance”,

[VarSet,repeatNo,INT([IGet,0]/0.25)]
[VarSet,fraction,FRAC([IGet,0]/0.25)]
[Loop,repeatNo,
[ISet,Tool: Deformation:Inflate,100]
]
[ISet,Tool:Deformation:Inflate,(fraction*100)]

,1]

In the code above, [Get,0] is shorthand for “get the value of this interface item”, i.e. the slider. Using [IGet,“zscript:Apply Inflate”] would work just as well. The “zscript:Apply Inflate” is the path form for a zscript loaded through the ZScript:Load button and appearing in the ZScript Window at the bottom of the UI. For a plugin, the path would be something like “Zplugin:My Plugin:Apply Inflate”.

(The code above will deal only with positive slider values but it would be straightforward to make it work with negative values too. You’d need to test for values less than 0, use -100 when appropriate in the loop and make sure the Loop repeatNo was positive.)

HTH,

thanks Marcus! Finally got around to plugging this bit of code into my script and it worked like a charm :smiley: