프로젝트

일반

사용자정보

개정판 6c481e3b

ID6c481e3bf70e5620bb50a7072ca41e4b25ab7d5d
상위 c16dd916
하위 ebf7afeb

함의성이(가) 약 2년 전에 추가함

cad graphic ongoing

Change-Id: If784301f48e076deabad10b9762b5f0008b8681b

차이점 보기:

DTI_PID/DTI_PID/ImportTextFromCADDialog.py
1110 1110
                            for symbol in symbols:
1111 1111
                                if 'Converted' in symbol.attrib and symbol.attrib['Converted'] == str(True):
1112 1112
                                    symbols_node.remove(symbol)
1113
                        graphics_node = id2_xml_root.find(xg.GRAPHIC_NODE_NAME)
1114
                        graphics_node.clear()
1113 1115

  
1114 1116
                    if 'Text' in will_be_converted_items:
1115 1117
                        """remove texts from id2 xml file"""
......
1134 1136
                    unknowns.clear()
1135 1137
                    """up to here"""
1136 1138

  
1137
                    """add text, line and symbol from autocad file to id xml file"""
1139
                    """add text, line and symbol from autocad file to id2 xml file"""
1138 1140
                    for blk_tbl_record in autocad_xml_root.iter('AcDbBlockTableRecord'):
1139 1141
                        if blk_tbl_record.attrib['Name'].upper() != '*Model_Space'.upper():
1140 1142
                            continue
......
1166 1168
                        for blk_ref in blk_tbl_record.iter('AcDbBlockReference'):
1167 1169
                            if 'Symbol' in will_be_converted_items:
1168 1170
                                if blk_ref.attrib['Layer'] not in exclude_layers:
1169
                                    node = self.symbol_to_xml(blk_ref, mapping_configs)
1170
                                    if node:
1171
                                        symbols_node.append(node)
1171
                                    node = None
1172
                                    block_name = blk_ref.attrib['Name']
1173
                                    if block_name.split('+')[0] == 'Graphic':
1174
                                        node = self.graphic_to_xml(blk_ref)
1175
                                        if node:
1176
                                            graphics_node.append(node)
1177
                                    else:
1178
                                        node = self.symbol_to_xml(blk_ref, mapping_configs)
1179
                                        if node:
1180
                                            symbols_node.append(node)
1172 1181

  
1173 1182
                            if 'Text' in will_be_converted_items:
1174 1183
                                #angle = round(float(blk_ref.attrib['Angle']), 2)
......
1303 1312
        else:
1304 1313
            return [pt[0] * self.scales[0] + self.offsets[0], self.offsets[2] - pt[1] * self.scales[1] + self.offsets[1]]
1305 1314

  
1315
    def graphic_to_xml(self, blk_ref_node):
1316
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
1317

  
1318
        try:
1319
            node = Element('GRAPHIC')
1320
            uidNode = Element('UID')
1321
            uidNode.text = str(uuid.uuid4())
1322
            node.append(uidNode)
1323

  
1324
            nameNode = Element('NAME')
1325
            nameNode.text = blk_ref_node.attrib['Name']
1326
            node.append(nameNode)
1327

  
1328
            min_extents, max_extents = None, None
1329
            tokens = blk_ref_node.attrib['MaxExtents'].strip('()').split(',')
1330
            if 3 == len(tokens):
1331
                max_extents = self.convert_to_image_coords([float(tokens[0]), float(tokens[1])])
1332

  
1333
            tokens = blk_ref_node.attrib['MinExtents'].strip('()').split(',')
1334
            if 3 == len(tokens):
1335
                min_extents = self.convert_to_image_coords([float(tokens[0]), float(tokens[1])])
1336

  
1337
            locNode1 = Element('LOCATION1')
1338
            locNode1.text = '{},{}'.format(min_extents[0], min_extents[1])
1339
            node.append(locNode1)
1340

  
1341
            locNode2 = Element('LOCATION2')
1342
            locNode2.text = '{},{}'.format(max_extents[0], max_extents[1])
1343
            node.append(locNode2)
1344

  
1345
        except Exception as ex:
1346
            from App import App
1347
            from AppDocData import MessageType
1348

  
1349
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1350
                                                           sys.exc_info()[-1].tb_lineno)
1351
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1352

  
1353
            return None
1354

  
1355
        return node
1356

  
1306 1357
    def symbol_to_xml(self, blk_ref_node, mapping_configs: list) -> str:
1307 1358
        """try to convert block reference element to id2 xml"""
1308 1359
        from SymbolSvgItem import SymbolSvgItem
......
1450 1501
        """try to convert line element to id2 xml"""
1451 1502
        from LineTypeConditions import LineTypeConditions
1452 1503
        from EngineeringLineItem import QEngineeringLineItem
1453
        import uuid, math
1454 1504

  
1455 1505
        def get_line_type(layers: list, line_types: list, layer_name: str, line_type: str) -> str:
1456 1506
            """return line type"""

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)