help with script for saving objects in different maxfiles.

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  08 August 2006
help with script for saving objects in different maxfiles.

Let's say I have 10 objects (grouped gemotery example: car, bike, aeroplane). Now I want to write a script which will save each grouped objects in separate files. Also it would be nice if this script reset position of group to 0,0,0. Can someone help me with this?
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
I know I can save selected with this command:

saveNodes $ "C:\Documents and Settings\pt\Desktop\Untitled.max"

but how to make maxscript to split all selected groups into different files.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
Try something like:
for obj in selection do
  (
  	isOpen = false
	if isOpenGroupHead obj then
  	(
  		isOpen = true
  		setGroupOpen obj false
  	)
  	
  	if isGroupHead obj then
  	(
  		tempPos = obj.position
  		obj.position = [0,0,0]
  		saveNodes obj.children ("c:/temp/" + obj.name + ".max")
  		obj.position = tempPos
  		if isOpen == true then
  		(
  			setGroupOpen obj true
  		)
  	)
  )


This should take all groups (open or not) in the current selection and save them each, centered at 0,0,0 in their own file, and then return them to their previous position and state (open or closed).

Last edited by handiklap : 08 August 2006 at 01:58 PM.
 
  08 August 2006
thank you Jeff!!! It works perfect. I wish I was as smart as you .
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
i have a smaller version but is not fool proof


select $*
for obj in selection do
(
if (classof obj.baseobject) == dummy then
(
if obj.children.count != 0 then
(
save_file = "C:\\" +obj.name +".max"
move $ [0,0,0]
saveNodes obj.children save_file
)
)
)
 
  08 August 2006
thank you guys again. I don't want to push my luck, but is there anyway to save the file with zoom extents all selected? I mean that when using tbumbnail view I can see group I saved. I know I should use this command:

actionMan.executeAction 0 "311"

but where to put it?
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
After obj.position = [0,0,0] in handiklap's example.




Light
 
  08 August 2006
thanks Light but it doesn't work. In thumbnail I can see the position I had when running the script.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
I just noticed, It's not working like it should. In my gropus I have dummy object. And when using script it's only saving dyummy object not the geometry.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
Is this something you need to do often? otherwise if there are only about ten objects in your scene, you could have probably done it by now by hand.
 
  08 August 2006
believe me I wouldn't ask if it's one time job.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
select $*
for obj in selection do
(
if (classof obj.baseobject) == dummy then
(
if obj.children.count != 0 then
(
save_file = "C:\\" +obj.name +".max"
obj.position = [0,0,0]
max zoomext sel
saveNodes obj.children save_file
)
)
)


well, i;ve tested this with a dummy in the group and it seems to work fine.
 
  08 August 2006
Thank you Richard. But now script is splitting everything apart. I looks like if I have more than one dummy assigne to an object it's creating files for each dummy.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
  08 August 2006
select $*

for obj in selection do
(
if (classof obj.baseobject) == dummy then
(
if isGroupHead obj == true then
(
save_file = "C:\\" +obj.name +".max"
obj.position = [0,0,0]
max zoomext sel
saveNodes obj.children save_file
)
)
)

if this doesnt work, i give up! What version of max have you got?
 
  08 August 2006
still it save only dummy. I'm working with max 8. I think I will have to remove dummies in the future and will use your first script. Thank you again Richard.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
Thread Closed 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 11:13 AM.


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