Skip to main content

cpref

Maya 对象引用库

目录

快速开始

如果你的Maya有pip那么

cd "C:\Program Files\Autodesk\Maya2022\bin"
mayapy -m pip install cpref

如果没有

  1. 打开C:\Users\PC\Documents\maya文件夹
  2. 进入scripts文件夹,如果没有就创建它
  3. 下载完整的cpref代码
  4. 解压并进入解压完成的文件夹
  5. 将src目录中的cpref文件夹复制到scripts
  6. 打开maya,如果已经打开了就重启它
  7. 打开脚本编辑器并执行以下示例代码
import maya.mel as mel
from cpref.object_ref import Ref

mel.eval("""polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1 -n test_poly;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
setKeyframe {"group5"};""")
r = Ref("test_poly")
print("Ref __init__ >>", r)
print("Ref is_null >>", r.is_null())
print("Ref as_string >>", r.as_string())
print("Ref as_string_list >>", r.as_string_list())

功能介绍

Maya节点引用

Maya节点引用功能提供了对Maya节点长期引用

from __future__ import unicode_literals, print_function


def test():
    import maya.mel as mel
    from cpref.object_ref import Ref
    mel.eval("""polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1 -n test_poly;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
doGroup 0 1 1;
setKeyframe {"group5"};""")
    r = Ref("test_poly")
    print("Ref __init__ >>", r)
    print("Ref is_null >>", r.is_null())
    print("Ref as_string >>", r.as_string())
    print("Ref as_string_list >>", r.as_string_list())

    print("")
    print("")

    print("### test unsafe methods")
    print("Ref unsafe_m_selection_list >>", r.unsafe_m_selection_list())
    print("Ref unsafe_as_string_list >>", r.unsafe_as_string_list())
    print("Ref unsafe_m_dag_path >>", r.unsafe_m_dag_path())
    print("Ref unsafe_full_path_name >>", r.unsafe_full_path_name())
    print("Ref unsafe_partial_path_name >>", r.unsafe_partial_path_name())

    print("")
    print("")

    print("### test test_poly")
    r = Ref("test_poly")
    print("Ref format >>", r)
    print("Ref ref_type >>", r.ref_type)

    print("### test test_poly.vtx[*]")
    r = Ref("test_poly.vtx[*]")
    print("Ref format >>", r)

    print("### test test_poly.vtx[0]")
    r = Ref("test_poly.vtx[0]")
    print("Ref format >>", r)

    print("### test test_poly.tx")
    r = Ref("test_poly.tx")
    print("Ref format >>", r)
    print("Ref ref_type >>", r.ref_type)

    print("")
    print("")

    print("### test object null check")
    r = Ref("test_poly")
    mel.eval("file -f -new;")
    print("Ref is_null >>", r.is_null())


test()
Ref __init__ >> DagNode<u'test_poly'>
Ref is_null >> False
Ref as_string >> test_poly
Ref as_string_list >> (u'test_poly',)


### test unsafe methods
Ref unsafe_m_selection_list >> ('test_poly')
Ref unsafe_as_string_list >> (u'test_poly',)
Ref unsafe_m_dag_path >> test_poly
Ref unsafe_full_path_name >> |group5|group4|group3|group2|group1|test_poly
Ref unsafe_partial_path_name >> test_poly


### test test_poly
Ref format >> DagNode<u'test_poly'>
Ref ref_type >> 1
### test test_poly.vtx[*]
Ref format >> Component<u'test_poly.vtx[0:381]'>
### test test_poly.vtx[0]
Ref format >> Component<u'test_poly.vtx[0]'>
### test test_poly.tx
Ref format >> Plug<u'test_poly.translateX'>
Ref ref_type >> 0


### test object null check
Ref is_null >> True

版权说明

该项目签署了Apache-2.0 授权许可,详情请参阅 LICENSE

Release files for cpref 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpref 1.1.1
File Size Uploaded
cpref-1.1.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cpref 1.1.1
File Interpreter ABI Platform
cpref-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 19.7 kB

Release files / cpref-1.1.1.tar.gz

Download URL cpref-1.1.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
30c32931234e5ebda0330fd6d8d6fba86b81d26ec8839de7786d57b869776d18
BLAKE2b-256 checksum
How to use checksums
d63216fe5625d85920687eebc84b0457f7a7663f874c638a17f6e61e92a35762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / cpref-1.1.1-py2.py3-none-any.whl

Download URL cpref-1.1.1-py2.py3-none-any.whl
Size 10.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
abdb755003e251c134f18180c3071d141965a3dcf8dbd4f66a6df53a7e220b00
BLAKE2b-256 checksum
How to use checksums
d8f4993c53de628479a85c9e5638b55f29175ae41ee46740c0ca5c3be00bfd9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page