Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modifying Morph Channels Of Same Names On Multiple Selected Objects

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
477 Views, 3 Replies

Modifying Morph Channels Of Same Names On Multiple Selected Objects

So the problem I'm encountering is that I have multiple objects in my scene with morpher modifiers on them, but I want to be able to easily modify all of the morpher channels using a progress bar floater. They all have varying numbers of active channels, but they have a consistent naming scheme across all of them.

 

For instance:

  • Object 1 has a morpher modifier with 4 active channels: Concave_Width, Kicks, Wheelbase_Lng, Wheelbae_Shrt
  • Object 2 has a morpher modifier with 6 active channels: Concave_Depth, Dips, Kicks, Arch, Wheelbase_Lng, Wheelbase_Shrt
  • Object 3 has a morpher modifier with 5 active channels: Concave_Depth, Dips, Arch, Wheelbase_Lng, Wheelbase_Shrt
  • etc

 

I came across this Autodesk document laying out a script that does almost exactly what I need, but it's limited to only a singular selected object.

 

I'm having trouble trying to figure out how to modify this script such that the floater is populated with all channel names (no duplicates) for every Kicks, Dips, etc named channels that exist in all selected objects with morph channels. Then I can easily modify their 0-100 values at the same time, rather than having to switch between every object every time I want to change a channel with the exact same name. This would ultimately save me a great deal of time.

 

I'm rather new to Max scripting so any help would be greatly appreciated, thank you!

3 REPLIES 3
Message 2 of 4
denisT.MaxDoctor
in reply to: Anonymous

the idea makes sense... but the way from Autodesk docs is not practical.

delete objects
gc()

ss = sphere name:#sphere_source pos:[0,0,50] radius:15 segments:18 wirecolor:brown
cs = cylinder name:#cylinder_source pos:[0,0,0] radius:10 sides:18 height:20 heightsegs:7 wirecolor:orange
st = sphere name:#sphere_target pos:[40,0,10] radius:10 segments:18 wirecolor:green
ct = cone name:#acone_target pos:[0,40,0] radius1:10 radius2:2 height:20 sides:18 heightsegs:7 wirecolor:yellow
xt = cone name:#zcone_target pos:[40,40,0] radius1:1 radius2:15 height:10 sides:18 heightsegs:7 wirecolor:blue


converttomesh objects

addmodifier ss (morpher())
addmodifier cs (morpher())

WM3_MC_BuildFromNode ss.morpher 1 st	
WM3_MC_BuildFromNode ss.morpher 2 ct	
WM3_MC_BuildFromNode ss.morpher 3 xt	
	
WM3_MC_BuildFromNode cs.morpher 3 st	
WM3_MC_BuildFromNode cs.morpher 2 ct	
WM3_MC_BuildFromNode cs.morpher 1 xt	
	
fn morpherSubAnimByTarget target =
(
	morphers = getclassinstances Morpher
	subs = #() 
	for m in morphers do
	(
		for k=1 to 100 where (WM3_MC_GetTarget m k) == target do append subs m[k]
	)
	subs
) 	

for t in #(st, ct, xt) do (morpherSubAnimByTarget t).controller = bezier_float()

 

this snippet shows now to find and bind all the same target channels for all morphers.

 

The next step is to how make UI. But it's the next story...

 

 

Message 3 of 4

I was going to say that it would be faster to instance controller "manually" vs scripting, but changed mind after your last line 👍

There is enough different (build-in) UI options for animations

Message 4 of 4


@domo.spaji wrote:

I was going to say that it would be faster to instance controller "manually" vs scripting, but changed mind after your last line 👍

There is enough different (build-in) UI options for animations


 

 

delete objects
gc()

mapped fn adjustSphere sp = 
(
	sp.objectoffsetrot = (rotateZmatrix 90)
	sp.objectoffsetscale = [-1,-1,-1]
	sp.objectoffsetpos = [0,0,sp.radius]	
)
mapped fn visibleAllEdges n = (meshop.autoEdge n #all 0)

ss = sphere name:#sphere_source pos:[0,0,40] radius:10 segments:18 wirecolor:brown smooth:off
cs = cylinder name:#cylinder_source pos:[0,0,0] radius:10 sides:18 height:20 heightsegs:5 capsegs:2 wirecolor:orange smooth:off
st = sphere name:#sphere_target pos:[40,0,0] radius:10 segments:18 wirecolor:green smooth:off
ct = cone name:#upcone_target pos:[40,0,40] radius1:10 radius2:0 height:20 sides:18 heightsegs:7 wirecolor:yellow smooth:off
xt = cone name:#downcone_target pos:[40,0,80] radius1:0 radius2:15 height:20 sides:18 heightsegs:7 wirecolor:blue smooth:off
zt = cylinder name:#cylinder_target pos:[40,0,-40] radius:10 sides:18 height:20 heightsegs:7 wirecolor:gray smooth:off

adjustSphere #(ss, st)
resetXform objects
converttomesh objects
visibleAllEdges objects 

addmodifier ss (morpher())
addmodifier cs (morpher())

WM3_MC_BuildFromNode ss.morpher 1 zt	
WM3_MC_BuildFromNode ss.morpher 2 ct	
WM3_MC_BuildFromNode ss.morpher 3 xt	
	
WM3_MC_BuildFromNode cs.morpher 3 st	
WM3_MC_BuildFromNode cs.morpher 2 ct	
WM3_MC_BuildFromNode cs.morpher 1 xt	
	
fn morpherSubAnimByTarget target =
(
	morphers = getclassinstances Morpher
	subs = #() 
	for m in morphers do
	(
		for k=1 to 100 where (WM3_MC_GetTarget m k) == target do append subs m[k]
	)
	subs
) 	

for t in #(st, ct, xt, zt) do (morpherSubAnimByTarget t).controller = bezier_float()



try(destroydialog BindMorphTargetsRol) catch()
rollout BindMorphTargetsRol "Bind Morph Targets" width:191
(
	label lb0 align:#center
	slider sp0 type:#float range:[0,100,0] scale:0.1 width:176 align:#left offset:[0,0] 

	label lb1 align:#center
	slider sp1 type:#float range:[0,100,0] scale:0.1 width:176 align:#left offset:[0,0]

	label lb2 align:#center
	slider sp2 type:#float range:[0,100,0] scale:0.1 width:176 align:#left offset:[0,0]

	label lb3 align:#center
	slider sp3 type:#float range:[0,100,0] scale:0.1 width:176 align:#left offset:[0,0]

	on BindMorphTargetsRol open do
	(
		targets = #(st, ct, xt, zt)
		for k=1 to targets.count do 
		(
			target = targets[k]
			aa = morpherSubAnimByTarget target
			lb = BindMorphTargetsRol.controls[2*(k-1) + 1]
			sp = BindMorphTargetsRol.controls[2*(k-1) + 2]
			lb.text = target.name
			sp.controller = aa[1]
		)
	)
)
_ts = BindMorphTargetsRol
createdialog BindMorphTargetsRol

 

 

 

here is more fun... 

 

 

But ... the question is how to make the UI dynamically in this case, where can there be any number of morph targets?
And this is the next story ...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report