Mirror an object by rotation
Gentlemen, I have a script that I found on the Internet. It creates an Attribute Holder on a spline object (in this case, it is a controller for the left leg: "CThigh_Controller_L"). There is a button on the attribute that perfectly mirrors the position from the left to the right leg (in this case, these are not bones, but ordinary points). Does anyone know what a command would look like that would do the same thing only with rotation? Don't forget that all objects are in a hierarchy. Thank you.
Original script:
-- Define custom attributes
myAttributes = attributes my_custom_attributes
(
-- Create a rollout with buttons
rollout my_rollout "My Custom Rollout"
(
button btn2 "Left to Right" width:100 height:20
-- Define actions for the button
on btn2 pressed do
(
-- Define the left and right objects
leftObjects = #($CThigh_Controller_L)
rightObjects = #($CThigh_Controller_R)
-- Function to mirror the positions of right objects relative to left objects
fn mirrorPositions leftObjs rightObjs =
(
undo on
(
-- Ensure the number of left and right objects match
if (leftObjs.count == rightObjs.count) then
(
-- Iterate through each pair of left and right objects
for i = 1 to leftObjs.count do
(
leftObj = leftObjs[i]
rightObj = rightObjs[i]
-- Check if the objects are valid
if (isValidNode leftObj and isValidNode rightObj) then
(
-- Calculate the mirrored position of the right object relative to the left object
mirroredPos = [leftObj.pos.x * -1, leftObj.pos.y, leftObj.pos.z]
-- Set the mirrored position for the right object
rightObj.pos = mirroredPos
)
else
(
print ("One or both objects in pair " + i as string + " are invalid.")
)
)
)
else
(
print "The number of left and right objects must be the same."
)
)
)
-- Call the function to mirror positions
mirrorPositions leftObjects rightObjects
)
)
-- Define parameters for the Attribute Holder
parameters main rollout:my_rollout
(
-- Add parameters here if needed
)
)
-- Create an empty Attribute Holder modifier
attrHolder = EmptyModifier()
-- Add the custom attributes to the Attribute Holder
custAttributes.add attrHolder myAttributes
-- Find the spline object by name and apply the Attribute Holder
splineObj = $CThigh_Controller_L
addModifier splineObj attrHolder