Home Coding, Scripting, Shaders

MaxScript - continue script after export

Hello everyone,
Does anyone know if it is possible to continue the same script after the export is done?

I have a simple script that deletes unselected objects, clans empty layers, and then exports selected objects but I would really like it if I could undo all of that after the export is done and not have to do it manually.

Replies

  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    undo on (
        your code goes here
    )
    max undo
  • Zvezdan
    Options
    Offline / Send Message
    Thank you for the answer, but I still can't figure it out because the last operation in my script is export and after that, it just finishes. Does it matter that export is the last command?
  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    No, the export function should simply return true/false whether it was cancelled or not and then continue on with the script (in this case it would then close out the undo and run max undo).
    If you're able to post the script I can take a look to see what's stopping it.
  • Zvezdan
    Options
    Offline / Send Message
    I am retarded xD wrote max undo after wrong ")"

    Here is the script:

    (   
        undo on (
           
        if selection.count != 0 do
            (
                macros.run "Modifier Stack" "Convert_to_Poly"
                objects.ishidden = off
                actionMan.executeAction 0 "283"  -- Tools: Unfreeze All
                for obj in selection do (
                    local layer = layerManager.getLayer 0
                    for obj in selection do layer.addNode obj
                    actionMan.executeAction 0 "40044"  -- Selection: Select Invert
                    actionMan.executeAction 0 "40020"  -- Edit: Delete Objects
                    macros.run "Scene Explorer" "SERemoveEmptyLayers"
                    select $*
                    actionMan.executeAction 0 "40373"  -- File: Export Selected
                    exit
                )
            )
        )
        max undo
    )

    I am sure that it is probably super stupid for someone who actually knows how to code.

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    without trying it myself


    does that exit command need to be there? 
  • Zvezdan
    Options
    Offline / Send Message
    If I don't put exit and I have selected multiple objects then when one export is finished it starts another one for every selected object. It is certainly not the best script, but I don't know better for now :D
Sign In or Register to comment.