ZBrushCentral

Help With Profile Graphs in ZScripts?

Perhaps one of the ZScript experts can help me out. :slight_smile:

I was writing a randomized gear script, but ran into a roadblock with writing a routine for generating random profiles.

The main thing is, I can’t figure out how to specify that these points are to have sharp corners rather than smooth curves. Plus I’m not entirely sure of the proper formatting to script a profile curve.

As a result, my gears are looking more like flowers. :slight_smile: Which would be fine if I wanted a screen full of flowers. :smiley:

Here’s a code snippet:

[varSet,Y1,rand(100)]
[varSet,Y2,rand(100)]
[varSet,Y3,rand(100)]
[varSet,Y4,rand(100)]
[varSet,Y5,rand(100)]

[varSet,Y6,rand(100)]
[varSet,Y7,rand(100)]
[varSet,Y8,rand(100)]
[varSet,Y9,rand(100)]
[varSet,Y10,rand(100)]

// Specify the points in the profile.
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,0,Y1,0,Y1]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,25,Y2,25,Y2]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,50,Y3,50,Y3]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,75,Y4,75,Y4]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,100,Y5,100,Y5]

// Specify the points in the outer
// cross-section of the gear.
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,0,Y6,0,Y6]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,25,Y7,25,Y7]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,50,Y8,50,Y8]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,75,Y9,75,Y9]
[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,100,Y10,100,Y10]

Maybe someone out their would know a better way of scripting Profile Graphs? I couldn’t find anything about it in the Zscript commands reference.

Good question, WingedOne.

When working with ZGraphs by hand – to turn curve points into corner points, you drag them off the ZGraph and back on again.

In a ZScript context, you do the same thing. For example (from your ZScript, above):

[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,50,Y3,50,Y3] creates a curve point. To make it a corner point, add a point that’s not on the ZGraph, say, -20,-20. So it would read:

[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,50,Y3,-20,-20,50,Y3]

Have fun!
dave

Thanks Davey!

Another quick question:

Is there a way for a ZScript to get information about what points are currently in a Profile Graph and to remove them? Or just to remove all the points even without getting the information from the Profile Graph?

I’d have to say no. There’s no way to read the points from a ZGraph via ZScript.

Here are the other options you have:

You can reset all materials to their default state: [IReset,5]. That way you know where you’re starting from.

You can read points’ positions by hand; open the Transform:Info sub-palette, click on a point in a ZGraph, and the first two Info sliders will tell you the point’s position (let’s call 'em xx,yy). Then, in a ZScript, you can [IClick,xx,yy,new xx, new yy] to move it.

And hey – you didn’t ask, but here’s a tip on using [IReset…]: you know that dialog box that pops up when you do an [IReset]? You can suppress it by placing it inside an [IKeyPress…] command.

Here’s what an [IReset] looks like without giving the user an opportunity to confirm:

[IKeyPress,13,[IReset,5]]

This would of course reset all materials. Be careful, this’ll wipe out all customized materials without warning.

Have fun,
dave

Thanks Davey. :slight_smile: The information will come in handy. :+1: