Home Coding, Scripting, Shaders

Maxscript Save selected

Hi everyone, is it possible to run in 3ds max script Save selection?

Replies

  • Nels
    Here's the script, but it saves objects separately however I need to save a group of objects

    for obj in selection do 
      ( 
      tempPos = obj.position 
      obj.position = [0,0,0] 
      saveNodes obj ("c:/temp/" + obj.name + ".max") 
      obj.position = tempPos 
      ) 
  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    So you want to center all your selected objects to [0,0,0] , save them to a max file, and then set them back to their original position? If so, this should work:

    objSel = selection as array
    objPos = for obj in objSel collect (obj.position)
    for obj in objSel do (obj.position = [0,0,0])
    dirPath = "c:/temp/"
    if (doesFileExist dirPath == false) do (makeDir dirPath all:true)
    saveNodes objSel (dirPath + "objs.max")
    for i=1 to objSel.count do (objSel[i].position = objPos[i])
  • Nels
    Thanks a lot, it works!
    Is it possible to save each group separately, adding +1 to each next saved name?
  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    If you're using the group system in max; A group is basically just an invisible node that the objects are parented to, so get all the unique groups that're selected and perform one export for each which contains all their child objects. Something like this:


    origSel = selection as array
    allGroups = for obj in origSel collect (obj.parent)
    allGroups = makeuniquearray allGroups
    dirPath = "c:/temp/"
    if (doesFileExist dirPath == false) do (makeDir dirPath all:true)
    for grp in allGroups do (
        if grp != undefined do (
            objSel = grp.children
            objPos = #()
            for obj in objSel do (
                append objPos (obj.position)
                obj.position = [0,0,0]
            )
            saveNodes objSel (dirPath + grp.name + ".max")
            for i=1 to objSel.count do (objSel[i].position = objPos[i])
        )
    )
  • Nels
    It saves each object at 0 0 0 position, Is it possible to locate every group to 0 0 0 ?

  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    origSel = selection as array
    allGroups = for obj in origSel collect (obj.parent)
    allGroups = makeuniquearray allGroups
    dirPath = "c:/temp/"
    if (doesFileExist dirPath == false) do (makeDir dirPath all:true)
    for grp in allGroups do (
        if grp != undefined do (
            objSel = grp.children
            oldPos = grp.pos
            grp.pos = [0,0,0]
            saveNodes objSel (dirPath + grp.name + ".max")
            grp.pos = oldPos
        )
    )
  • Nels
    Perfect!
    Thanks a lot.
Sign In or Register to comment.