Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Created January 5, 2022 20:58
Show Gist options
  • Save Roumenov/b7ef27a557b5e014d954d7f0021eff8b to your computer and use it in GitHub Desktop.
Save Roumenov/b7ef27a557b5e014d954d7f0021eff8b to your computer and use it in GitHub Desktop.
maya constraints and navigating history/connections
import pymel.core as pm
object1 = pm.spaceLocator(relative = 1, position = (0,1,0))
object2 = pm.spaceLocator(relative = 1, position = (1,0,0))
constraint = pm.parentConstraint(object1,object2, maintainOffset = True)
#so, this first one returns nothing from my object
pm.listHistory(allConnections = True, type = 'constraint')
object2.listHistory(allConnections = True, type = 'constraint')
#idk if the params are wrong or what, but it doesn't get me shit
#i guess it doesn't count as "history", i need to review what that term really means
#listConnections however, never fails
pm.listConnections(type = 'constraint')
#only problem is that it returns a list of inputs for all connections
#which is hugely redundant, so I need to do get a little weird and make a list(set(list()))
constraint_instance = list(set(object2.listConnections(type = 'constraint')))[0]
#is this the way? I guess i just expect something more terse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment