Custom Attribute Controllers

Custom Attribute Controllers

dgood158
Participant Participant
1,473 Views
7 Replies
Message 1 of 8

Custom Attribute Controllers

dgood158
Participant
Participant

Hello,

 

I'm trying to find out how an ex-coworker achieved this set up for Custom Attributes of an dummy block. Currently there is a Custom Attribute Rollout created that makes the initial Pitch, Roll, Heave, etc. However, I'm having trouble getting the sub-animations (see picture). The main points are "Float_Wire" attached to another object and the sub-animations are "Bezier_Float" with all the keys represented. I don't know how they achieved this but was told they did it by scripts. If there are any ideas I'm willing to try and see if it works out. Thank you in advance.

 

 Custom_AttributesCustom_Attributes

0 Likes
1,474 Views
7 Replies
Replies (7)
Message 2 of 8

denisT.MaxDoctor
Advisor
Advisor

Do you want us to guess from the picture what types of controllers are used?
obviously they are connected by wire. But the type is difficult to guess. The float type suggests itself for yaw, pitch and roll, but if we look at the picture, then something else is used..
so look in the file and please let us know.
to wire subanims by mxs is not a problem when you know what to wire.

 

.. and if you put a link to the file, it will be quite simple

 

Message 3 of 8

denisT.MaxDoctor
Advisor
Advisor

more likely it's done something like:

delete objects

d = dummy name:#attribute_holder pos:[0,0,50]

b0 = point name:#p0 box:on pos:[-30,0,0] wirecolor:red
b1 = point name:#p0 box:on pos:[0,0,0] wirecolor:green
b2 = point name:#p0 box:on pos:[30,0,0] wirecolor:blue
	
ypr_attr = attributes attr  attribID:#(0x1967, 0xa121de52)
(
	parameters params rollout:params
	(
		yaw type:#float ui:yaw_sp 
		pitch type:#float ui:pitch_sp 
		roll type:#float ui:roll_sp 		
	)
	rollout params "CA: YPR Rotation"
	(
		spinner yaw_sp "Yaw: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]		
		spinner pitch_sp "Pitch: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
		spinner roll_sp "Roll: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
	)
)

