-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringer_sketch.py
More file actions
184 lines (159 loc) · 10.1 KB
/
stringer_sketch.py
File metadata and controls
184 lines (159 loc) · 10.1 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
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
import Sketcher
import FreeCAD
import FreeCAD,FreeCADGui,Part, Draft
import os
import framing
__title__="FreeCAD Stick Framers Toolkit"
__author__ = "Paul Randall"
__url = "http://www.mathcodeprint.com/"
__command_name__ = "Stringer_Sketch" #Name of the command to appear in Toolbar
__command_group__ = "Constructions" #Name of Toolbar to assign the command
def makeStringerSketch( name ):
newsketch=FreeCAD.ActiveDocument.addObject('Sketcher::SketchObjectPython',name)
Stringer_Sketch(newsketch)
newsketch.ViewObject.Proxy=0
FreeCAD.ActiveDocument.recompute()
newsketch.Placement = FreeCAD.Placement( FreeCAD.Vector (1219.2,-38.1,0),FreeCAD.Rotation (0.7071067811865476, 0.0, 0.0, 0.7071067811865475) )
newsketch.Placement.Rotation = FreeCAD.Rotation (4.329780281177467e-17, 0.7071067811865476, 0.7071067811865475, 4.329780281177466e-17)
return newsketch
class Stringer_Sketch_Command:
def GetResources(self):
#print 'Run getResources() for Stringer_Sketch_Command'
icon_path = framing.getIconImage( "stringer_sketch" )
# image_path = '/stickframe/icons/stringer_sketch.png'
# global_path = FreeCAD.getHomePath()+'Mod'
# user_path = FreeCAD.getUserAppDataDir()+'Mod'
# icon_path = ''
# if os.path.exists(user_path + image_path):
# icon_path = user_path + image_path
# elif os.path.exists(global_path + image_path):
# icon_path = global_path + image_path
return {'MenuText': 'Stringer_Sketch',
'ToolTip': 'Tooltip for Stringer_Sketch command',
'Pixmap' : str(icon_path) }
def IsActive(self):
if FreeCAD.ActiveDocument == None:
#print 'Stringer_Sketch command is NOT active'
return False
else:
#print 'Stringer_Sketch command IS active'
return True
def Activated(self):
#print 'Stringer_SketchCommand activated'
b=FreeCAD.ActiveDocument.addObject('Sketcher::SketchObjectPython','Stringer_Sketch')
newsketch = Stringer_Sketch(b)
b.ViewObject.Proxy=0
newsketch.Placement = FreeCAD.Placement( FreeCAD.Vector (1219.2,-38.1,0),FreeCAD.Rotation (0.7071067811865476, 0.0, 0.0, 0.7071067811865475) )
newsketch.Placement.Rotation = FreeCAD.Rotation (4.329780281177467e-17, 0.7071067811865476, 0.7071067811865475, 4.329780281177466e-17)
FreeCAD.ActiveDocument.recompute()
class Stringer_Sketch:
def __init__(self, obj):
#print 'The Stringer_Sketch class has been instantiated init'
obj.Proxy = self
App = FreeCAD
tmpCircle = None
geometryList = []
constructionList = []
constraintList = []
geometryList.append( Part.LineSegment( App.Vector (-2235.2, 1422.4, 0.0), App.Vector (-1955.8, 1422.4, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1955.8, 1422.4, 0.0), App.Vector (-1955.8, 1244.6000000000001, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-2235.2, 1422.4, 0.0), App.Vector (-2235.2, 1244.6000000000001, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-279.4, 0.0, 0.0), App.Vector (0.0, 0.0, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (0.0, 0.0, 0.0), App.Vector (0.0, 177.8, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (0.0, 177.8, 0.0), App.Vector (-279.4, 177.8, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-2235.2, 1244.6000000000001, 0.0), App.Vector (-279.4000000000001, 0.0, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1955.8, 1244.6000000000001, 0.0), App.Vector (-1676.3999999999999, 1244.6000000000001, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1676.3999999999999, 1244.6000000000001, 0.0), App.Vector (-1676.3999999999999, 1066.8, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1676.3999999999999, 1066.8, 0.0), App.Vector (-1397.0, 1066.8, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1397.0, 1066.8, 0.0), App.Vector (-1397.0, 889.0, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1397.0, 889.0, 0.0), App.Vector (-1117.6, 889.0, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1117.6, 889.0, 0.0), App.Vector (-1117.6, 711.2, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-1117.6, 711.2, 0.0), App.Vector (-838.1999999999999, 711.2, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-838.1999999999999, 711.2, 0.0), App.Vector (-838.1999999999999, 533.4, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-838.1999999999999, 533.4, 0.0), App.Vector (-558.8, 533.4, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-558.8, 533.4, 0.0), App.Vector (-558.8, 355.6, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-558.8, 355.6, 0.0), App.Vector (-279.4, 355.6, 0.0)))
geometryList.append( Part.LineSegment( App.Vector (-279.4, 355.6, 0.0), App.Vector (-279.4, 177.8, 0.0)))
constructionList.append( Part.LineSegment( App.Vector (-2154.6670588235297, 1548.9517647058829, 0.0), App.Vector (80.53294117647056, 126.5517647058823, 0.0)))
constructionList.append( Part.LineSegment( App.Vector (-2235.2, 1422.4, 0.0), App.Vector (0.0, 0.0, 0.0)))
constructionList.append( Part.LineSegment( App.Vector (-2154.6670588235297, 1548.9517647058829, 0.0), App.Vector (-2315.732941176471, 1295.8482352941182, 0.0)))
constructionList.append( Part.LineSegment( App.Vector (80.53294117647059, 126.55176470588236, 0.0), App.Vector (-80.53294117647062, -126.55176470588233, 0.0)))
constraintList.append( Sketcher.Constraint('Vertical',2 ) )
constraintList.append( Sketcher.Constraint('Vertical',1 ) )
constraintList.append( Sketcher.Constraint('Vertical',8 ) )
constraintList.append( Sketcher.Constraint('Vertical',10 ) )
constraintList.append( Sketcher.Constraint('Vertical',12 ) )
constraintList.append( Sketcher.Constraint('Vertical',14 ) )
constraintList.append( Sketcher.Constraint('Vertical',16 ) )
constraintList.append( Sketcher.Constraint('Vertical',18 ) )
constraintList.append( Sketcher.Constraint('Vertical',4 ) )
constraintList.append( Sketcher.Constraint('Horizontal',0 ) )
constraintList.append( Sketcher.Constraint('Horizontal',7 ) )
constraintList.append( Sketcher.Constraint('Horizontal',9 ) )
constraintList.append( Sketcher.Constraint('Horizontal',11 ) )
constraintList.append( Sketcher.Constraint('Horizontal',13 ) )
constraintList.append( Sketcher.Constraint('Horizontal',15 ) )
constraintList.append( Sketcher.Constraint('Horizontal',17 ) )
constraintList.append( Sketcher.Constraint('Horizontal',5 ) )
constraintList.append( Sketcher.Constraint('Horizontal',3 ) )
constraintList.append( Sketcher.Constraint('Equal',2,1))
constraintList.append( Sketcher.Constraint('Equal',1,8))
constraintList.append( Sketcher.Constraint('Equal',8,10))
constraintList.append( Sketcher.Constraint('Equal',10,12))
constraintList.append( Sketcher.Constraint('Equal',12,14))
constraintList.append( Sketcher.Constraint('Equal',14,16))
constraintList.append( Sketcher.Constraint('Equal',16,18))
constraintList.append( Sketcher.Constraint('Equal',18,4))
constraintList.append( Sketcher.Constraint('Equal',0,7))
constraintList.append( Sketcher.Constraint('Equal',7,9))
constraintList.append( Sketcher.Constraint('Equal',9,11))
constraintList.append( Sketcher.Constraint('Equal',11,13))
constraintList.append( Sketcher.Constraint('Equal',13,15))
constraintList.append( Sketcher.Constraint('Equal',15,17))
constraintList.append( Sketcher.Constraint('Equal',17,5))
constraintList.append( Sketcher.Constraint('Equal',5,3))
constraintList.append( Sketcher.Constraint('Coincident',0,2,1,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',7,2,8,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',7,1,1,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',9,1,8,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',10,1,9,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',11,1,10,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',12,1,11,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',13,1,12,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',13,2,14,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',15,1,14,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',16,1,15,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',16,2,17,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',18,1,17,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',5,2,18,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',4,2,5,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',3,2,4,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',3,1,6,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',2,1,0,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',6,1,2,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',3,2,-1,1 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',0,2,19 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',4,2,19 ) )
constraintList.append( Sketcher.Constraint('Coincident',20,1,0,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',20,2,3,2 ) )
constraintList.append( Sketcher.Constraint('Coincident',21,1,19,1 ) )
constraintList.append( Sketcher.Constraint('Coincident',22,1,19,2 ) )
constraintList.append( Sketcher.Constraint('Perpendicular',20,0,21 ) )
constraintList.append( Sketcher.Constraint('Perpendicular',22,0,20 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',3,2,22 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',0,1,21 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',21,2,6 ) )
constraintList.append( Sketcher.Constraint('PointOnObject',22,2,6 ) )
constraintList.append( Sketcher.Constraint('DistanceY',1,2,1,1,177.8))
constraintList.append( Sketcher.Constraint('DistanceX',0,1,0,2,279.4))
obj.addGeometry( geometryList, False)
obj.addGeometry( constructionList, True)
obj.addConstraint( constraintList )
def onChanged(self, fp, prop):
name = str(prop)
newvalue = str(fp.getPropertyByName(str(prop)))
#FreeCAD.Console.print.writeMessage('Changed property: ' + name + 'to ' + newvalue + '')
def execute(self,fp):
fp.recompute()
# print (' Stringer_Sketch Class executed()')
FreeCADGui.addCommand('Stringer_Sketch',Stringer_Sketch_Command() )