Announcement

Collapse
No announcement yet.

relax on z axis. script help?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • relax on z axis. script help?

    would be very useful for sorting out my really bumpy roads .. however the script i found is ancient and gives an error in max 2018.. (its from 2009)


    its here:

    https://forums.cgsociety.org/t/zlax-...only/1246777/7

    if anyone with some scripting skill wanted to try updating this to work in newer max versions, id be a very happy boy.

    one of those features (relaxing in a specific direction only) which ive never thought of before.. and now it seems indespensible

  • #2
    Hi,

    it works in 2020 there is just some line breaks that needs to be fixed.

    (
    /*

    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,theNewVe rtPos.z]
    polyOp.setVert theSourceObject v theZrealxedPos
    )

    delete theCopy
    select theSourceObject
    subobjectLevel = 1
    )else messagebox "Z relax currently only works on Collapsed Editable Poly objectsand requires a selection at the vertex level."
    )
    )
    www.suurland.com
    www.cg-source.com
    www.hdri-locations.com

    Comment


    • #3
      with formatting https://paste.ofcode.org/BBe9CLzxBaKydKFPjK9b3S
      www.suurland.com
      www.cg-source.com
      www.hdri-locations.com

      Comment


      • #4
        that worked lovely.. many thanks for the help

        Comment

        Working...
        X