@@ -102,26 +102,36 @@ def parse_shape(self, d):
102
102
return None
103
103
start = self .normalize (d .GetStart ())
104
104
end = self .normalize (d .GetEnd ())
105
- if (shape == "segment" or shape == "rect" and
106
- not (hasattr (d , "IsFilled" ) and d .IsFilled ())):
105
+ if shape == "segment" :
107
106
return {
108
107
"type" : shape ,
109
108
"start" : start ,
110
109
"end" : end ,
111
110
"width" : d .GetWidth () * 1e-6
112
111
}
113
- if shape == "rect" and hasattr (d , "IsFilled" ) and d .IsFilled ():
114
- return {
112
+
113
+ if shape == "rect" :
114
+ if hasattr (d , "GetRectCorners" ):
115
+ points = list (map (self .normalize , d .GetRectCorners ()))
116
+ else :
117
+ points = [
118
+ start ,
119
+ [end [0 ], start [1 ]],
120
+ end ,
121
+ [start [0 ], end [1 ]]
122
+ ]
123
+ shape_dict = {
115
124
"type" : "polygon" ,
116
- "pos" : start ,
125
+ "pos" : [ 0 , 0 ] ,
117
126
"angle" : 0 ,
118
- "polygons" : [[
119
- [0 , 0 ],
120
- [end [0 ] - start [0 ], 0 ],
121
- [end [0 ] - start [0 ], end [1 ] - start [1 ]],
122
- [0 , end [1 ] - start [1 ]]
123
- ]]
127
+ "polygons" : [points ],
128
+ "width" : d .GetWidth () * 1e-6 ,
129
+ "filled" : 0
124
130
}
131
+ if hasattr (d , "IsFilled" ) and d .IsFilled ():
132
+ shape_dict ["filled" ] = 1
133
+ return shape_dict
134
+
125
135
if shape == "circle" :
126
136
shape_dict = {
127
137
"type" : shape ,
@@ -132,6 +142,7 @@ def parse_shape(self, d):
132
142
if hasattr (d , "IsFilled" ) and d .IsFilled ():
133
143
shape_dict ["filled" ] = 1
134
144
return shape_dict
145
+
135
146
if shape == "arc" :
136
147
a1 , a2 = self .get_arc_angles (d )
137
148
if hasattr (d , "GetCenter" ):
@@ -144,6 +155,7 @@ def parse_shape(self, d):
144
155
"endangle" : a2 ,
145
156
"width" : d .GetWidth () * 1e-6
146
157
}
158
+
147
159
if shape == "polygon" :
148
160
if hasattr (d , "GetPolyShape" ):
149
161
polygons = self .parse_poly_set (d .GetPolyShape ())
@@ -321,7 +333,8 @@ def parse_drawing(self, d):
321
333
s = self .parse_shape (d )
322
334
elif d .GetClass () in ["PTEXT" , "MTEXT" , "FP_TEXT" , "PCB_TEXT" ]:
323
335
s = self .parse_text (d )
324
- elif d .GetClass ().startswith ("PCB_DIM" ) and hasattr (pcbnew , "VECTOR_SHAPEPTR" ):
336
+ elif (d .GetClass ().startswith ("PCB_DIM" )
337
+ and hasattr (pcbnew , "VECTOR_SHAPEPTR" )):
325
338
result .append (self .parse_dimension (d ))
326
339
s = self .parse_text (d .Text ())
327
340
else :
0 commit comments