ca = createinstance pry_attr
append d.baseobject.custattributes ca
--custattributes.add d attr
paramWire.connect2way d.baseObject.attr[#yaw] b0.pos.controller[#Z_Position] "Z_Position" "yaw"
paramWire.connect2way d.baseObject.attr[#pitch] b1.pos.controller[#Z_Position] "Z_Position" "pitch"
paramWire.connect2way d.baseObject.attr[#roll] b2.pos.controller[#Z_Position] "Z_Position" "roll"

 

but two-way connection doesn't make sense for me in case of using with a CA. It should definitely be a one-way connection.

 

 

Message 4 of 8

dgood158
Participant
Participant

@denisT.MaxDoctor 

Sorry I didn't get an email about your post, otherwise I would have gotten back sooner. I have attached a file with the associated objects with the connections. I have tried to see what the connection types were for the "pitch/roll/yaw" controllers. When I right click nothing shows up for the controller (none on the list are selected). All I could see is that it was a wire_float. The sub animations are all bezier_floats. I do appreciate the help and I apologies for the lack of information, hopefully the attached file helps. I saw the script that you added to the forum I'm going to give it a shot and see if it works. In the attached file, the "VehicleMotion_001" is the dummy block with the custom attributes. Thanks!

0 Likes
Message 5 of 8

dgood158
Participant
Participant

@denisT.MaxDoctor 

 

I tried your script, that did do what I wanted, which was create the sub animation for each of the motions "Yaw Animation/Pitch Animation/Roll Animation" to each of them. I'm trying to figure out in your script how that was achieved? Is that achieved after the paramWire.connect2way? I'm trying to understand how it is created so I know what to add to my current script. That is the only part that I can find that is different form what I currently have.  Thanks for the help!

global controlnode

controlnode = $

custAttributes.delete controlnode 1 -- remove existing custom attributes for replacement

custAttributes.add controlnode VehMotAtt

VehMotAtt=attributes Custom_Attributes 
(
	parameters Main rollout:Custom_Attributes
	(
		Pitch Type:#float UI: Pitch Default: 0.0
		Roll Type:#float UI: Roll Default: 0.0
		Heave Type:#float UI: Heave Default: 0.0
		Yaw Type:#float UI: Yaw Default: 0.0
		Transport Type:#float UI: Transport Default: 0.0
	)

	rollout Custom_Attributes "Custom_Attributes" 
	(
		spinner Pitch "Pitch:"
		spinner Roll "Roll:"
		spinner Heave "Heave:"
		spinner Yaw "Yaw:"
		spinner Transport "Transport:"
	)
)

custAttributes.add controlnode VehMotAtt

 

0 Likes
Message 6 of 8

denisT.MaxDoctor
Advisor
Advisor

I looked at your file... the how it was made (but a more correct way): 

delete objects

d = dummy name:#attribute_holder pos:[0,0,50] boxsize:[100,1000,100]

t = point name:#source pos:[0,0,-80] size:50 box:on axistripod:on wirecolor:orange
c = t.rotation.controller = rotation_list()
r = c.available.controller = euler_xyz()
c.setname 2 "YPR Rotation"
c.setactive 2

attr = attributes attr  attribID:#(0x1967, 0xa121de52)
(
	parameters params rollout:params
	(
		yaw type:#float ui:yaw_sp 
		pitch type:#float ui:pitch_sp 
		roll type:#float ui:roll_sp 
	)
	rollout params "CA: YPR Rotation"
	(
		spinner yaw_sp "Yaw: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,4]		
		spinner pitch_sp "Pitch: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
		spinner roll_sp "Roll: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
	)
)

ca = createinstance attr
append d.baseobject.custattributes ca

paramWire.connect ca[#yaw] 		r[3] "degtorad yaw"
paramWire.connect ca[#pitch]	r[1] "degtorad pitch"
paramWire.connect ca[#roll] 	r[2] "degtorad roll"

ezc = bezier_float()
addEaseCurve r ezc

select d

 

but it's not the best solution. 

the better is:

delete objects

d = dummy name:#attribute_holder pos:[0,0,50] boxsize:[100,100,100]

t = point name:#source pos:[0,0,-80] size:50 box:on axistripod:on wirecolor:orange
c = t.rotation.controller = rotation_list()
s = c.available.controller = rotation_script()
c.setname 2 "YPR Rotation"
c.setactive 2


attr = attributes attr  attribID:#(0x1967, 0xa121de52)
(
	parameters params rollout:params
	(
		yaw type:#float ui:yaw_sp 
		pitch type:#float ui:pitch_sp 
		roll type:#float ui:roll_sp 
	)
	rollout params "CA: YPR Rotation"
	(
		spinner yaw_sp "Yaw: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,4]		
		spinner pitch_sp "Pitch: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
		spinner roll_sp "Roll: " type:#float range:[-1e9, 1e9, 0] fieldwidth:64 align:#right offset:[4,0]
	)
)

ca = createinstance attr
append d.baseobject.custattributes ca

s.addtarget "yaw" d.baseObject.attr[#yaw]
s.addtarget "pitch" d.baseObject.attr[#pitch]
s.addtarget "roll" d.baseObject.attr[#roll]
s.setexpression "rotateYPRMatrix yaw pitch roll"

ezc = bezier_float()
addEaseCurve s ezc

select d

 

because Euler_XYZ (example #1) is not the same as Yaw-Pitch-Roll Rotation(example #2).

 

0 Likes
Message 7 of 8

dgood158
Participant
Participant

@denisT.MaxDoctor 

 

Thank you for throwing together the scripts, it took a little bit to wrap my head around but I finally got it. It is a great way to get the function to work, however I will probably stay with the paramwires, using the two-way, and was able to get that to work. It isn't the best way, however we have a lot of scripts working with this setup so it will be a challenge to update all of them at this time. I'm going to save what you created and hopefully we can switch to that in the future, seems cleaner. Thank you for taking the time to help with this. I'm working on updating files and scripts to hopefully just make it a quick switch.

0 Likes
Message 8 of 8

denisT.MaxDoctor
Advisor
Advisor

you should use "two-way connection" with care. When we talk about your case for example the Yaw/Pitch/Roll to Euler Angles is unambiguous and always true. But reverse 'connection' doesn't always give the same result. Thus, interpolation (inbetween keys animation) can be different in two cases. IMHO one of the ways must be LOCKED 

0 Likes