Notifications
Clear all

[Closed] Problem with wiring custom attribute

Hello,
I have a little problem with automatic parameter wiring position constraint weights to a custom attribute. Every solution I could think of has failed. So maybe some maxscript god around here has a solution.

What I want to realize is a IK/FK interpolation on a long stretchy bone chain. So I created a FK chain, an IK chain and a stretchy chain as blend target. Writing a function that snaps the FK bone chain to the IK bone chain was no problem either. Now the point helpers of the stretchy chain need to be position constraint to the bones of the FK and IK chain. Position constraint to the IK chain was done manually before I discovered the time saving aspect of maxscript. Now I’m trying to add the FK chain bones as second targets to the existing position constraints of the point helpers and wiring all the weights to a custom attribute that drives the blend between the FK and IK chain on all bones.

This is, what I have so far:


hlpName = "hlp_";
bName = "bone_";
for i = 1 to 50 do
(
	--get objects
	hlpObject = execute ("$'" + hlpName + i as string + "'");
	bObject = execute ("$'" + bName + i as string + "'");
	
	--add set weight of existing position target to 100 and add new target with weight 0
	hlpObject.position.controller[2].setWeight 1 100;
	hlpObject.position.controller[2].appendTarget bObject 0;
	
	--add animation controllers on the weights
	--hlpObject.position.controller[2][#Position_Weight_0] = bezier_float();
	--hlpObject.position.controller[2][#Position_Weight_1] = bezier_float();
	
	--wire custom attribute to weights
	paramWire.connect $ctrl_Test.modifiers[#Attribute_Holder].Custom_Attributes[#FKSnap] hlpObject.position.controller[2].Position_Weight_0 "100-FKSnap";
	paramWire.connect $ctrl_Test.modifiers[#Attribute_Holder].Custom_Attributes[#FKSnap] hlpObject.position.controller[2].Position_Weight_1 "FKSnap";
)

The problem is, that the “paramWire.connect” call throws a “connect requires subAnims” error. In the track view I discovered that there were indeed no controllers on the weights. So I tried to add some with maxscript. Trying to add bezier float controllers (what is possible manually in the track view) via script however throws a “No ““put”” function for SubAnim:Position_Constraint” error. So how can I get this to work?

Greetings

DeFi

5 Replies
 S-S

Defi.
I did’t read your post that well, but i guess your problem is just that you are not using subanims. It just means that you access for example controllers like you would array or such:

paramWire.connect $Teapot01.modifiers[#Attribute_Holder].Custom_Attributes[1] $Box01.position.controller[2][1] “100-Param1”

  • This will connect teapots modifier 1 custom attribute “param1” to position constraints Position weight 0

I just replaced “.Custom_Attributes[#Param1]” which i made with “.Custom_Attributes[1]”

Which does same as previous, but for some reason parameter wires need it in subanim format.

  • Hope this helps.

@S_S1: Perfect! Using this hint, everything works fine now.
Thank you very much!

Sorry for double posting, but I’ve ran into the next strange problem.
Now I want to dynamically wire some rotations with ascending weights from 0.5 to 1.0, but for some reason, the following code wires everything to “X_Rotation * 1.0” instead to the correct values. At first I thought there was some referencing error(evaluating w to true = 1.0), but printing str to the listener shows the correct string values of eg. “X_Rotation * 0.55”. Passing the manual value of “X_Rotation * 0.55” to paramwire.connect works, but every time I use a dynamically calculated number it is converted to 1.0 when wired. Composing the string str using the append function had no effect on the result either. Any idea what may have gone wrong?


bName = "b_";
for i = 44 to 54 do
(
	w = (0.5 + (i - 44) * 0.05) as string;
	str = "X_Rotation * " + w;
	print str;
	paramWire.connect $ctrl_test.rotation.controller[1] bObject.rotation.controller[2][1] str;
)

[EDIT]
Just found a workaround(make the expression pseudo-static using execute), but knowing the reason for the false interpretation of the string would be nice anyhow.


bName = "b_";
for i = 44 to 54 do
(
	w = (0.5 + (i - 44) * 0.05) as string;
	str = "\"X_Rotation * " + w + "\"";
	print str;
	execute ("paramWire.connect $ctrl_test.rotation.controller[1] bObject.rotation.controller[2][1] " + str as string);

)

 eek

(a-1)*0.5 + 0.5 *b – will give us a linear interpolation between t[0,1] of a,b i.e a value between a and b based on 0 and 1.

Now for an interpolation of non 0 1 values, we take our value from our minimum so for example:

(0.75 – 0.5) = 0.25

and our minimum value from our maximum: (1.0-0.5) = 0.5 Now all we do is divide the first by this:

0.25 / 0.5 = 0.5

So we’ve in a way projected our standard interpolation into a new ‘set’ of base values:

(t – min) /(max-min)

‘t’ being your value between the (max,min) values.

Hello, eek. First of all I feel honored to get an answer from an animation master like you. (Half of my problems with rigging are solved instantly, because of the tons of useful stuff you and PEN keep dropping everywhere in the rigging forum. Thanks! )

But now I’m a little confused, because my problem wasn’t really about calculating the interpolation values. Sure, I didn’t use the reference way of realizing a linear interpolation, but the values I calculated were exactly what I needed. Maybe my description of the problem was bad, so I try again.

The problem was about why wiring the string value of eg. “X_Rotation * 0.55”, that was composed of a string and a dynamic float didn’t work as expected. In my case it’s contained in the variable str and prints perfectly as “X_Rotation * 0.55” to the console but after executing the script everything is wired to “X_Rotation * 1.0” instead. Even adding random stuff like

str = “X_Rotation * ” + w + ” + 0.12345”;

still leads to a wiring of “X_Rotation * 1.0 + 0.12345” where the float part contained in w somehow gets interpreted as “1.0” when passed to paramWire.connect but not when passed to print. And since I don’t really like the execute workaround I’m curious about the reason for this.