Aller au contenu

Photo

Max programming with NWN modifiers


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Shadooow

Shadooow
  • Members
  • 4 470 messages

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?


  • OldTimeRadio aime ceci

#2
Michael DarkAngel

Michael DarkAngel
  • Members
  • 370 messages

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



#3
Shadooow

Shadooow
  • Members
  • 4 470 messages
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



#4
Michael DarkAngel

Michael DarkAngel
  • Members
  • 370 messages
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


  • OldTimeRadio aime ceci

#5
Shadooow

Shadooow
  • Members
  • 4 470 messages

this appears to work without any issue, tyvm MDA!


  • Michael DarkAngel aime ceci