Recreate Set Value & Flatten in Lscript?


New member
Hi guys, what are the Set Value & Flatten on normal axis commands in Lscript?

I'm trying to automate my LW workflow & want to run those commands without the interactive panels showing up.



Active member
You probably have to create the code for those steps. Not by calling the commands themselves I would guess.


New member
It would be nice to have something like LScript Commander for modeler so you can capture the internal commands as you use them.

The Mirror tool also has an interactive panel, but they created 3 Lscripts ", &" to bypass the panel, maybe they could do the same here. Hint..hint...LW3Dgroup


New member
I read the reference manual & User Guide & came up with this for "set value" replacement...must be the world's simplest Lscript :p

How on earth do I even start trying to tackle the flatten tool on normal axis.....Matt, are you out there :)

// LScript Modeler template

@version 2.2
@script modeler

// edit only selected components. 





Active member
For flatten to normal... take your polygon selection, and average the normal. This gets you the normal you need.

Once you have the normal, you can use the equation of a plane (Ax + By + Cz + D = 0, or P dot3d N + D = 0) to figure out which way the points need to move to flatten out, D being the distance along the normal vector. Move all your points in your selection, and there you go... (You do this by plugging in the values of your vertices and taking the dot product; This yields the distance along the normal vector the point needs to move ( P += (D * N) )

As options, you could give the user the choice of first selected poly normal, average poly normal, or last selected poly normal to flatten to.

Flatten to X, Y and Z would work the same way; get the average value for that axis, and then set all the points to the new value.
//Code to average coordinate values goes here...
newvalue = center(boundingbox());
   foreach(p, points){
      tmp = pointinfo(p);
      if(mode = X_COORD) tmp.x = newvalue.x;
      if(mode = Y_COORD) tmp.y = newvalue.y;
      if(mode = Z_COORD) tmp.z = newvalue.z;
Last edited:


New member
Thanks Kryslin, but that's way over my head :)

I got it working by using quadro app to send keyboard keys to modeler


Active member
Kuzey : Flatten to X, Y, or Z is fairly simple, as far as lscripts go. And knowing a bit about vector math is kind of necessary in doing some pretty cool things, like move all the selected points to the same plane. Likewise, set value is roughly the same script, except instead of generating a value from the selection, you get the value from the user. I find lscript easier to work with than Python, because I'm more familiar with C / C# syntax...
Top Bottom