MetaFusion/scripts/utils/CurrentProjectDNA.py
2025-02-07 05:10:30 +08:00

31 lines
921 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from Core import Descriptor
def current_project_dna():
"""
更新当前项目的DNA文件路径
- 检查场景中的RL4节点
- 更新项目DNA路径
"""
# 获取所有embeddedNodeRL4类型的节点
rl4_nodes = cmds.ls(type="embeddedNodeRL4")
# 如果没有找到RL4节点报错并返回
if not rl4_nodes:
cmds.error("No RL4 node object...")
return
# 获取当前项目DNA路径
pre_path = Descriptor(gpd=True)
# 检查每个RL4节点
for node in rl4_nodes:
# 获取节点的DNA文件路径
rl4_path = cmds.getAttr(f"{node}.dnaFilePath")
# 如果文件存在且与当前路径不同则更新项目DNA路径
if cmds.file(rl4_path, query=True, exists=True) and rl4_path != pre_path:
Descriptor(spd=rl4_path)