Author Topic: Max programming with NWN modifiers  (Read 338 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Max programming with NWN modifiers
« on: March 08, 2014, 03:56:45 am »


               

I created a MAXScript to automatizate the process Ive been doing manually for 5hours already and the script works. Problem is it erases the AuroraTrimesh modifier on the update.


 


How can I avoid that?



               
               

               
            

Legacy_Michael DarkAngel

  • Hero Member
  • *****
  • Posts: 627
  • Karma: +0/-0
Max programming with NWN modifiers
« Reply #1 on: March 08, 2014, 05:53:36 am »


               

If you want to post your script somewhere I can take a look at it and see if I can figure something out for you.


 


[EDIT]After thinking about it.  Sounds like whatever your script is doing is collapsing the the stack.  What you could do is copy any modifiers at the beginning of your script and the re-apply the copied modifiers at the end of your script.


 


icon_zdevil.gif


 MDA



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Max programming with NWN modifiers
« Reply #2 on: March 08, 2014, 06:32:45 am »


               

for obj in selection do --loop through all objects selected
(
 if canConvertTo obj Mesh then --has Editable Mesh modifier
 (
 convertToMesh obj --collapse to EditableMesh
  for v = 1 to getNumVerts obj do --loop through all vertices
  (
  vert = getVert obj v --get the v-th vertex
  vert.z = vert.z+20;
  setVert obj v vert --assign back to the v-thvertex
  )
 update obj --update the mesh
 )
)

the code is from the MAXScript reference with minor modifications, but tried googling already and didnt found other way to do this neither how could I save modifiers and restore after this operation



               
               

               
            

Legacy_Michael DarkAngel

  • Hero Member
  • *****
  • Posts: 627
  • Karma: +0/-0
Max programming with NWN modifiers
« Reply #3 on: March 08, 2014, 06:58:57 am »


               

for obj in selection do  --  loop through all objects selected
(
  if canConvertTo obj Mesh then  --  has Editable Mesh modifier
  (
    --
    --  Copy node
    --
    local copy_of_meshnode = copy obj
    local modifier_count = (obj.modifiers).count
 
    convertToMesh obj  --  collapse to EditableMesh
 
    for v = 1 to getNumVerts obj do  --  loop through all vertices
    (
      vert = getVert obj v  --  get the v-th vertex
      vert.z = vert.z + 20
      setVert obj v vert  --  assign back to the v-thvertex
    )
 
    update obj  --  update the mesh
 
    --
    --  Copy modifiers from node copy to original collapsed node
    --
    if (modifier_count != 0) then
    (
      for i = modifier_count to 1 by -1 do
      (
        addmodifier obj copy_of_meshnode.modifiers[i]
      )
    )
 
    --
    --  Delete the copy
    --
    delete copy_of_meshnode
  )
)

Try that.


 


icon_zdevil.gif


 MDA


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Max programming with NWN modifiers
« Reply #4 on: March 08, 2014, 07:09:33 am »


               

this appears to work without any issue, tyvm MDA!