Untitled
unknown
plain_text
a year ago
4.0 kB
5
Indexable
import maya.cmds as cmds
# Define the list of groups to select
groups_to_select = [
'|CHAR', 'mini_joystick_rig:joystick_rig', 'spaceship_internal_final:PROPS', 'panelCamera',
'spaceship_internal_final:gaming_chair_rig1:belt_rigRN', 'spaceship_internal_final:gaming_chair_rig2:belt_rigRN',
'spaceship_internal_final:gaming_chair_rig3:belt_rigRN', 'spaceship_internal_final:gaming_chair_rig4:belt_rigRN',
'spaceship_internal_final:gaming_chair_rig5:belt_rigRN', 'spaceship_internal_final:gaming_chair_rig6:belt_rigRN',
'spaceship_internal_final:gaming_chair_rig7:belt_rigRN'
]
# Clear any existing selection
cmds.select(clear=True)
print("Cleared selection")
# Select all specified groups
for group in groups_to_select:
if cmds.objExists(group):
cmds.select(group, add=True)
print(f"Selected group: {group}")
else:
print(f"Group does not exist: {group}")
# Check if 'panelCamera' exists and find its top-most locator if it's a child
panel_camera = 'panelCamera'
if cmds.objExists(panel_camera):
print(f"'panelCamera' exists: {panelCamera}")
current_node = panel_camera
top_locator = None
# Traverse upwards to find the top-most transform with a locator shape
while current_node:
parent = cmds.listRelatives(current_node, parent=True)
if parent:
current_node = parent[0]
# Check if the current node has a locator shape
children = cmds.listRelatives(current_node, shapes=True) or []
if any(cmds.nodeType(child) == 'locator' for child in children):
top_locator = current_node
else:
break # Stop if there's no parent
# Select the top-most locator if found
if top_locator:
cmds.select(top_locator, add=True)
print(f"Selected top locator: {top_locator}")
else:
print("No locator found above 'panelCamera' in hierarchy")
# Set display smoothness for the CHAR group
if cmds.objExists('|CHAR'):
cmds.select('|CHAR', replace=True) # Replace selection with CHAR
cmds.displaySmoothness('|CHAR', divisionsU=3, divisionsV=3, pointsWire=16, pointsShaded=4, polygonObject=3)
print("Set display smoothness for '|CHAR'")
# Re-select everything to include CHAR, panelCamera locator, and specified groups
cmds.select(clear=True)
for group in groups_to_select:
if cmds.objExists(group):
cmds.select(group, add=True)
if top_locator:
cmds.select(top_locator, add=True)
# Find all mesh nodes within the selected objects
mesh_nodes = cmds.ls(selection=True, dag=True, type="mesh", long=True)
# Delete the USD_ATTR_subdivisionScheme attribute if it exists on each mesh node
for mesh in mesh_nodes:
if cmds.attributeQuery('USD_ATTR_subdivisionScheme', node=mesh, exists=True):
cmds.deleteAttr(f"{mesh}.USD_ATTR_subdivisionScheme")
print(f"Deleted subdivisionScheme attribute from {mesh}")
else:
print(f"Attribute 'USD_ATTR_subdivisionScheme' not found on {mesh}")
# Activate existing belt references if present in the scene but unloaded
belt_reference_path = "X:/Shared drives/Loopbox/Viaggio_Ignoto_Project/Rigging/scenes/belt_rig/belt_rig.ma"
for belt_reference_name in groups_to_select:
if "belt_rigRN" in belt_reference_name: # Match only the belt references
try:
# Check if the reference exists and is unloaded
is_loaded = cmds.file(belt_reference_name, q=True, reference=True, isLoaded=True)
if not is_loaded:
cmds.file(belt_reference_name, loadReference=True)
print(f"Activated reference: {belt_reference_name}")
else:
print(f"Reference already loaded: {belt_reference_name}")
except RuntimeError:
print(f"Reference '{belt_reference_name}' does not exist in the scene.")
Editor is loading...
Leave a Comment