Notifications
Clear all

[Closed] Max script request

Hello,

I’d like to ask for a script that converts dummy helpers to groups. You can see what I need from the following screenshots

Thanks
Zarko

14 Replies

looking at your final result i see that you don’t care about dummy001, 002, 003 animations. is it true?

so… the simplest script is:


 mapped fn makeGroupHead node = if isvalidnode node and node.children.count > 0 do 
 (
 	if not isgrouphead node and not isgroupmember node do
 	(
 		cc = join #() node
 		deleteitem cc 1
 		 
 		if isvalidnode (g = group cc name:node.name) do
 		(
 			g.parent = node.parent 
 			if node.isselected do selectmore g
 			delete node
 			g
 		)
 	)
 )
 /*
 makeGroupHead (selection as array)
 */
 

do i miss anything?

1 Reply
 em3
(@em3)
Joined: 11 months ago

Posts: 0

Not usually.

Yes, this is exactly what I needed. Also could this script be modified to have an option where the dummies can be converted into containers instead of groups?

Thank you for your help.
Zarko

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

here is more correct parent->grouphead and parent->container functions:

mapped fn parentToGroupHead node = if isvalidnode node and node.children.count > 0 do 
(
	if not isgrouphead node and not isgroupmember node do
	(
		cc = join #() node
		deleteitem cc 1
		
		parent = node.parent
		node.children.parent = undefined
		sel = node.isselected
		if isvalidnode (g = group #(node) name:node.name) do
		(
			g.parent = parent
			g.transform.controller = node.transform.controller
			attachnodestogroup cc g
			delete #(node)
			if sel do selectmore g
			g
		)
	)
)
mapped fn parentToContainer node = if isvalidnode node and node.children.count > 0 do 
(
	if not iskindof node Container do
	(
		cc = join #() node
		deleteitem cc 1
		 
		if isvalidnode (c = Container name:node.name parent:node.parent) do
		(
			c.transform.controller = node.transform.controller
			c.addnodestocontent cc
			if node.isselected do selectmore c
			delete node
			c
		)
	)
)

Hello,

The script runs well when the dummy helpers are not linked (parented), but when one dummy is a child of another the script doesn’t group the bottom child. I’ve made a short video clip that explains this problem.
https://docs.google.com/file/d/0B0V4AxfEEBovQ1lhNC12UjlLSVE/edit?usp=sharing

Maybe I’m using a wrong call for the functions?

Thanks

4 Replies
(@denist)
Joined: 11 months ago

Posts: 0

what script doesn’t work? to group? or to container?

(@denist)
Joined: 11 months ago

Posts: 0

it works if you process the nested dummies first… so to make it works the selection list (or any node collection) has to be sorted from descendants to ancestors…

(@denist)
Joined: 11 months ago

Posts: 0

actually it’s a good challenge for anyone who wants to practice in mxs…
write a function that sorts node list in order where every node stays before its ancestors.

(@zarko)
Joined: 11 months ago

Posts: 0

Yes you’re right. It works if the selection list is sorted but only for the parentToGroupHead function. The parentToContainer function doesn’t seem to work.

Zarko

I tried with this


 fn addBeforeAncestors obj = if objects.count != 0 do
 (
 	local o = (while obj.parent != undefined do obj = obj.parent)
 	local childsArr = #(o)
 	while o.children[1] != undefined do
 	(
 		insertitem o.children[1] childsArr 1
 		o = childArrs[1]
 	)
 	childArr
 )
 getAllChildren objects[1]
 

it works too.

1 Reply
(@zarko)
Joined: 11 months ago

Posts: 0

I seem to be at a loss. I don’t know how to call these functions… Could you please write how they should be run. Thanks.

I’d like to ask for a script that Can intake EVERY framestate Of an object And Pack them into EVERY percent of a Morph target’s channel. Making it so That The selected Morph channel’s “0-thru-100” is that PathDeform’s vine-like animation!, instaed of it being your average morph ]( .html)[/IMG] ]( .html)[/IMG] ]( .html)[/IMG]