更新 server.py

This commit is contained in:
2025-04-16 22:57:01 +08:00
parent 6ec6e0a381
commit 0449d01df4

View File

@@ -160,8 +160,17 @@ def get_scene_info():
# Get selection
try:
# Ensure to pass boolean True, not the string "True"
selection = cmds.ls(sl=True) or []
# Use OpenMaya API to get selection objects, avoid cmds.ls parameter issues
selection_list = om.MGlobal.getActiveSelectionList()
selection = []
for i in range(selection_list.length()):
try:
dep_node = selection_list.getDependNode(i)
if not dep_node.isNull():
node_fn = om.MFnDependencyNode(dep_node)
selection.append(node_fn.name())
except Exception as e:
logger.debug(f"Error getting selection item {i}: {e}")
logger.debug(f"Selection: {selection}")
except Exception as e:
logger.warning(f"Error getting selection: {e}")