/
nmGeneralTab_func.py
executable file
·674 lines (666 loc) · 20.1 KB
/
nmGeneralTab_func.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
================================================================================
================================================================================
Author: Nole Murphy
Ammended: Nic Wiederhold
Script: nmGeneralTab_func.py
Collection: nmSwissArmyKnife.py
Website: www.nm3d.net
Date Created: 3/6/2011
Last Updated: 10/6/2014
================================================================================
================================================================================
FUNCTIONS:
nmManipulator_local
nmManipulator_world
nmGrouper_group
nmGrouper_ungroup
nmMatchMaker_ab
nmMatchMaker_ba
nmHistory_delete
nmCenter_center
nmMrFreeze_freeze
nmMrFreeze_zero
nmRenamer_searchReplace
nmRenamer_prefix
nmRenamer_suffix
nmRenamer_rename
nmOuterSpace_refresh
nmOuterSpace_create
nmOuterSpace_setSel
nmOuterSpace_remove
================================================================================
HOW TO RUN:
import nmGeneralTab_func
================================================================================
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#=======================#
# MAIN IMPORTS #
#=======================#
# import maya commands
import maya.cmds as cmds
# import maya mel commands
import maya.mel as mel
#=======================#
# IMPORT FUNCTIONS #
#=======================#
import nmGUI_func
#=======================#
# FUNCTIONS #
#=======================#
### manipulator ###
# object
def nmManipulator_object():
'''
this function will set all the transform tools to local space.
'''
cmds.manipMoveContext('Move',e=True,mode=0)
cmds.manipRotateContext('Rotate',e=True,mode=0)
try:
cmds.manipScaleContext('Scale',e=True,mode=0)
except:
pass
# line
nmGUI_func.nmGUI_runCheck('complete','Manipulator tools have been set to object space.')
# local
def nmManipulator_local():
'''
this function will set all the transform tools to local space.
'''
cmds.manipMoveContext('Move',e=True,mode=1)
cmds.manipRotateContext('Rotate',e=True,mode=0)
try:
cmds.manipScaleContext('Scale',e=True,mode=1)
except:
pass
# line
nmGUI_func.nmGUI_runCheck('complete','Manipulator tools have been set to local space.')
# world
def nmManipulator_world():
'''
this function will set all the transform tools to world space.
'''
cmds.manipMoveContext('Move',e=True,mode=2)
cmds.manipRotateContext('Rotate',e=True,mode=1)
try:
cmds.manipScaleContext('Scale',e=True,mode=2)
except:
pass
# line
nmGUI_func.nmGUI_runCheck('complete','Manipulator tools have been set to world space.')
### grouper ###
# group
def nmGrouper_group():
'''
this function will group the selected objects either at its
position or at the origin. will also auto name the group
depending if there is a group below that has the same naming
convention. can do multiple objects with different numbered
null groups.
'''
# get
place = cmds.radioButtonGrp('nmSAK_grpRBG',q=True,sl=True)
# sel
sel = cmds.ls(sl=True)
if (len(sel) > 0):
# group list
groups = []
# group selected
for stuff in sel:
par = cmds.listRelatives(stuff,p=True)
if '_null_' in stuff:
# split obj
split = stuff.split('_null_')
objName = split[0]
num = split[-1]
new = int(num) + 1
if not(cmds.objExists(objName+'_null_'+str(new))):
# create group
cmds.group(n=objName+'_null_'+str(new),em=True)
if (place == 1):
cmds.parentConstraint(stuff,objName+'_null_'+str(new),mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
cmds.parent(stuff,objName+'_null_'+str(new))
groups.append(objName+'_null_'+str(new))
if (par):
cmds.parent(objName+'_null_'+str(new),par[0])
cmds.select(cl=True)
else:
if (cmds.objExists(stuff+'_null_0')==0):
cmds.group(n=stuff+'_null_0',em=True)
if (place == 1):
cmds.parentConstraint(stuff,stuff+'_null_0',mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
cmds.parent(stuff,stuff+'_null_0')
groups.append(stuff+'_null_0')
if (par):
cmds.parent(stuff+'_null_0',par[0])
cmds.select(cl=True)
# sel groups
if (groups):
cmds.select(groups,r=True)
# line
nmGUI_func.nmGUI_runCheck('complete','Selected objects have been grouped.')
else:
# create empty group
cmds.group(em=True)
# line
nmGUI_func.nmGUI_runCheck('complete','Null group has been created.')
# ungroup
def nmGrouper_ungroup():
'''
This function will attempt to ungroup the selected items.
'''
# sel
sel = cmds.ls(sl=True)
if (len(sel) > 0):
# ungroup selected
for stuff in sel:
if (cmds.listRelatives(stuff,c=True)):
cmds.ungroup(stuff)
# line
nmGUI_func.nmGUI_runCheck('complete','Selected objects have been ungrouped.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select a parent node to ungroup.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
### match maker ###
# a to b
def nmMatchMaker_ab():
'''
this function will move the selected item "a's" tranforms or
pivot to other selected items "b". this move can be done with
several options. nothing checked will do the move normally. with
average checked, "a" will be averaged with selection "b".
checking order will allow you to selected multiple a-b
and do the moves all at once.
'''
# sel
sel = cmds.ls(sl=True)
# get checkbox
avg = cmds.checkBox('nmSAK_movAvgCHBX',q=True,v=True)
ordr = cmds.checkBox('nmSAK_movOrdCHBX',q=True,v=True)
types = cmds.radioButtonGrp('nmSAK_movTypeRBG',q=True,sl=True)
# check
if (len(sel) > 1):
if (types==1):
if (avg == 1):
if (len(sel) > 1):
sels = cmds.ls(sl=True)
sels.remove(sels[0])
cmds.parentConstraint(sels,sel[0],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
elif (ordr == 1):
if ((len(sel))%2):
nmGUI_func.nmGUI_runCheck('error','An odd number of objects are selected.')
else:
i = 0
# move selected
while (i < len(sel)-1):
cmds.parentConstraint(sel[i+1],sel[i],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
# counter
i += 2
else:
i = 0
# move selected
while (i < len(sel)-1):
cmds.parentConstraint(sel[-1],sel[i],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
# counter
i += 1
else:
if (avg == 1):
if (len(sel) > 1):
sels = cmds.ls(sl=True)
sels.remove(sels[0])
cmds.spaceLocator(n='ImJuStTeMpOrArYmK')
cmds.parentConstraint(sels,'ImJuStTeMpOrArYmK',mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
get = cmds.xform('ImJuStTeMpOrArYmK',q=True,rp=True,ws=True)
cmds.xform(sel[0],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[0],p=True,ws=True,sp=(get[0],get[1],get[2]))
cmds.delete('ImJuStTeMpOrArYmK')
cmds.select(sel)
elif (ordr == 1):
if ((len(sel))%2):
nmGUI_func.nmGUI_runCheck('error','An odd number of objects are selected.')
else:
i = 0
# move selected
while (i < len(sel)-1):
get = cmds.xform(sel[i+1],q=True,rp=True,ws=True)
cmds.xform(sel[i],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[i],p=True,ws=True,sp=(get[0],get[1],get[2]))
# counter
i += 2
else:
get = cmds.xform(sel[-1],q=True,rp=True,ws=True)
# set
i = 0
# move selected
while (i < len(sel)-1):
cmds.xform(sel[i],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[i],p=True,ws=True,sp=(get[0],get[1],get[2]))
# counter
i += 1
# line
nmGUI_func.nmGUI_runCheck('complete','Match has been made from a to b.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select two or more objects.')
# b to a
def nmMatchMaker_ba():
'''
this function will move the selected item "b's" tranforms or
pivot to other selected items "b". this move can be done with
several options. nothing checked will do the move normally. with
average checked, "b" will be averaged with selection "a".
checking order will allow you to selected multiple b-a
and do the moves all at once.
'''
# sel
sel = cmds.ls(sl=True)
# get checkbox
avg = cmds.checkBox('nmSAK_movAvgCHBX',q=True,v=True)
ordr = cmds.checkBox('nmSAK_movOrdCHBX',q=True,v=True)
types = cmds.radioButtonGrp('nmSAK_movTypeRBG',q=True,sl=True)
# check
if (len(sel) > 1):
if (types==1):
if (avg == 1):
if (len(sel) > 1):
sels = cmds.ls(sl=True)
sels.remove(sels[-1])
cmds.parentConstraint(sels,sel[-1],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
elif (ordr == 1):
if ((len(sel))%2):
nmGUI_func.nmGUI_runCheck('error','An odd number of objects are selected.')
else:
i = 0
# move selected
while (i < len(sel)-1):
cmds.parentConstraint(sel[i],sel[i+1],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
# counter
i += 2
else:
i = 1
# move selected
while (i < len(sel)):
cmds.parentConstraint(sel[0],sel[i],mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
# counter
i += 1
else:
if (avg == 1):
if (len(sel) > 1):
sels = cmds.ls(sl=True)
sels.remove(sels[-1])
cmds.spaceLocator(n='ImJuStTeMpOrArYmK')
cmds.parentConstraint(sels,'ImJuStTeMpOrArYmK',mo=False,n='tEmPbLaHbLaH')
cmds.delete('tEmPbLaHbLaH')
get = cmds.xform('ImJuStTeMpOrArYmK',q=True,rp=True,ws=True)
cmds.xform(sel[-1],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[-1],p=True,ws=True,sp=(get[0],get[1],get[2]))
cmds.delete('ImJuStTeMpOrArYmK')
cmds.select(sel)
elif (ordr == 1):
if ((len(sel))%2):
nmGUI_func.nmGUI_runCheck('error','An odd number of objects were selected.')
else:
i = 0
# move selected
while (i < len(sel)-1):
get = cmds.xform(sel[i],q=True,rp=True,ws=True)
cmds.xform(sel[i+1],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[i+1],p=True,ws=True,sp=(get[0],get[1],get[2]))
# counter
i += 2
else:
get = cmds.xform(sel[0],q=True,rp=True,ws=True)
# set
i = 1
# move selected
while (i < len(sel)):
cmds.xform(sel[i],p=True,ws=True,rp=(get[0],get[1],get[2]))
cmds.xform(sel[i],p=True,ws=True,sp=(get[0],get[1],get[2]))
# counter
i += 1
# line
nmGUI_func.nmGUI_runCheck('complete','Match has been made from b to a.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select two or more objects.')
### history ###
def nmHistory_delete():
'''
this function deletes history on the selected objects. options
are all history or non-deformer history.
'''
# sel
sel = cmds.ls(sl=True)
# get deformer check box
check = cmds.checkBox('nmSAK_hisCHBX',q=True,v=True)
# check
if (len(sel) > 0):
for stuff in sel:
# check for non def
if (check == 1):
try:
mel.eval('doBakeNonDefHistory( 1,{"prePost"});')
except:
pass
else:
cmds.delete(stuff,ch=True)
# line
nmGUI_func.nmGUI_runCheck('complete','History has been deleted.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
### center ###
def nmCenter_center():
'''
this functions centers the rotation and scale pivots on the
selected objects.
'''
# sel
sel = cmds.ls(sl=True)
# check
if (len(sel) > 0):
for stuff in sel:
cmds.xform(stuff,cp=True)
# line
nmGUI_func.nmGUI_runCheck('complete','Pivots have been centered.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
### mr. freeze ###
# freeze
def nmMrFreeze_freeze():
'''
this function will freeze transforms on the selected objects
given the checked options.
'''
# get trans
trans = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v1=True)
# get rot
rot = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v2=True)
# get scl
scl = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v3=True)
# sel
sel = cmds.ls(sl=True)
### check
if (trans == 1):
tr = True
else:
tr = False
if (rot == 1):
ro = True
else:
ro = False
if (scl == 1):
sc = True
else:
sc = False
# check
if (len(sel) > 0):
for stuff in sel:
if not((cmds.getAttr(stuff+'.tx',l=True))and(cmds.getAttr(stuff+'.ty',l=True))and(cmds.getAttr(stuff+'.tz',l=True))):
cmds.makeIdentity(stuff,a=True,t=tr,r=0,s=0,n=0)
if not((cmds.getAttr(stuff+'.rx',l=True))and(cmds.getAttr(stuff+'.ry',l=True))and(cmds.getAttr(stuff+'.rz',l=True))):
cmds.makeIdentity(stuff,a=True,t=0,r=ro,s=0,n=0)
if not((cmds.getAttr(stuff+'.sx',l=True))and(cmds.getAttr(stuff+'.sy',l=True))and(cmds.getAttr(stuff+'.sz',l=True))):
cmds.makeIdentity(stuff,a=True,t=0,r=0,s=sc,n=0)
# line
nmGUI_func.nmGUI_runCheck('complete','Transforms have been frozen.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
# zero
def nmMrFreeze_zero():
'''
this function zeros out the transforms on the selected objects
given the checked options.
'''
# get trans
trans = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v1=True)
# get rot
rot = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v2=True)
# get scl
scl = cmds.checkBoxGrp('nmSAK_frzCBG',q=True,v3=True)
# sel
sel = cmds.ls(sl=True)
# check
if (len(sel) > 0):
# cycle
for stuff in sel:
### check
if (trans == 1):
if (cmds.getAttr(stuff+'.tx',l=True)==0):
cmds.setAttr(stuff+'.tx',0)
if (cmds.getAttr(stuff+'.ty',l=True)==0):
cmds.setAttr(stuff+'.ty',0)
if (cmds.getAttr(stuff+'.tz',l=True)==0):
cmds.setAttr(stuff+'.tz',0)
if (rot == 1):
if (cmds.getAttr(stuff+'.rx',l=True)==0):
cmds.setAttr(stuff+'.rx',0)
if (cmds.getAttr(stuff+'.ry',l=True)==0):
cmds.setAttr(stuff+'.ry',0)
if (cmds.getAttr(stuff+'.rz',l=True)==0):
cmds.setAttr(stuff+'.rz',0)
if (scl == 1):
if (cmds.getAttr(stuff+'.sx',l=True)==0):
cmds.setAttr(stuff+'.sx',1)
if (cmds.getAttr(stuff+'.sy',l=True)==0):
cmds.setAttr(stuff+'.sy',1)
if (cmds.getAttr(stuff+'.sz',l=True)==0):
cmds.setAttr(stuff+'.sz',1)
# line
nmGUI_func.nmGUI_runCheck('complete','Transforms have been zeroed out.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
### renamer ###
# search and replace
def nmRenamer_searchReplace():
'''
this function will search through the selected objects and find
the search string and replace it with the replace string. also
works with having the replace blank so you can get rid of strings
you dont want or need in the selected.
'''
# sel
sel = cmds.ls(sl=True)
sel.sort()
sel.reverse()
# get
search = cmds.textFieldGrp('nmSAK_renSearchTFG',q=True,tx=True)
replace = cmds.textFieldGrp('nmSAK_renReplaceTFG',q=True,tx=True)
searLen = len(search)
# check
if (len(sel) > 0):
if not(search == ''):
for stuff in sel:
new = stuff.split('|')[-1]
if search in new:
start = new.find(search)
after = start+searLen
# rename
cmds.rename(stuff,new[:start]+replace+new[after:])
# line
nmGUI_func.nmGUI_runCheck('complete','"'+search+'" has been replaced with "'+replace+'".')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please specify a search string to be replaced.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
# prefix
def nmRenamer_prefix():
'''
this function will add a prefix to the selected objects.
'''
# sel
sel = cmds.ls(sl=True)
sel.sort()
sel.reverse()
# get
prefix = cmds.textFieldGrp('nmSAK_renPrefixTFG',q=True,tx=True)
# check
if (len(sel) > 0):
if not(prefix == ''):
for stuff in sel:
new = stuff.split('|')[-1]
cmds.rename(stuff,prefix+new)
# line
nmGUI_func.nmGUI_runCheck('complete','Prefix "'+prefix+'" has been added.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please specify a string to be added as a prefix.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
# suffix
def nmRenamer_suffix():
'''
this function will add a prefix to the selected objects.
'''
# sel
sel = cmds.ls(sl=True)
sel.sort()
sel.reverse()
# get
suffix = cmds.textFieldGrp('nmSAK_renSuffixTFG',q=True,tx=True)
# check
if (len(sel) > 0):
if not(suffix == ''):
for stuff in sel:
new = stuff.split('|')[-1]
cmds.rename(stuff,new+suffix)
# line
nmGUI_func.nmGUI_runCheck('complete','Suffix "'+suffix+'" has been added.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please specify a string to be added as a suffix.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
# rename
def nmRenamer_rename():
'''
this function will rename the selected objects given the start
counter and the padding.
'''
# sel
sel = cmds.ls(sl=True,l=True)
numRange = []
# get
name = cmds.textFieldGrp('nmSAK_renNameTFG',q=True,tx=True)
start = cmds.intFieldGrp('nmSAK_renStartIFG',q=True,v1=True)
pad = cmds.intFieldGrp('nmSAK_renPadIFG',q=True,v1=True)
count = '%0'+str(pad)+'d'
# rename
if (len(sel)>0):
if not(name == ''):
for stuff in sel:
numRange.append(start)
start+=1
i=0
while (i<len(numRange)):
sel = cmds.ls(sl=True,l=True)
cmds.rename(sel[i],name+count %numRange[i])
i+=1
# line
nmGUI_func.nmGUI_runCheck('complete','Selected objects have been renamed "'+name+'*".')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please specify a rename string.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
### outer space ###
# refresh
def nmOuterSpace_refresh():
'''
this function will get all the namespaces in the scene and add them
dynamically to the drop down menu for selection.
'''
# get
current = cmds.namespaceInfo(lon=True)
curNames = cmds.optionMenuGrp('nmSAK_namespaceOMG',q=True,ill=True)
curNames.remove(curNames[0])
# remove all
if (curNames):
for stuff in curNames:
cmds.deleteUI(stuff,mi=True)
# add
if (current):
for stuff in current:
cmds.setParent('nmSAK_namespaceOMG')
cmds.menuItem(l=stuff)
# create namespace
def nmOuterSpace_create():
'''
this function will add the given string as a namespace to the scene.
'''
# get
namespace = cmds.textFieldGrp('nmSAK_genNameSpcTFG',q=True,tx=True)
# create
if not(namespace==''):
if not(cmds.namespace(ex=namespace)):
cmds.namespace(add=namespace)
nmGUI_func.nmGUI_runCheck('complete','Namespace "'+namespace+'" has been created.')
nmOuterSpace_refresh()
else:
# line
nmGUI_func.nmGUI_runCheck('error','Namespace already exists.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please specify a namespace string to be created.')
# set selected
def nmOuterSpace_setSel():
'''
this function will set the current selected objects under the given
namespace.
'''
# sel
sel = cmds.ls(sl=True)
# get
curSel = cmds.optionMenuGrp('nmSAK_namespaceOMG',q=True,sl=True)
if (curSel == 1):
curName = ':'
else:
curName = cmds.optionMenuGrp('nmSAK_namespaceOMG',q=True,v=True)+':'
# check
if (len(sel)>0):
# set
for stuff in sel:
split = stuff.split(':')[-1]
cmds.rename(stuff,curName+split)
# line
nmGUI_func.nmGUI_runCheck('complete','Selected objects have been set to "'+curName+'".')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')
# remove
def nmOuterSpace_remove():
'''
this function will remove all namespaces from the selected objects.
'''
# sel
sel = cmds.ls(sl=True)
# check
if (len(sel)>0):
for stuff in sel:
split = stuff.split(':')[-1]
cmds.rename(stuff,':'+split)
# line
nmGUI_func.nmGUI_runCheck('complete','Namespaces have been removed from the selected objects.')
else:
# line
nmGUI_func.nmGUI_runCheck('error','Please select one or more objects.')