ScriptSpot home

Forum topic · General Scripting

Listing

By John Pester · 2013-04-10

Description

How would i

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

Thanks

Comments (7)
Branko Živković

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

Reply to Branko Živković
John Pester

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?

Reply to John Pester
Branko Živković

basic forum rule

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

Reply to Branko Živković
John Pester

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
)

Reply to John Pester
Branko Živković

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

John Pester

Cool

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???

Branko Živković

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