2 Simple class to hold common information used by the JSON attribute pattern
3 reader and writer. To use, make sure that pyJsonAttrPatternInfo.py is in
4 your Python path then do the following:
6 from pyJsonAttrPatternInfo import PyJsonAttrPatternInfo as JsonKeys
8 flagKeyword = JsonKeys.kKeyFlags
11 from builtins
import object
13 import maya.api.OpenMaya
as omAPI
16 def jsonDebug(dbgString):
18 Print out some debugging messages if the flag is turned on.
19 Lazily I'm making the location to turn it on be right here as well.
23 print(
'JSON: %s' % dbgString)
28 class PyJsonAttrPatternInfo(object):
29 kPluginPatternFactoryName =
'json'
32 kKeyAcceptedTypes =
'acceptedTypes'
33 kKeyAcceptedNumericTypes =
'acceptedNumericTypes'
34 kKeyAcceptedPluginTypes =
'acceptedPluginTypes'
35 kKeyAttrType =
'attributeType'
38 kKeyNiceName =
'niceName'
39 kKeyShortName =
'shortName'
40 kKeyCategories =
'categories'
41 kKeyEnumNames =
'enumNames'
42 kKeyDefault =
'defaultValue'
43 kKeyDisconnect =
'disconnectBehavior'
44 kKeyChildren =
'children'
47 kKeySoftMin =
'softMin'
48 kKeySoftMax =
'softMax'
56 kNumericTypes = {
'bool' : omAPI.MFnNumericData.kBoolean,
57 'byte' : omAPI.MFnNumericData.kByte,
58 'char' : omAPI.MFnNumericData.kChar,
59 'short' : omAPI.MFnNumericData.kShort,
60 'short2' : omAPI.MFnNumericData.k2Short,
61 'short3' : omAPI.MFnNumericData.k3Short,
62 'long' : omAPI.MFnNumericData.kLong,
63 'int' : omAPI.MFnNumericData.kInt,
64 'long2' : omAPI.MFnNumericData.k2Long,
65 'int2' : omAPI.MFnNumericData.k2Int,
66 'long3' : omAPI.MFnNumericData.k3Long,
67 'int3' : omAPI.MFnNumericData.k3Int,
68 'float' : omAPI.MFnNumericData.kFloat,
69 'float2' : omAPI.MFnNumericData.k2Float,
70 'float3' : omAPI.MFnNumericData.k3Float,
71 'double' : omAPI.MFnNumericData.kDouble,
72 'double2' : omAPI.MFnNumericData.k2Double,
73 'double3' : omAPI.MFnNumericData.k3Double,
74 'double4' : omAPI.MFnNumericData.k4Double,
75 'addr' : omAPI.MFnNumericData.kAddr,
76 'angle' : omAPI.MFnUnitAttribute.kAngle,
77 'distance': omAPI.MFnUnitAttribute.kDistance,
78 'time' : omAPI.MFnUnitAttribute.kTime }
82 kTypeCompound =
'compound'
84 kTypeString =
'string'
86 kTypeMatrix = [
'floatMatrix',
'doubleMatrix']
87 kTypeMatrixTypes = { kTypeMatrix[0] : omAPI.MFnMatrixAttribute.kFloat,
88 kTypeMatrix[1] : omAPI.MFnMatrixAttribute.kDouble }
89 kTypeLightData =
'lightData'
90 kTypeMessage =
'message'
92 kGenericTypes = {
'numeric' : omAPI.MFnData.kNumeric,
93 'pluginGeometry' : omAPI.MFnData.kPluginGeometry,
94 'string' : omAPI.MFnData.kString,
95 'matrix' : omAPI.MFnData.kMatrix,
96 'stringArray' : omAPI.MFnData.kStringArray,
97 'doubleArray' : omAPI.MFnData.kDoubleArray,
98 'intArray' : omAPI.MFnData.kIntArray,
99 'pointArray' : omAPI.MFnData.kPointArray,
100 'vectorArray' : omAPI.MFnData.kVectorArray,
101 'componentList' : omAPI.MFnData.kComponentList,
102 'mesh' : omAPI.MFnData.kMesh,
103 'lattice' : omAPI.MFnData.kLattice,
104 'nurbsCurve' : omAPI.MFnData.kNurbsCurve,
105 'nurbsSurface' : omAPI.MFnData.kNurbsSurface,
106 'sphere' : omAPI.MFnData.kSphere,
107 'dynArrayAttrs' : omAPI.MFnData.kDynArrayAttrs,
108 'dynSweptGeometry': omAPI.MFnData.kDynSweptGeometry,
109 'subdSurface' : omAPI.MFnData.kSubdSurface,
110 'nObject' : omAPI.MFnData.kNObject,
111 'nId' : omAPI.MFnData.kNId }
116 kFlagFunctions = {
'readable' :
'readable',
117 'writable' :
'writable',
118 'canconnectassrc' :
'readable',
119 'canconnectasdst' :
'writable',
120 'connectable' :
'connectable',
121 'storable' :
'storable',
124 'indexmatters' :
'indexMatters',
125 'keyable' :
'keyable',
126 'channelbox' :
'channelBox',
128 'usedascolor' :
'usedAsColor',
129 'indeterminant' :
'indeterminant',
130 'rendersource' :
'renderSource',
131 'worldspace' :
'worldSpace',
132 'affectsworldspace' :
'affectsWorldSpace',
133 'usedasfilename' :
'usedAsFilename',
134 'affectsappearance' :
'affectsAppearance',
135 'usesarraydatabuilder' :
'usesArrayDataBuilder',
136 'internal' :
'internal' }
141 kDisconnectBehaviors = {
'delete' : omAPI.MFnAttribute.kDelete,
142 'reset' : omAPI.MFnAttribute.kReset,
143 'nothing' : omAPI.MFnAttribute.kNothing }