Last active
March 13, 2019 14:06
-
-
Save fereria/50d532a9c123255787bd5336627d9a7b to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
""" | |
選択しているリファレンスを複製する | |
複数OK、数値はTransformノード限定 | |
""" | |
import pymel.core as pm | |
import os.path | |
# 現在選択中のノードのFileReferenceを取得する | |
sel_node = pm.ls(sl=True) | |
load_reference = [] | |
for i in sel_node: | |
ref_node = i.referenceFile() | |
if i.referenceFile() not in load_reference: | |
load_reference.append(ref_node) | |
for ref in load_reference: | |
path = ref.path | |
bn = os.path.splitext(os.path.basename(path))[0] | |
to_ref = pm.createReference(path, ns=bn) | |
to_ns = to_ref.namespace | |
for n in ref.nodes(): | |
if n.type() == "transform": | |
to_pynode = pm.PyNode(n.name().replace(ref.namespace + ":", to_ns + ":")) | |
for attr in ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz", "v"]: | |
# ノードにConstriantが貼られている場合は無視する | |
if len(n.attr(attr).connections(scn=True, type="constraint")) == 0: | |
to_pynode.attr(attr).set(n.attr(attr).get()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment