Wednesday 24 June 2009

Scripts scripts scripts

I am a beginner scripter. I am really new to it all.
But they are a great way to save you loads of work.

Here is an example:
15 bones are running down each arm the torero. I want them to be maya-style/tendons so i can easily pull them off the rig and make nice arcs etc etc.
That would take me half an hour of quite repetitious clicking/selection/applying/aligning.

Here is a script that does it in one second. It could probably be written nicer and use FN()-functions for some of the things. But it works great!


AxisPointArray=#()
BoneArray =#()
join BoneArray $Selection

for i=1 to BoneArray.count do
(
PositionPoint = point()
PositionPoint.box = true
PositionPoint.size = 8
PositionPoint.wirecolor = color 0 255 0
PositionPoint.transform = BoneArray[i].transform
PositionPoint.name = "Position_" + BoneArray[i].name
join PositionPointArray PositionPoint
)

for i=1 to BoneArray.count do
(
AxisPoint = point()
AxisPoint.box = true
AxisPoint.size = 8
AxisPoint.wirecolor = color 0 255 0
AxisPoint.transform = BoneArray[i].transform
AxisPoint.name = "Axis_" + BoneArray[i].name
in coordsys local move Axispoint [0,0,8]
join AxisPointArray AxisPoint
AxisPoint.Parent = PositionPointArray[i]
)

for i =1 to BoneArray.count do
(
--BoneArray[i].position.controller = position_XYZ ()
BoneArray[i].position.controller = position_list ()
MyposConst = Position_Constraint ()
MyposConst.appendtarget PositionPointArray[i] 50
BoneArray[i].pos.controller.Available.controller = MyposConst



)
for i=1 to BoneArray.count-1 do
(
Aimer= lookat_constraint()
BoneArray[i].rotation.controller = Aimer
BoneArray[i].rotation.controller.constraints.appendtarget PositionPointArray[i+1] 50
Aimer.lookat_vector_length = 0
Aimer.PickUpNode = AxisPointArray[i]
Aimer.upnode_world = false
)

-------------------------
------------------------
And here is what the script does :
Adds the green points to the correct-places and binds the bones to the green points.

1 comment: