5
5
6
6
from .common import EcadParser , Component
7
7
from .kicad_extra import find_latest_schematic_data , parse_schematic_data
8
+ from .svgpath import create_path
8
9
from ..core import ibom
9
10
from ..core .config import Config
10
11
from ..core .fontparser import FontParser
@@ -134,6 +135,21 @@ def parse_text(self, d):
134
135
pos = self .normalize (d .GetPosition ())
135
136
if not d .IsVisible ():
136
137
return None
138
+ if hasattr (d , "GetTextThickness" ):
139
+ thickness = d .GetTextThickness () * 1e-6
140
+ else :
141
+ thickness = d .GetThickness () * 1e-6
142
+ if hasattr (d , 'TransformToSegmentList' ):
143
+ segments = [self .normalize (p ) for p in d .TransformToSegmentList ()]
144
+ lines = []
145
+ for i in range (0 , len (segments ), 2 ):
146
+ if i == 0 or segments [i - 1 ] != segments [i ]:
147
+ lines .append ([segments [i ]])
148
+ lines [- 1 ].append (segments [i + 1 ])
149
+ return {
150
+ "thickness" : thickness ,
151
+ "svgpath" : create_path (lines )
152
+ }
137
153
if d .GetClass () == "MTEXT" :
138
154
angle = d .GetDrawRotation () * 0.1
139
155
else :
@@ -147,10 +163,6 @@ def parse_text(self, d):
147
163
else :
148
164
height = d .GetHeight () * 1e-6
149
165
width = d .GetWidth () * 1e-6
150
- if hasattr (d , "GetTextThickness" ):
151
- thickness = d .GetTextThickness () * 1e-6
152
- else :
153
- thickness = d .GetThickness () * 1e-6
154
166
if hasattr (d , "GetShownText" ):
155
167
text = d .GetShownText ()
156
168
else :
@@ -163,6 +175,7 @@ def parse_text(self, d):
163
175
attributes .append ("italic" )
164
176
if d .IsBold ():
165
177
attributes .append ("bold" )
178
+
166
179
return {
167
180
"pos" : pos ,
168
181
"text" : text ,
@@ -188,8 +201,8 @@ def parse_edges(self, pcb):
188
201
edges = []
189
202
drawings = list (pcb .GetDrawings ())
190
203
bbox = None
191
- for m in self .footprints :
192
- for g in m .GraphicalItems ():
204
+ for f in self .footprints :
205
+ for g in f .GraphicalItems ():
193
206
drawings .append (g )
194
207
for d in drawings :
195
208
if d .GetLayer () == pcbnew .Edge_Cuts :
@@ -228,10 +241,10 @@ def parse_drawings_on_layers(self, drawings, f_layer, b_layer):
228
241
229
242
def get_all_drawings (self ):
230
243
drawings = [(d .GetClass (), d ) for d in list (self .board .GetDrawings ())]
231
- for m in self .footprints :
232
- drawings .append (("ref" , m .Reference ()))
233
- drawings .append (("val" , m .Value ()))
234
- for d in m .GraphicalItems ():
244
+ for f in self .footprints :
245
+ drawings .append (("ref" , f .Reference ()))
246
+ drawings .append (("val" , f .Value ()))
247
+ for d in f .GraphicalItems ():
235
248
drawings .append ((d .GetClass (), d ))
236
249
return drawings
237
250
0 commit comments