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
Old 08 August 2006   #1
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
 
Old 08 August 2006   #2
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
 
Old 08 August 2006   #3
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.
 
Old 08 August 2006   #4
thank you Jeff!!! It works perfect. I wish I was as smart as you .
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
Old 08 August 2006   #5
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
)
)
)
 
Old 08 August 2006   #6
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
 
Old 08 August 2006   #7
After obj.position = [0,0,0] in handiklap's example.




Light
 
Old 08 August 2006   #8
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
 
Old 08 August 2006   #9
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
 
Old 08 August 2006   #10
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.
 
Old 08 August 2006   #11
believe me I wouldn't ask if it's one time job.
__________________
:: www.lukx.com cgi
:: www.lukeszeflinski.com photography
 
Old 08 August 2006   #12
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.
 
Old 08 August 2006   #13
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
 
Old 08 August 2006   #14
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?
 
Old 08 August 2006   #15
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:00 AM.


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