forked from corredD/upy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
342 lines (314 loc) · 12 KB
/
__init__.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 5 23:30:44 2010
@author: Ludovic Autin - [email protected]
This is the main uPy module initialisation
>>> import upy
>>> hClass = upy.getHelperClass()
>>> helper = hClass()
>>> upy.setUIClass()
>>> from upy import uiadaptor
See examples in upy/examples
"""
import os
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
uiadaptor = None
helper = None
host = None
if not os.path.isfile(os.path.abspath(__path__[0])+os.sep+"version.txt"):
f=open(os.path.abspath(__path__[0])+os.sep+"version.txt","w")
f.write("0.0.0")
f.close()
f = open(os.path.abspath(__path__[0])+os.sep+"version.txt","r")
__version__ = f.readline()#"0.6.304"
f.close()
#print globals()
def retrieveHost():
"""
Retrieve the 3d host application where the script is running.
@rtype: string
@return: the name of the host, ie blender, maya or c4d
"""
global host
host=''
try :
import c4d
host = 'c4d'
except :
try :
import MaxPlus
host = '3dsmax'
except:
try :
import Blender
host = 'blender24'
#Text->Open->Execute Python Script
except:
try :
import bpy
host = 'blender25'
#Text->Open->Execute Python Script
except:
try :
import hou
host = 'houdini'
#Text->Open->Execute Python Script
except:
try :
import siutils
host = 'softimage'
except:
try :
import maya
host = 'maya'
except:
try :
import chimera
host = 'chimera'
except :
try :
import DejaVu
host = 'dejavu'
except :
print('host not supported')
return host
def getUClass(host,pref=None):
"""
Return the base class for UI design according the provide host.
@type host: string
@param host: name of the host application
@type pref: string
@param pref: UI interface prefernce for instance qt
@rtype: Class
@return: the specific ui class
"""
if host == 'blender24':
#check version
# from pyubic.blender.blenderUI import blenderUIDialog as adaptor
from upy.blender.v249.blenderUI import blenderUIDialog as adaptor
elif host == 'blender25':
import bpy
blender_version = bpy.app.version
if blender_version < (2,60,0):
from upy.blender.v257.blenderUI import blenderUIDialog as adaptor
elif blender_version >= (2,60,0) and blender_version < (2,63,0): #2.62
from upy.blender.v262.blenderUI import blenderUIDialog as adaptor
elif blender_version >= (2,63,0) and blender_version < (2,71,0): #2.63 and more
from upy.blender.v263.blenderUI import blenderUIDialog as adaptor
elif blender_version >= (2,71,0): #2.63 and more
from upy.blender.v271.blenderUI import blenderUIDialog as adaptor
else :
print (blender_version,blender_version < (2,60,0))
elif host=='c4d':
import c4d
c4d_version = c4d.GetC4DVersion()
if c4d_version > 12000 and c4d_version < 13000 :
from upy.cinema4d.r12.c4dUI import c4dUIDialog as adaptor
elif c4d_version > 13000 and c4d_version < 14000:
from upy.cinema4d.r13.c4dUI import c4dUIDialog as adaptor
elif c4d_version > 14000:
from upy.cinema4d.r14.c4dUI import c4dUIDialog as adaptor
elif host=='maya':
from upy.autodeskmaya.mayaUI import mayaUIDialog as adaptor
elif host=='softimage':
from siutils import si
Application = si()
if type(Application) == unicode :
import sipyutils
Application = sipyutils.si()
v = Application.version()
if v >= (11,0,525,0):
#from upy.softimage.v2013.softimageUI import softimageUIDialog as adaptor
from upy.pythonUI.qtUI import qtUIDialog as adaptor
elif host=='3dsmax':
#from upy.autodesk3dsmax.v2013.maxUI import maxUIDialog as adaptor
from upy.autodesk3dsmax.v2015.maxUI import maxUI as adaptor
elif host=='dejavu':
from upy.dejavuTk.dejavuUI import dejavuUIDialog as adaptor
# print ("ok",adaptor)
elif host=='houdini':
if pref is not None :
if pref == "qt" :
from upy.pythonUI.qtUI import qtUIDialog as adaptor
else :
from upy.houdini.houdiniUI import houdiniUIDialog as adaptor
## elif host == 'chimera':
# from ePMV.Chimera.chimeraUI import chimeraAdaptor as uiadaptor
# elif host == 'houdini':
# from ePMV.houdini.houdiniUI import houdiniAdaptor as uiadaptor
elif host =="qt" :
from upy.pythonUI.qtUI import qtUIDialog as adaptor
else :
adaptor = None
return adaptor
def getHClass(host):
"""
Return the base class for modelling design according the provide host.
@type host: string
@param host: name of the host application
@rtype: Class
@return: the specific ui class
"""
#print globals()
if host == 'blender24':
from upy.blender.v249.blenderHelper import blenderHelper as helper
elif host == 'blender25':
import bpy
blender_version = bpy.app.version
if blender_version < (2,60,0):
from upy.blender.v257.blenderHelper import blenderHelper as helper
elif blender_version >= (2,60,0) and blender_version < (2,63,0): #2.62
from upy.blender.v262.blenderHelper import blenderHelper as helper
elif blender_version >= (2,63,0) and blender_version < (2,71,0): #2.62
from upy.blender.v263.blenderHelper import blenderHelper as helper
elif blender_version >= (2,71,0): #2.62
from upy.blender.v271.blenderHelper import blenderHelper as helper
else :
print (blender_version)
elif host=='c4d':
import c4d
c4d_version = c4d.GetC4DVersion()
if c4d_version > 12000 and c4d_version < 13000:
from upy.cinema4d.r12.c4dHelper import c4dHelper as helper
elif c4d_version > 13000 and c4d_version < 14000:
from upy.cinema4d.r13.c4dHelper import c4dHelper as helper
elif c4d_version > 14000:
from upy.cinema4d.r14.c4dHelper import c4dHelper as helper
elif host=='maya':
from upy.autodeskmaya.mayaHelper import mayaHelper as helper
elif host=='softimage':
from siutils import si
Application = si()
if type(Application) == unicode :
import sipyutils
Application = sipyutils.si()
v = Application.version()
if v >= (11,0,525,0):
from upy.softimage.v2013.softimageHelper import softimageHelper as helper
elif host=='3dsmax':
from upy.autodesk3dsmax.v2015.maxHelper import maxHelper as helper
elif host=='dejavu':
from upy.dejavuTk.dejavuHelper import dejavuHelper as helper
elif host == 'chimera':
from upy.ucsfchimera.chimeraHelper import chimeraHelper as helper
elif host == 'houdini':
from upy.houdini.houdiniHelper import houdiniHelper as helper
else :
helper = None
return helper
def getUIClass(host=None):
"""
Return and define the base class for UI design according the provide host.
If the host is not provide,retrieveHost() will be called to guess the host.
@type host: string
@param host: name of the host application
@rtype: Class
@return: the specific ui class
"""
global uiadaptor
if host is None:
host = retrieveHost()
print ("getUIClass ",host)
if host == '' :
from upy.dejavuTk.dejavuUI import dejavuUIDialog as adaptor
uiadaptor = adaptor
return uiadaptor
uiadaptor = getUClass(host)
return uiadaptor
def setUIClass(host=None,pref=None):
"""
Set the base class for UI design according the provide host.
If the host is not provide,retrieveHost() will be called to guess the host.
@type host: string
@param host: name of the host application
@type pref: string
@param pref: UI interface prefernce for instance qt
"""
global uiadaptor
if host is None:
host = retrieveHost()
if not host :
return None
uiadaptor = getUClass(host,pref=pref)
def getHelperClass(host=None):
"""
Return the base class for modelling design according the provide host.
If the host is not provide,retrieveHost() will be called to guess the host.
@type host: string
@param host: name of the host application
@rtype: Class
@return: the specific ui class
"""
global helper
if host is None:
host = retrieveHost()
if not host :
return None
helper = getHClass(host)
return helper
def getPClass(host):
"""
Return the base class for plugin type provided.
@type host: string
@param host: name of the host application
@rtype: Class
@return: the specific ui class
"""
if host == 'blender24':
from upy.blender.v249 import blenderPlugin as plugClass
elif host == 'blender25':
import bpy
blender_version = bpy.app.version
if blender_version < (2,60,0):
from upy.blender.v257 import blenderPlugin as plugClass
elif blender_version >= (2,60,0) and blender_version < (2,63,0): #2.62
from upy.blender.v262 import blenderPlugin as plugClass
elif blender_version >= (2,63,0) and blender_version < (2,71,0): #2.63
from upy.blender.v263 import blenderPlugin as plugClass
elif blender_version >= (2,63,0): #2.63
from upy.blender.v271 import blenderPlugin as plugClass
else :
print (blender_version,blender_version < (2,60,0))
elif host=='c4d':
import c4d
c4d_version = c4d.GetC4DVersion()
if c4d_version > 12000 and c4d_version < 13000:
from upy.cinema4d.r12 import c4dPlugin as plugClass
elif c4d_version > 13000 and c4d_version < 14000:
from upy.cinema4d.r13 import c4dPlugin as plugClass
elif c4d_version > 14000:
from upy.cinema4d.r14 import c4dPlugin as plugClass
elif host=='maya':
from upy.autodeskmaya import mayaPlugin as plugClass
elif host=='softimage':
from siutils import si
Application = si()
if type(Application) == unicode :
import sipyutils
Application = sipyutils.si()
v = Application.version()
if v >= (11,0,525,0) :
from upy.softimage.v2013 import softimagePlugin as plugClass
elif host=='3dsmax':
from upy.autodesk3dsmax.v2015 import maxPlugin as plugClass
elif host=='dejavu':
from upy.dejavuTk import dejavuPlugin as plugClass
elif host == 'chimera':
from upy.ucsfchimera import chimeraPlugin as plugClass
elif host == 'houdini':
from upy.houdini import houdiniPlugin as plugClass
else :
plugClass = None
return plugClass
def getPluginClass(host=None,plug = None):
global pluginType
if host is None:
host = retrieveHost()
if not host :
return
pluginType = getPClass(host)
if plug is not None :
return pluginType.get(plug)
else :
return pluginType.general_plugClass