-
Notifications
You must be signed in to change notification settings - Fork 0
/
maya-xgen.py
100 lines (85 loc) · 4.04 KB
/
maya-xgen.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 使用py调用maya里xgen面板
# # ------------------------------------------------------------
# # xgen
# # get xgen data
# import xgenm as xg
# import xgenm.xgGlobal as xgg
# import xgenm.XgExternalAPI as xge
# if xgg.Maya:
# #palette is collection, use palettes to get collections first.
# palettes = xg.palettes()
# for palette in palettes:
# print("Collection:" + palette)
# #Use descriptions to get description of each collection
# descriptions = xg.descriptions(palette)
# for description in descriptions:
# print("Description:" + description)
# objects = xg.objects(palette, description, True)
# #Get active objects,e.g. SplinePrimtives
# for object in objects:
# print(" Object:" + object)
# attrs = xg.allAttrs(palette, description, object)
# for attr in attrs:
# print (" Attribute:" + attr + ", Value:" + xg.getAttr(attr, palette, description, object))
# # set xgen data
# # xg.setAttr("iMethod",xge.prepForAttribute("1"),"collection", "description", "SplinePrimitive")
# xg.setAttr("cacheFileName",xge.prepForAttribute("${DESC}.abc"),"nier:Nier_hair", "nier:hou1", "SplinePrimitive")
# de = xgg.DescriptionEditor
# de.refresh("Full")
# # --------------------------------------------------------
# # set all cache file name to ${DESC}.abc
# import xgenm as xg
# import xgenm.xgGlobal as xgg
# import xgenm.XgExternalAPI as xge
# if xgg.Maya:
# palettes = xg.palettes()
# for palette in palettes:
# # print("Collection:" + palette)
# if 'hair' not in palette:
# continue
# descriptions = xg.descriptions(palette)
# for description in descriptions:
# # print("Description:" + description)
# xg.setAttr("useCache",xge.prepForAttribute("true"),palette, description, "SplinePrimitive")
# xg.setAttr("liveMode",xge.prepForAttribute("false"),palette, description, "SplinePrimitive")
# # xg.setAttr("iMethod",xge.prepForAttribute("1"),"collection", "description", "SplinePrimitive")
# # xg.setAttr("cacheFileName",xge.prepForAttribute("${DESC}.abc"),"nier:Nier_hair", "nier:hou1", "SplinePrimitive")
# xg.setAttr("cacheFileName",xge.prepForAttribute("${DESC}.abc"),palette, description, "SplinePrimitive")
# de = xgg.DescriptionEditor
# de.refresh("Full")
# # --------------------------------------------------------
# change Collection/Edit File Path
# a = xg.getAttr("xgDataPath", 'nier:Nier_hair')
# newPath = ';lakjdflksjdf'
# a = "{}{}".format(a,newPath)
# xg.setAttr("xgDataPath", a , 'nier:Nier_hair')
# # --------------------------------------------------------
# # 在lookdev工程导出毛发guides,把原本的xgen转换成curves,再选择导出即可
# import maya.cmds as cmds
# import xgenm as xg
# import xgenm.xgGlobal as xgg
# if xgg.Maya:
# palettes = xg.palettes()
# for palette in palettes:
# descriptions = xg.descriptions(palette)
# for description in descriptions:
# print(" Description:" + description)
# guidesName = xg.descriptionGuides(description)
# print(guidesName)
# cmds.select(guidesName, r = True)
# newName = description+"_Curves"
# mel.eval('xgmCreateCurvesFromGuidesOption(0, 0, "%s")' % (newName))
# rootName = "-root %s " % (newName)
# command = ('-j \
# -stripNamespaces\
# -uvWrite\
# -writeColorSets\
# -writeFaceSets\
# -worldSpace\
# -writeVisibility\
# -writeUVSets\
# -dataFormat ogawa\
# -frameRange 0 0\
# %s\
# -file %s' % (rootName,exportAbcPath))
# cmds.AbcExport( j=command )