[SOLVED] Saving all the Objects or Groups in Scene to separate MAX files

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
  1 Week Ago
[SOLVED] Saving all the Objects or Groups in Scene to separate MAX files

Hello Everyone,

I'm trying to use a script to export all my Objects and my Groups in a Scene to separate MAX files. So far, the script works great on Objects, however, for Groups, it saves a blank file with the GroupName, and saves each Group Member to a separate file. How can I fix it ?


dir="c:\\temp\\" -- the target directory
typ=".max"  -- change this to the filetype you want

select(for o in geometry where isGroupHead o or classOf o != VRayProxy or classOf o != VRayPlane collect o)
sel=selection as array

for s in sel do
(
  f=dir+s.name+typ
  if typ==".max" then
  (
   saveNodes s f quiet:true
  ) else
  (
  select s
   exportfile f selectedOnly:true --#noprompt
  )
)

Last edited by unsuns : 1 Week Ago at 10:02 AM.
 
  1 Week Ago
if you want to save node collection in new max file you don't have to select them...
all that you need is collect groups (head and members) and save every collection with new file.
the most complicated part of the process is to do collections with or without nested groups. but it's up to yours needs
 
  1 Week Ago
If I don't select them nothing happens.
 
  1 Week Ago
Originally Posted by unsuns: If I don't select them nothing happens.
you have to collect a group nodes.


fn getGroupMembers node = if isgrouphead node do (join #() node)
for node in objects where isgrouphead node do
(
   members = getGroupMembers node
   savenodes members (@"c:\temp\" + node.name + ".max")
)
 
  1 Week Ago
Alright, so what would be the full script including the 2 conditions ? Thank you for your help Denis !
 
  1 Week Ago
Originally Posted by unsuns: Alright, so what would be the full script including the 2 conditions ? Thank you for your help Denis !
it depends on what you want to do with VRay nodes. they already might be in some group. or they might not...

i don't have VRay in my system and don't remember about this type of nodes. but if they are simply parents of another nodes and not included in any group, or should be saved in a file anyway:

for node in objects where isgrouphead node or iskindof node VRayProxy or iskindof node VRayPlane do
(
 nodes = join #() node
 savenodes nodes (@"c:\temp\" + node.name + ".max")
)
 
  1 Week Ago
Regarding VrayProxy and VrayPlane, In fact I don't mind if they're in a group of not, I just want to exclude them if they are present in the scene as single objects because it would be useless to save them to single files anyway... Otherwise it's no big deal, I can delete them manually afterwards.

I'm only interested in keeping VrayFur because it's tied to an object.

To make myself clear, the two conditions are :
- If there's a Single object, then save it in a separate file.
- If there's a Group, then save the whole Group to a separate file.

I'd like to be able to process an entire scene this way.

Please give me the full script, I'm really a newbie and I'd be so grateful to you...
 
  1 Week Ago
Please give me the full script, I'm really a newbie and I'd be so grateful to you...

for node in objects where not isgroupmember node and (isgrouphead node or iskindof node VRayProxy or iskindof node VRayPlane) do
(
 nodes = if isgrouphead node then (join #() node) else #(node)
 savenodes nodes (@"c:\temp\" + node.name + ".max")
)


no matter how this script works for you, I advise you to look into the mxs help to understand what this code is doing
 
  1 Week Ago
Now it's working for Groups, but not for single objects.

You can forget about the VrayProxy and VrayPlane exceptions, they're not working anyway (I don't want them to be saved to separate files).
 
  1 Week Ago
Anyone else could help please ?
 
  1 Week Ago



-- save single nodes ::::

fn isSingleNode node = (node.parent == undefined and node.children.count == 0)


for node in objects where not iskindof node VRayProxy and not iskindof node VRayPlane and isSingleNode node do
(
  savenodes #(node) (@"c:\temp\" + node.name + ".max")
)


-- save groups (root heads) ::::

for node in objects where isgrouphead node and node.parent == undefined do
(
   savenodes (join #() node) (@"c:\temp\" + node.name + ".max")
   join saved_nodes nodes
)
 
  1 Week Ago
Thank you Denis, actually this is the cleanest and the fastest way that works on both Single Objects and Groups, however the exceptions don't seem to work, I'd also like to exclude Lights and Cameras as well if possible.


for node in objects where not isgroupmember node or isgrouphead node do
(
 nodes = if isgrouphead node then (join #() node) else #(node)
 savenodes nodes (@"c:\temp\" +node.name+ ".max")
)
 
  1 Week Ago
Originally Posted by unsuns06: Thank you Denis, actually this is the cleanest and the fastest way that works on both Single Objects and Groups, however the exceptions don't seem to work, I'd also like to exclude Lights and Cameras as well if possible.
one hour of my work costs $250 , it would be cheaper for you to open the mxs help and learn a little. I did every piece for you, you only need to assemble them correctly
 
  1 Week Ago
You're right, I'll dig into it. Thank you a lot Denis, you've been of great help !

Edit : Here is the full code including all the conditions. So basically the script saves all the Geometry(ONLY) Single Objects and Groups to separate Max Files, if it could be helpful for anyone .


for node in objects where superclassof node ==Geometryclass and not superclassof node ==Camera and not classof node ==Targetobject and not iskindof node VRayPlane and not iskindof node VRayProxy and (node.parent == undefined and node.children.count == 0) and not isgroupmember node or isgrouphead node do
(
 nodes = if isgrouphead node then (join #() node) else #(node)
 savenodes nodes (@"c:\temp\" + node.name + ".max")
)

Last edited by unsuns : 1 Week Ago at 09:58 AM. Reason: Added full code
 
  6 Days Ago
Originally Posted by denisT: one hour of my work costs $250 , it would be cheaper for you to open the mxs help and learn a little. I did every piece for you, you only need to assemble them correctly
We greatly appreciate the time you've taken to share your knowledge with us.
__________________
http://3dcutout.com/
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:10 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.