batch export script error help

batch export script error help

remainz
Advocate Advocate
856 Views
2 Replies
Message 1 of 3

batch export script error help

remainz
Advocate
Advocate

HI

 

Im trying to export many objects to STL format. Max does not have a way to batch export to this format or include the object name on export making errors inevitable.

 

I have found a script here but I think somthing has changed and it no longer works.

http://forums.autodesk.com/t5/programming/stl-batch-export-script-help/td-p/4080787

 

I recieve error "references only allowed on variable,properties and array indexes"

in line exportFile etc

 

I have no idea what this error means or how to go about fixing it. 

Is the error in the code or the max version or is it me?

 

thanks a lot for any hlpe

 

Joe Remainz

 

macroScript Export_Selected_2_STL category:"ScrewyScripts" tooltip:"Export selected to .STL"

(
global STL_Object_Name = ""

fn SetSTLExportOptions = 
    (
    local BM_GETSTATE = 0xF2
    local BM_CLICK = 0xF5
    local BM_SETCHECK = 0xF1
    local BST_CHECKED = 0x1
        
    WindowHandle = DialogMonitorOPS.GetWindowHandle()
    if ((UIAccessor.GetWindowText WindowHandle) == "Export STL File") then
        (
        children = UIAccessor.GetChildWindows WindowHandle
        for i = 1 to children.count do
            (
            child = children
            childTitle = (UIAccessor.GetWindowText child)
            if (childTitle == "Object01") then
                UIAccessor.SetWindowText child STL_Object_Name
            if (childTitle == "Selected only") then
                (
                cbState = windows.sendMessage child BM_GETSTATE 0 0
                checked = bit.get cbState BST_CHECKED
                if (checked == false) then
                    (
                    windows.sendMessage child BM_CLICK 0 0
                    windows.sendMessage child BM_SETCHECK 1 0                        
                    )
                )
            )
        uiAccessor.sendMessageID WindowHandle #IDOK    
        )
    true
    )

DialogMonitorOPS.unRegisterNotification id:#Set_STL_Export_Options
DialogMonitorOPS.RegisterNotification SetSTLExportOptions id:#Set_STL_Export_Options
DialogMonitorOPS.Enabled = true
    
selected = for obj in selection collect obj
for obj in selected do
    (
    STL_Object_Name = obj.name
    select obj
    exportFile ((getDir #export) + "/" + STL_Object_Name + ".stl")
    )
    
DialogMonitorOPS.Enabled = false
DialogMonitorOPS.unRegisterNotification id:#Set_STL_Export_Options
)

 

 

 

0 Likes
857 Views
2 Replies
Replies (2)
Message 2 of 3

Steve_Curley
Mentor
Mentor
Man that's an old thread - I'd forgotten about that. The problem is the way the forum is displaying it - this is a completely different forum system to the one in use back in 2009 - obviously the conversion from one to the other wasn't exactly 100% perfect 😉

The problem line should read:-
exportFile ((getDir #export) + "/" + STL_Object_Name + ".stl") 
If you go back to that thread, scroll down a bit (Message 8) there's another version of it attached to that reply - the filename is weird but it's just a normal zip file. I just d/l it and extracted it fine, so that's another option rather that relying on the on-screen text.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 3

remainz
Advocate
Advocate

thanks curley steve

your the man

0 Likes