Last active
May 17, 2024 06:08
-
-
Save mclavan/6227e8d0412a40ba236f to your computer and use it in GitHub Desktop.
Connecting Nodes with pymel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This script will create an attribute called joint_vis on the first selected and then connect it to the visibility to the second selected. | |
You wll need to have two object in your scene selected to make this example work. | |
Mainly this script is a demo of connecting and disconecting attributes using pymel. | |
''' | |
import pymel.core as pm | |
selected = pm.ls(selection=True) | |
driver = selected[0] | |
driven = selected[1] | |
driver.addAttr('joint_vis', at='long', keyable=True, min=0, max=1) | |
# Creating the connection | |
driver.joint_vis >> driven.v | |
# Disconnecting the connection | |
#driver.v // driven.v | |
# Many hardcore python developers do not like using the operators >> and // | |
# Maya has pm.connectAttr() and pm.disconnectAttr() | |
# This can also be done through methods too connect and disconnect. | |
# driver.joint_vis.connect(driven.v) | |
# driver.joint_vis.disconnect(driven.v) | |
# http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/PyMel/attributes.html?highlight=connectattr | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment