[Closed] Zlax: Relax along Z value only
Just thought I’d post this here. Had a question in the regular Max forum to see if I could relax along the Z only. Nothing in MAX allows this so I wrote this:
(
/*
Zlax
Relaxes verts only along the Z axis
2008 shannont@pbworld.com
*/
local theQuery = queryBox "This will convert your object into an editable poly.
ALL modifiers will be lost!
Do you still want to do this?"
if theQuery != false do
(
--functions
fn geomFilt o = (superClassOf o == GeometryClass)
--variables
local theMessage = "Select the object to relax"
local theSourceObject = pickObject message:theMessage prompt:theMessage filter:geomFilt
convertToPoly theSourceObject
--Copy our object to a new one
local theCopy = copy theSourceObject
local numberOfVerts = theCopy.numVerts
--set the relax settings
theCopy.relaxAmount = .25
theCopy.relaxIterations = 4
theCopy.relaxHoldOuterPoints = false
theCopy.relaxHoldBoundaryPoints = false
theCopy.EditablePoly.Relax selLevel:#Object
--Change the Z values for all the original verts based on the z value of the relaxed object
for i = 1 to numberOfVerts do
(
theOriginalVertPos = polyOp.getVert theSourceObject i
theNewVertPos = polyOp.getVert theCopy i
theZrealxedPos = [theOriginalVertPos.x,theOriginalVertPos.y,theNewVertPos.z]
polyOp.setVert theSourceObject i theZrealxedPos
)
delete theCopy
select theSourceObject
)
)
I hope it helps somebody somewhere!
Wow! Just amazing how your script idea is simple, yet, it works! Thanks for sharing it! I can already see upgraded versions of zlax relaxing in another directions!
Thanks! I’ll probably upgrade it sometime, but what I wrote fits my needs perfectly.
When I do, I’ll definitely do the combination (XY, XZ, Z, etc.) thing. Great idea!
You may want to change your first querybox since you are converting to poly, not mesh.
-Eric
Thanks simple and useful (bloody roads and terrains!)
here’s a small modification so that it works only on the selected verts, didn’t have a chance to add any of the ui bits
(
/*
Zlax
Relaxes verts only along the Z axis
2008 shannont@pbworld.com
adjusted to only work on selected verts by Dave Buchhofer dbuchhofer@gmail.com 01-2009
*/
--local theQuery = queryBox "This will convert your object into an editable poly.
ALL modifiers will be lost!
Do you still want to do this?"
--if theQuery != false do
(
--functions
fn geomFilt o = (superClassOf o == GeometryClass)
local theSourceObject = selection[1]
if (ClassOf theSourceObject == Editable_Poly) and (subobjectLevel == 1) and (theSourceObject.selectedVerts.count != 0) then
(
--Copy our object to a new one
local theCopy = copy theSourceObject
verts = theCopy.selectedVerts as bitarray
--set the relax settings
theCopy.relaxAmount = .25
theCopy.relaxIterations = 4
theCopy.relaxHoldOuterPoints = false
theCopy.relaxHoldBoundaryPoints = false
theCopy.EditablePoly.Relax selLevel:#Object
--Change the Z values for all the original verts based on the z value of the relaxed object
for v in verts do
(
theOriginalVertPos = polyOp.getVert theSourceObject v
theNewVertPos = polyOp.getVert theCopy v
theZrealxedPos = [theOriginalVertPos.x,theOriginalVertPos.y,theNewVertPos.z]
polyOp.setVert theSourceObject v theZrealxedPos
)
delete theCopy
select theSourceObject
subobjectLevel = 1
)else messagebox "Z relax currently only works on Collapsed Editable Poly objects
and requires a selection at the vertex level."
)
)
Maybe create a scripted modifier and allow the gizmo to define the direction…
Good plan! I’ve never made a scripted modifier. This one is perfect for it. Thanks for the suggestion. I’ll post it when I do it.