forked from VyacheslavKlipov/PlacementTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotation.py
177 lines (161 loc) · 5.86 KB
/
Rotation.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
import FreeCADGui
import FreeCAD
import Part,PartGui
from PySide import QtGui
from Common import ICONPATH
from Common import GetSelectedUpperObjects
def Rotate(obj,x,y,z):
a=obj.Placement.Rotation
obj.Placement.Rotation=FreeCAD.Rotation(z,y,x)
obj.Placement.Rotation=obj.Placement.Rotation.multiply(a)
return
def RotateOld(obj,x,y,z):
a=obj.Placement.Rotation.toEuler()
FreeCAD.Console.PrintMessage(a)
FreeCAD.Console.PrintMessage('\n')
i=0
b=[]
r=[]
r.append(z)
r.append(y)
r.append(x)
while i<3:
# FreeCAD.Console.PrintMessage(i)
c=a[i]+r[i]
if c>=360:
c=c-360
if c<=-360:
c=c+360
b.append(c)
i=i+1
d=FreeCAD.Rotation(b[0],b[1],b[2])
#FreeCAD.Console.PrintMessage(b)
#FreeCAD.Console.PrintMessage(d)
obj.Placement.Rotation=d
return
class rX90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rX90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на 90 градусов по оси X"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,90,0,0)
return
class rY90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rY90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на 90 градусов по оси Y"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,0,90,0)
return
class rZ90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rZ90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на 90 градусов по оси Z"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,0,0,90)
return
class rX_90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rX_90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на -90 градусов по оси X"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,-90,0,0)
return
class rY_90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rY_90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на -90 градусов по оси Y"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,0,-90,0)
return
class rZ_90():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rZ_90.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на -90 градусов по оси Z"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
for obj in objs:
Rotate(obj,0,0,-90)
return
class rX():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rX.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на r градусов по оси X"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
if objs.__len__() > 0:
ret=QtGui.QInputDialog.getDouble(None,"","rX")
if ret[1]:
for obj in objs:
Rotate(obj,ret[0],0,0)
return
class rY():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rY.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на r градусов по оси Y"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
if objs.__len__() > 0:
ret=QtGui.QInputDialog.getDouble(None,"","rY")
if ret[1]:
for obj in objs:
Rotate(obj,0,ret[0],0)
return
class rZ():
def GetResources(self):
return {'Pixmap' : ICONPATH+'rZ.svg', # the name of a svg file available in the resources
# 'Accel' : "Shift+S", # a default shortcut (optional)
# 'MenuText': "Allign Left",
'ToolTip' : "Поворачивает объект на r градусов по оси Z"}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(self.__str__())
objs=GetSelectedUpperObjects()
if objs.__len__() > 0:
ret=QtGui.QInputDialog.getDouble(None,"","rZ")
if ret[1]:
for obj in objs:
Rotate(obj,0,0,ret[0])
return
FreeCADGui.addCommand('rX90',rX90())
FreeCADGui.addCommand('rY90',rY90())
FreeCADGui.addCommand('rZ90',rZ90())
FreeCADGui.addCommand('rX_90',rX_90())
FreeCADGui.addCommand('rY_90',rY_90())
FreeCADGui.addCommand('rZ_90',rZ_90())
FreeCADGui.addCommand('rX',rX())
FreeCADGui.addCommand('rY',rY())
FreeCADGui.addCommand('rZ',rZ())