/
Basic_Collection.py
75 lines (53 loc) · 2.12 KB
/
Basic_Collection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# coding:utf-8
import pyblish.api
import pymel.core as pm
import sys
import inspect
import os
# 事实证明一个文件内写多个plugin是可以的,
# hosts才是对的
# pyblish_qml启动的时候的host是python
# 想要使用自己的plugin需要注册host
class CollectLoadedPlugin(pyblish.api.ContextPlugin):
"""Collect [loadedPlugins] Type:list"""
order = pyblish.api.CollectorOrder
label = "Current Loaded Plugin"
# hosts = ['maya']
# 只有host可以显示在pyblish qml界面上,host 可以是列表
# 这是因为在maya里运行的时候,本质pyblish_qml的host是python
# 需要手动注册,不能使用环境变量方式
hosts = ['maya', 'mayapy']
def process(self, context):
loadedPluginPath = map(lambda x: pm.Path(x).basename().name, pm.pluginInfo(q=True, lsp=True))
context.data['LoadedPlugins'] = loadedPluginPath
class CollectMayaProject(pyblish.api.ContextPlugin):
"""Collect [mayaProject]"""
order = pyblish.api.CollectorOrder
label = "Current Maya Project"
hosts = ['maya', 'mayapy']
def process(self, context):
context.data['mayaProject'] = pm.Workspace.getcwd()
class CollectPythonPath(pyblish.api.ContextPlugin):
"""Collect [pythonPaths] Type:list"""
order = pyblish.api.CollectorOrder
label = "Current Python Sys Path"
hosts = ['maya', 'mayapy']
def process(self, context):
context.data['pythonPaths'] = sys.path
class CollectSceneName(pyblish.api.ContextPlugin):
"""Collect [mayaSceneName]"""
order = pyblish.api.CollectorOrder
label = "Current Maya Scene"
hosts = ['maya', 'mayapy']
def process(self, context):
if os.path.exists(pm.sceneName()):
filename = context.create_instance(name=os.path.basename(pm.sceneName()))
filename.data['family'] = 'Scene'
filename.data['icon'] = 'tint'
filename.data['path'] = pm.sceneName()
# -------------------------------------------------------------------------------------------
# 检索模块
plugins = []
for x, y in locals().items():
if inspect.isclass(y):
plugins.append(y)