# Demon Project - Compensate Null Script # By Peter Agg # peter.agg@googlemail.com / peteragg.co.uk """ This script is designed to compliment with my Enveloping Nulls Script. The user is prompted to select a null which has already been Pose constrained to a bone. It will then compensate the constraint by the length of the bone that it has been constrained to. This is useful for _env nulls on IK chains, where the bone might be facing the opposite way. Note: As this is designed to go with the Enveloping Nulls Script it presumes that the null will only have a single Pose constraint on it """ from win32com.client import constants as c def Picknull(): global Picked # Pick the model to work with Picked = Application.PickElement(c.siNullFilter, "Pick model", "Pick model" ) # Right-Click bomb out if Picked[0] == 0: Application.logmessage("ERROR: Right button clicked, returning") return else: GetNullRef() def GetNullRef(): global PickedRef # get the Bone which the _env null is constrained to constraints = Picked(2).Kinematics.Constraints for k in constraints: # Make sure that the constraint is a Pose if str(k.Type) == "posecns": for l in k.constraining: PickedRef = l Ref = PickedRef #"# Application.logmessage(str(Picked(2)) + " is constrained by a " + k.Type + " to: " + str(PickedRef)) CompNull() def CompNull(): Application.logmessage(PickedRef) # Get it's length RefLength = Application.GetValue(str(PickedRef) + ".bone.length") #"# Application.logmessage("RefLength = " + str(RefLength)) # Compensate the constraint by the bone length Application.SetValue(str(Picked(2)) + ".kine.posecns.posx", RefLength, "") Picknull()