Notifications
Clear all

[Closed] CA parameter block question

Oh boy, i hope i can explain this right.
Basically i’m working on a custom spine script that allows you to specify a scale factor for each bone in the spine (something similar to what Jason Schleifer did on his Rigging DVD). My Idea was to create X sliders for each bones scale factor.

in the CA_def i have something like this…


 numberOfBones = 5
 while numberOfBones > 1 do 
 (
   numberOfBones -=1
   Txt += "slider" +((numberOfBones) as string) +" type:#float ui:(SliderSl" +((numberOfBones) as string)+ ") default:0 animatable:true 
"
 )
 

…wich gives me in this case 5 sliders, named “slider1, slider2…” and so on.

Now i want to add each slider to a different script controller as target. The problem is, i have no idea how to address these sliders. Depending on the number of bones that was specified, the number of slider are variable.

this code obviously dont work…


 numberOfBones=5
 for i = 1 to numberOfBones do
 (
  ...
  ...
  Node.modifiers[[#Attribute_Holder]].Ca_def.([u][b]Slider+i[/b][/u]).controller = bezier_float()
  ScriptController.AddTarget "VariableName" node.modifiers[#Attribute_Holder].CA_def.([u][b]Slider+i[/b][/u]).controller 
  ...
  ...  
 )
 

…but i hope you get the picture. I m looking for a way to apply sliderX as target.

9 Replies
 lo1

 Node.modifiers[[#Attribute_Holder]].Ca_def.[("Slider" + i as string)].controller = bezier_float()
 

I tried (“slider”+i as string) before, but without square brackets.
But even with square brackets i get a syntax error.

 lo1

If SliderX is a subanim of CaDef it should work. Please post your CA code…


sc1 = SpineSeg.value+1
			sc2 = SpineSeg.value+1
			(
				Txt = "def=attributes Spine_def
"
				Txt += "(
"
				Txt += "	parameters SpineParams rollout:SpineScaleR 
"
				Txt += "	(
"
				while sc1 > 1 do 
				(
					sc1 -=1
					Txt += "		Vertebra" +((sc1) as string) +" type:#float ui:(VertebraSp" +((sc1) as string)+ ", VertebraSl" +((sc1) as string)+ ") default:0 animatable:true 
"
				)
				
				Txt += "	)
"
				Txt += "	rollout SpineScaleR \"Spine Scale Factor\"
"
				Txt += "	(
"
				
				while sc2 > 1 do 
				(	
					sc2 -=1
					Txt += "		spinner VertebraSp"+((sc2) as string) +"\"Vertebra "+((sc2) as string) +":	  \" range:[-1,1,0] offset:[0,00]
"
					Txt += "		slider VertebraSl"+((sc2) as string) +" range:[-1,1,0] ticks:0
"
				)
				Txt += "	)
"
				Txt += ")
"
				Txt += "custAttributes.add Ct_IK_Hip.modifiers[1] def
"
			)
			code = txt as stringstream
			execute code	

 lo1

works fine for me


for i = 1 to 4 do print $.spine_def[("vertebra" + i as string)].controller

Though if that’s your entire attribute this will work just as well:


for i = 1 to 4 do print $.spine_def[i].controller

where i is a relevant value depending on how many controls you have per verterbra

hm, i tried both, but i get a
“MAXScript Rollout Handler Exception: – Unknown property: “Spine_def” “

 lo1

Then what makes you think the problem is with accessing the slider? It’s obviously in accessing the custom attribute definition entirely.

I’m guessing there’s not really an #Attribute_Holder modifier on the object or it doesn’t really contain the CA

but there’s definitely a attributeHolder with a CA on it.


spine_ca = custAttributes.getDef $.modifiers[1].Spine_def

confirms that.

stay tuned lo, i ‘m gonna check something…

ok, this code works. wich is odd because i just copied it out of the original code.
at least i know how to access the attributes, thx lo.


 obj = teapot  radius:2.0
addmodifier obj (EmptyModifier ())
select obj
Seg = 5
sc1=Seg+1
sc2 =Seg+1
(
	Txt = "def=attributes Spine_def
"
	Txt += "(
"
	Txt += "	parameters SpineParams rollout:SpineScaleR 
"
	Txt += "	(
"
	while sc1 > 1 do 
	(
		sc1 -=1
		Txt += "		Vertebra" +((sc1) as string) +" type:#float ui:(VertebraSp" +((sc1) as string)+ ", VertebraSl" +((sc1) as string)+ ") default:0 animatable:true 
"
	)
	
	Txt += "	)
"
	Txt += "	rollout SpineScaleR \"Spine Scale Factor\"
"
	Txt += "	(
"
	
	while sc2 > 1 do 
	(	
		sc2 -=1
		Txt += "		spinner VertebraSp"+((sc2) as string) +"\"Vertebra "+((sc2) as string) +":	  \" range:[-1,1,0] offset:[0,00]
"
		Txt += "		slider VertebraSl"+((sc2) as string) +" range:[-1,1,0] ticks:0
"
	)
	Txt += "	)
"
	Txt += ")
"
	Txt += "custAttributes.add $.modifiers[1] def
"
)
code = txt as stringstream
execute code

for i = 1 to 4 do print $.modifiers[1].spine_def[("vertebra" + i as string)]