Community
Hello everyone,
I started a blog where I hope to periodically post new tools, tips etc.
The 1st useful thing I've posted is a simple parent constraint tool:
http://www.sternativo.com/?p=146
any feedback, let me know 🙂
thanks!
hey I've updated the script.
Now is more efficient and it will change the name in the navigator based on the type of constraint (I've set it to work only on position, rotation and parent but it's easy to modify it) so it will look like this:
def constraint(CONSTRAINT_TYPE = 3, Weight = 100, SNAP = True, child = None , parent = None ): #assign child and parents variables and check if the right amount of items are selected if child == None or parent == None: selectedModels = FBModelList() FBGetSelectedModels (selectedModels, None, True, True) if len(selectedModels) <= 1 or len(selectedModels)> 2 : FBMessageBox( "Error", "Please select two items", "OK" ) return selected_objects = [FBFindObjectByFullName(model.FullName) for model in selectedModels] child = selected_objects[0] parent = selected_objects[1] ''' CONSTRAINT_TYPE_AIM = 0 CONSTRAINT_TYPE_EXPRESSION = 1 CONSTRAINT_TYPE_MULTI_REFERENTIAL = 2 CONSTRAINT_TYPE_PARENT_CHILD = 3 CONSTRAINT_TYPE_PATH = 4 CONSTRAINT_TYPE_POSITION = 5 CONSTRAINT_TYPE_RANGE = 6 CONSTRAINT_TYPE_RELATION = 7 CONSTRAINT_TYPE_RIGID_BODY = 8 CONSTRAINT_TYPE_3_POINTS = 9 CONSTRAINT_TYPE_ROTATION = 10 CONSTRAINT_TYPE_SCALE = 11 CONSTRAINT_TYPE_MAPPING = 12 CONSTRAINT_TYPE_CHAIN_IK = 13 ''' #setting te prefix for the name displayed on the constraint based on its type if CONSTRAINT_TYPE == 3 : constraint_name = "par_" elif CONSTRAINT_TYPE == 5 : constraint_name = "pnt_" elif CONSTRAINT_TYPE == 10 : constraint_name = "rot_" else: constraint_name = "" #constraint creation with type and name myManager = FBConstraintManager() myCons = myManager.TypeCreateConstraint(CONSTRAINT_TYPE) myCons.Name = constraint_name + child.Name + "_to_" + parent.Name #adding elements to the constraint slots #for index, element in enumerate(selected_objects): myCons.ReferenceAdd (0, child) #if I add an index > 1, it wont be added to the slot(dont know why) myCons.ReferenceAdd (1, parent) #if I add an index > 1, it wont be added to the slot(dont know why) #setting up the snap option, so the elements will keep their position if SNAP == True: myCons.Snap() #weight of the constraint myCons.Weight = 100 myCons.Active = True constraint(CONSTRAINT_TYPE = 3, Weight = 100, SNAP = True, child = None , parent = None )
hope it helps 🙂
Can't find what you're looking for? Ask the community or share your knowledge.