-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPost_test_02.py
More file actions
155 lines (137 loc) · 5.32 KB
/
Post_test_02.py
File metadata and controls
155 lines (137 loc) · 5.32 KB
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
__author__ = 'yangh_000'
import FreeCAD
import FreeCADGui
import os
import Part
import Drawing
import sys
from PySide import QtGui, QtCore
import cPickle
import SearchAgent
import begin
import ITSGui
App=FreeCAD
#App.newDocument()
v=FreeCADGui.activeDocument().activeView()
#existitem=["test"]
class small_sphere_01:
def Activated(self):
ssph1=Part.makeSphere(1.0)
pos=App.Vector(0,0,4.5)
rot=App.Rotation(App.Vector(0,0,1),0)
newplace=App.Placement(pos,rot)
ssph1.Placement=newplace
App.ActiveDocument.addObject("Part::Feature","small_sphere_01")
App.ActiveDocument.small_sphere_01.Shape=ssph1
App.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
ITSGui.existitem.append("small_sphere_01")
ITSGui.log.append('small_sphere_01')
def GetResources(self):
return {'Pixmap': './Mod/ITS_test00/sphere1.png', 'MenuText': 'small_sphere_01', 'ToolTip': 'Create a small sphere at center'}
def IsActive(self):
if len(begin.begin)<3 or len(begin.submit)<4 or len(begin.submit)==5:
return False
objs=App.ActiveDocument.Objects
for obj in objs:
a=obj.Name
if a=="small_sphere_01":
return False
return True
class small_sphere_02:
def Activated(self):
ssph1=Part.makeSphere(1.0)
pos=App.Vector(3,3,4.5)
rot=App.Rotation(App.Vector(0,0,1),0)
newplace=App.Placement(pos,rot)
ssph1.Placement=newplace
App.ActiveDocument.addObject("Part::Feature","small_sphere_02")
App.ActiveDocument.small_sphere_02.Shape=ssph1
App.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
ITSGui.existitem.append("small_sphere_02")
ITSGui.log.append('small_sphere_02')
def GetResources(self):
return {'Pixmap': './Mod/ITS_test00/sphere2.png', 'MenuText': 'small_sphere_02', 'ToolTip': 'Create a small sphere at side'}
def IsActive(self):
if len(begin.begin)<3 or len(begin.submit)<4 or len(begin.submit)==5:
return False
objs=App.ActiveDocument.Objects
for obj in objs:
a=obj.Name
if a=="small_sphere_02":
return False
return True
class small_sphere_03:
def Activated(self):
ssph1=Part.makeSphere(1.0)
pos=App.Vector(-3,-3,4.5)
rot=App.Rotation(App.Vector(0,0,1),0)
newplace=App.Placement(pos,rot)
ssph1.Placement=newplace
App.ActiveDocument.addObject("Part::Feature","small_sphere_03")
App.ActiveDocument.small_sphere_03.Shape=ssph1
App.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
ITSGui.existitem.append("small_sphere_03")
ITSGui.log.append('small_sphere_03')
def GetResources(self):
return {'Pixmap': './Mod/ITS_test00/sphere3.png', 'MenuText': 'small_sphere_03', 'ToolTip': 'Create a small sphere at side'}
def IsActive(self):
if len(begin.begin)<3 or len(begin.submit)<4 or len(begin.submit)==5:
return False
objs=App.ActiveDocument.Objects
for obj in objs:
a=obj.Name
if a=="small_sphere_03":
return False
return True
class sphere:
def Activated(self):
ssph1=Part.makeSphere(7.5)
App.ActiveDocument.addObject("Part::Feature","sphere")
App.ActiveDocument.sphere.Shape=ssph1
App.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
ITSGui.existitem.append("sphere")
ITSGui.log.append('sphere')
def GetResources(self):
return {'Pixmap': './Mod/ITS_test00/sphere_big.png', 'MenuText': 'sphere', 'ToolTip': 'Create a sphere'}
def IsActive(self):
if len(begin.begin)<3 or len(begin.submit)<4 or len(begin.submit)==5:
return False
objs=App.ActiveDocument.Objects
for obj in objs:
a=obj.Name
if a=="sphere":
return False
return True
class cube:
def Activated(self):
ssph1=Part.makeBox(10,10,10)
pos=App.Vector(-5,-5,-5)
rot=App.Rotation(App.Vector(0,0,1),0)
newplace=App.Placement(pos,rot)
ssph1.Placement=newplace
App.ActiveDocument.addObject("Part::Feature","cube")
App.ActiveDocument.cube.Shape=ssph1
App.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
ITSGui.existitem.append("cube")
ITSGui.log.append('cube')
def GetResources(self):
return {'Pixmap': './Mod/ITS_test00/cube.png', 'MenuText': 'cube', 'ToolTip': 'Create a cube'}
def IsActive(self):
if len(begin.begin)<3 or len(begin.submit)<4 or len(begin.submit)==5:
return False
objs=App.ActiveDocument.Objects
for obj in objs:
a=obj.Name
if a=="cube":
return False
return True
FreeCADGui.addCommand('small_sphere_01',small_sphere_01())
FreeCADGui.addCommand('small_sphere_02',small_sphere_02())
FreeCADGui.addCommand('small_sphere_03',small_sphere_03())
FreeCADGui.addCommand('sphere',sphere())
FreeCADGui.addCommand('cube',cube())