ScriptSpot

Forum topic · General Scripting

Listing

By Shade926 · 2013-04-10

Description

How would i

Export a list of all of the objects in a scene?

Thanks

Comments (7)

barigazy · 2013-04-11

First line of code is just for example. Will create five box in the row with distance of 30 units.
U can use your list of objects. Select objects in the scene and run this line:


--store your selection in array
listOfObj = selection as array

Last line is function for exporting.
For that function you need defined path where object will be exported (exportpath)
Then you need export class (in this case "ObjExp") and selectedonly argument must be on ei. true. If not then yoyu will be export whole scene

Shade926 · 2013-04-11

Ive put in my export path but when i export it to the chose place it doesn't show up there..

Does it export as a list?

basic forum rule

barigazy · 2013-04-11

You need to post some code or snapshot or even test file first.

Shade926 · 2013-04-11

Ye sorry thought i had done..

My code looks like this

button exportobjects "Export Selected Objects"
on exportobjects pressed do
(
listOfObj = selection as array
exportpath = @"C:\Users\Michael\Documents\3dsMax\export"
select listOfObj
exportFile exportpath using:ObjExp selectedonly:on
)

barigazy · 2013-04-11

Probably UAC block exporting. If you have windows8 than this is common problem.
Also you need error check


if selection.count == 0 then messageBox "Select objects!" else
(
    local exportpath = @"C:\Users\Michael\Documents\3dsMax\export"
    exportFile exportpath using:ObjExp selectedonly:on
)

More elegant solution you can find here http://www.scriptspot.com/3ds-max/scripts/batch-exportimport

Cool

Shade926 · 2013-04-11

Hello

Thanks for that... Could you explain what the first bit of code does and what the final line does..

Cant get my head round it???

barigazy · 2013-04-10

first run this in listener to see all export classes that max suports

for i in exporterPlugin.classes do print i

You will get then en array.
Let say that you want to export to *.obj list of objects.

-- this is my list of boxes
listOfObj = for i = 1 to 5 collect (Box pos:[0,i*30,0])
exportpath = @"c:\temp"
--now if you want to expor only selection (not whole scene) then
select listOfObj
exportFile exportpath using:ObjExp selectedonly:on