개정판 df64816c
issue #000: auto cal.
Change-Id: I9bb208fd487dbd94f8b466a466555e94160f13e2
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
260 | 260 |
if matches: |
261 | 261 |
try: |
262 | 262 |
autocad_xml = parse(autocad_xml_path) |
263 |
|
|
264 | 263 |
autocad_xml_root = autocad_xml.getroot() |
264 |
|
|
265 |
id2_xml_path = os.path.join(temp_path, matches[0]) |
|
266 |
id2_xml = parse(id2_xml_path) |
|
267 |
id2_xml_root = id2_xml.getroot() |
|
265 | 268 |
|
266 | 269 |
find = False |
267 | 270 |
x_offset = None |
268 | 271 |
y_offset = None |
269 | 272 |
for blk_tbl_record in autocad_xml_root.iter('AcDbBlockTableRecord'): |
273 |
if find: |
|
274 |
break |
|
275 |
|
|
270 | 276 |
if blk_tbl_record.attrib['Name'].upper() != '*Model_Space'.upper(): |
271 | 277 |
continue |
272 | 278 |
|
... | ... | |
276 | 282 |
blk_tbl_record.attrib['MaxExtents'].strip('(').strip(')').split(',')] |
277 | 283 |
autocad_bbox = [min_values[0], min_values[1], |
278 | 284 |
max_values[0] - min_values[0], max_values[1] - min_values[1]] |
279 |
for record in blk_tbl_record.iter('AcDbText'):
|
|
285 |
for text_node in blk_tbl_record.iter('AcDbText'):
|
|
280 | 286 |
if find_text != text_node.text: |
281 | 287 |
continue |
282 | 288 |
|
... | ... | |
284 | 290 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale] |
285 | 291 |
|
286 | 292 |
loc = [float(text_node.attrib['X']) * scale + offsets[0], -float(text_node.attrib['Y']) * scale + offsets[1]] |
293 |
_height = round(float(text_node.attrib['Height'])) * scale |
|
294 |
loc[1] -= _height |
|
295 |
|
|
287 | 296 |
x_offset = text_loc[0] - loc[0] |
288 | 297 |
y_offset = text_loc[1] - loc[1] |
289 | 298 |
find = True |
... | ... | |
293 | 302 |
for blk_ref in blk_tbl_record.iter('AcDbBlockReference'): |
294 | 303 |
if find: |
295 | 304 |
break |
296 |
for record in blk_ref.iter('AcDbAttribute'):
|
|
305 |
for text_node in blk_ref.iter('AcDbAttribute'):
|
|
297 | 306 |
if find_text != text_node.text: |
298 | 307 |
continue |
299 | 308 |
|
... | ... | |
301 | 310 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale] |
302 | 311 |
|
303 | 312 |
loc = [float(text_node.attrib['X']) * scale + offsets[0], -float(text_node.attrib['Y']) * scale + offsets[1]] |
313 |
_height = round(float(text_node.attrib['Height'])) * scale |
|
314 |
loc[1] -= _height |
|
315 |
|
|
304 | 316 |
x_offset = text_loc[0] - loc[0] |
305 | 317 |
y_offset = text_loc[1] - loc[1] |
306 | 318 |
find = True |
내보내기 Unified diff