Notifications
Clear all

[Closed] Batch exporting object to separate .X files

Hi,

I’m new to maxscript and trying to trying to create a batch .x file exporter in Maxscript that exports the selected objects via kwXport to their own .x file. I’ve tried two approaches:

  1. saveNodes (looks like it works but can’t specify the exporter and the files aren’t legitimate .x files, I believe they’re just .max files renamed)

(
 for obj in selection do 
( 
tmpPos = obj.position 
obj.position = [0,0,0] 
saveNodes obj ( "C:\\" + obj.name + ".x") quiet:true
obj.position = tmpPos
 )
 )
  1. exportFile (half works, exports a working .x file for each item through KwXport, however each file contains all the objects selected rather just the object the file is named after)

(
 for obj in selection do 
( 
tmpPos = obj.position 
obj.position = [0,0,0] 
exportFile ("C:\\" + obj.name + ".x") #noPrompt selectedOnly:true using:kwXport
obj.position = tmpPos
 )
 )

If anyone could give me a nudge in the right direction I would be very thankful

Cheers
Aaron

5 Replies

I could be wrong since I’m new to maxscript as well. But to me it seems you still have all of those objects selected when you export, and there for it exports all of the object.

So I’d try saving the selection as variable and then deselecting everything. Then looping trough the variable and exporting 1 object at time.

 eek

Don’t you need to select each object in the selection?


(
local arr = selection as array

for each in arr do
(
select each
tmpPos = each.position 
each.position = [0,0,0] 
exportFile ("C:\\" + each.name + ".x") #noPrompt selectedOnly:true using:kwXport
each.position = tmpPos

)

)

Cheers eek!

That did the trick, I’ve been racking my brain as to what it needed, I knew I was missing something to discern one object from another but wasn’t sure what – part of trying to learn the ropes I guess…

Thanks again
Aaron

If you’re using this on grouped objects as well you might need to check that they are in a group first and if they are, export them all at one time.

Just a headsup for odd MAX Group functionality

Good shout MoonDoggie, hadn’t thought of that, I don’t believe objects are grouped but ill prob add that in just incase