Reading the action commands sent to max and recompiling those set of actions as a script.

Hello All,

I have just finished a project with a happy ending and i want to librarize some models that i have created for future use on other projects and also share my workflow that i will use for the next decade (hopefully).

#1 - group the objects

 

#2 - rename the objects inside that group same as group's name

 

3# re-align pivots  considering the group as on objects.

 

4# move the grouped objects to "0" coordinates.

 

5# assign the grouped objects to a new layer

 

6# rename the layer , same as the group name.

 

7# save every layer to separated maxfiles. ("layers 2 files script from "tanya wiesner" works very wellin this case.)

 

8# launch a third party plugin to render the new max files, the program will render the preview and save the output named as the group's name.

so in total,

i will have a preview file

a max file

a group,a layer bunch bunch of objectsthat are named same as the max file.

"I had a plan"...

My initial idea was realying on the max script listener so any tool i used through the GUI, would be read from the listener. but it does not say anything usefull. so is here any other way around?

the first 6 steps are sufficient.

 

 

 

 

 

 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Did you test the new version

Did you test the new version in the top post?

titane357's picture

Thanks miauu for this well

Thanks miauu for this well explain example :-)

miauu's picture

You want someone to write a

You want someone to write a script that will do all 8 steps?

sergo's picture

Did you turn on Maxscript ->

Did you turn on Maxscript -> Macro Recorder? I believe most of your steps should have appeared in maxscript listener. You can't use that commands directly, but you'll have the clues to look up in maxscript help.

crystal3d's picture

well, they dont...:)

if i laucnh listener and start macro-recording, all i get is...

select #($Box001, $Box002)
actionMan.executeAction 0 "40140" -- Groups: Group
max group group
macros.run "Tools" "Move"
actionMan.executeAction 0 "310"

so without some scripting knowledge , i wont achieve to automate this thing.

miauu's picture

-- step b y step ( -- #1 -

--	step b y step
(
	--	#1 - group the objects
	grp = group selection select:true 
	--	#2 - rename the objects inside that group same as group's name
	for o in grp do o.name = grp.name
	--	3# re-align pivots  considering the group as on objects.
		--	i'm not sure what exactly you want, so...
	for o in grp do o.pivot = grp.pivot
	--	4# move the grouped objects to "0" coordinates.
	grp.pos = [0,0,0]
	--	6# create and rename the layer , same as the group name.
	grpLayer = layermanager.newLayerFromName grp.name
	--	5 assign the grouped objects to a new layer
	grpLayer.current = true	--	set layer as current layer
	for o in grp do (grpLayer.addNode o)	--	add objects in the group to the layer
	--	7# save every layer to separated maxfiles. ("layers 2 files script from "tanya wiesner" works very wellin this case.)
	saveNodes selection ((savePath as string)+grp.name+".max") quiet:true
)

With UI.

(
	global rol_crystal3d
	try(destroyDialog rol_crystal3d)catch()
	rollout rol_crystal3d ""
	(
		local savePath = undefined
		edittext et_savePath "Output path:" pos:[5,5] fieldwidth:220 labelontop:true readOnly:true
		button btn_getPath "Browse" pos:[230,22]
		button btn_Save "Save" width:100 align:#center 
 
		on btn_getPath pressed do
		(
			savePath = getSavePath caption:"Folder to save"
			et_savePath.text = savePath
		)
 
		on btn_Save pressed do
		(
			--	#1 - group the objects
			grp = group selection select:true 
 
			for o in grp do
			(
				o.name = grp.name 	--	#2 - rename the objects inside that group same as group's name
				o.pivot = grp.pivot 	--	3# re-align pivots  considering the group as on objects.
			)
			--	4# move the grouped objects to "0" coordinates.
			grp.pos = [0,0,0]
			--	6# create and rename the layer , same as the group name.
			grpLayer = layermanager.newLayerFromName grp.name
			--	5 assign the grouped objects to a new layer
			grpLayer.current = true	--	set layer as current layer
			for o in grp do (grpLayer.addNode o)	--	add objects in the group to the layer
			--	7# save every layer to separated maxfiles. ("layers 2 files script from "tanya wiesner" works very wellin this case.)
			saveNodes selection (savePath+"\\"+grp.name+".max") quiet:true
 
			--8# launch a third party plugin to render the new max files, the program will render the preview and save the output named as the group's name.
			--	instead of using third party plugin
			max select invert
			objToHide = selection as array
			max hide selection
			render renderhiddenobjects:false outputfile:(savePath+"\\"+grp.name+".png") vfb:false -- render grp
			for o in objToHide do o.isHidden = false		--	unhide other objects			
		)
	)
	createdialog rol_crystal3d width:300
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.