-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOreantaion-WithZeroOut
48 lines (37 loc) · 1.31 KB
/
Oreantaion-WithZeroOut
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
#################################################################
###################### Oreantaion-WithZero ########################
#################################################################
#Author:Siddarth Mehra
#Email:[email protected]
#Mobile: +91-7728050400(Whatsapp)
#select the object and run it'll keep the orientation of the selected object and create a upper group with position values
slc = cmds.ls(sl=True,tr=1)
selList = []
try:
parentt=cmds.listRelatives(p=True)
sz= len(parentt)
if sz>0:
for each in slc:
newName = each.replace(parentt[0]+'|','')
selList.append(newName)
print newName
else:
pass
except:
pass
print 'passed parent ftn'
for i in slc:
tmploc = cmds.spaceLocator()
cmds.delete(cmds.parentConstraint(i,tmploc))
pos = cmds.xform(tmploc, q=True, t=True, ws=True)
rot = cmds.xform(tmploc, q=True, ro=True, ws=True)
try:
name = i.replace(parentt[0]+'|','')
except:
name = i
offgrp = cmds.createNode('transform',n=(name+'_OR_Grp'))
cmds.xform(offgrp, translation=pos, ws=True)
cmds.xform(offgrp, rotation=rot, ws=True)
cmds.delete(tmploc)
cmds.parent(i,offgrp)
cmds.select(cl=True)