프로젝트

일반

사용자정보

개정판 7c180550

ID7c180550402307da51a46142d7d21906bbd31dcc
상위 c235988e
하위 799230f2, 89a2fbe0

백흠경이(가) 약 4년 전에 추가함

issue #1493: AutoCAD에서 블럭을 심볼로 변환시 오류 수정

Change-Id: Ib0f6b229afc6dcbfb863a35ee804eab672a5096b

차이점 보기:

DTI_PID/DTI_PID/ImportTextFromCADDialog.py
603 603
                    message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
604 604
                              f"{sys.exc_info()[-1].tb_lineno}"
605 605
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
606
            else:
607
                from App import App
608
                from AppDocData import MessageType
609

  
610
                message = 'There is no xml file'
611
                App.mainWnd().addMessage.emit(MessageType.Error, message)
606 612

  
607 613
    def symbol_to_xml(self, blk_ref_node, id2_bbox, autocad_bbox, mapping_configs: list) -> str:
608 614
        """try to convert block reference element to id2 xml"""
......
622 628
                                             scale, offsets)
623 629
            angle = round(float(blk_ref_node.attrib['Angle']), 2)
624 630

  
631
            """check if maxtents or minextents attribute exists"""
632
            if 'MaxExtents' not in blk_ref_node.attrib or 'MinExtents' not in blk_ref_node.attrib:
633
                return None
634

  
625 635
            min_extents, max_extents = None, None
626 636
            tokens = blk_ref_node.attrib['MaxExtents'].strip('()').split(',')
627 637
            if 3 == len(tokens):
......
655 665

  
656 666
                item = SymbolSvgItem.createItem(symbol.getType(), symbol.getName(), path=svg_file_path)
657 667
                loc = [min(min_extents[0], max_extents[0]), min(min_extents[1], max_extents[1])]
658
                connPts = None
659
                strConnPts = symbol.getConnectionPoint()
660
                if strConnPts is not None and strConnPts != '':
661
                    connPts = [(float(x.split(',')[0]), float(x.split(',')[1])) if len(x.split(',')) == 2 else (
662
                        x.split(',')[0], float(x.split(',')[1]), float(x.split(',')[2])) \
663
                            for x in strConnPts.split('/')]
664

  
665
                item.buildItem(name, symbol.getType(), angle, loc, (_width, _height), origin, connPts=connPts,
666
                               parentSymbol=None, childSymbol=None, hasInstrumentLabel=False, dbUid=uid)
668
                item.buildItem(name, symbol.getType(), angle, loc, (_width, _height), origin,
669
                               connPts=symbol.parse_connection_pts(origin), parentSymbol=None, childSymbol=None,
670
                               hasInstrumentLabel=False, dbUid=uid)
667 671
                item.converted = True
668 672

  
669 673
                app_doc_data = AppDocData.instance()
......
822 826

  
823 827
            """get id2 line type uid"""
824 828
            line_type, line_type_cond = get_line_type(layers, line_types, line_node.attrib['Layer'],
825
                                                    line_node.attrib['Linetype']), None
829
                                                      line_node.attrib['Linetype']), None
826 830
            model = self.ui.treeViewLineType.model()
827 831
            for row in range(model.rowCount()):
828 832
                parent_index = model.index(row, 0)
......
842 846
            node = None
843 847
            for idx in range(len(pts) - 1):
844 848
                start, end = pts[idx], pts[idx + 1]
849
                dx, dy = end[0] - start[0], end[1] - start[1]
845 850

  
846
                item = QEngineeringLineItem(vertices=[start, end], thickness=5)
847
                if item.length() < 40:
851
                """check if length is zero"""
852
                length = dx*dx + dy*dy
853
                if length == 0:
848 854
                    continue
849
                
855

  
856
                item = QEngineeringLineItem(vertices=[start, end], thickness=5)
857

  
850 858
                angle = math.degrees(item.angle())
851 859
                if not ((-5 < angle < 5) or (85 < angle < 95) or (175 < angle < 185) or (355 < angle < 365)):
852 860
                    continue
......
858 866

  
859 867
                node = item.toXml()
860 868

  
861
                '''
862
                """create a element for id2"""
863
                node = Element('LINE')
864
                node.attrib['OWNER'] = 'None'
865
                _node = SubElement(node, 'UID')
866
                _node.text = str(uuid.uuid4())
867

  
868
                _node = SubElement(node, 'STARTPOINT')
869
                _node.text = f"{start[0]},{start[1]}"
870

  
871
                _node = SubElement(node, 'ENDPOINT')
872
                _node.text = f"{end[0]},{end[1]}"
873

  
874
                if line_type_cond:
875
                    _node = SubElement(node, 'TYPE')
876
                    _node.text = line_type_cond.name
877
                    _node.attrib['TYPEUID'] = line_type_cond.uid
878

  
879
                _node = SubElement(node, 'AREA')
880
                _node.text = 'Drawing'
881

  
882
                _node = SubElement(node, 'THICKNESS')
883
                _node.text = '1'
884

  
885
                _node = SubElement(node, 'FLOWMARK')
886
                _node.text = 'None'
887

  
888
                _node = SubElement(node, 'CONNECTORS')
889
                for conn in range(2):
890
                    __node = SubElement(_node, 'CONNECTOR')
891
                    __node.attrib['CONNECTED_AT'] = '0'
892
                    __node.attrib['UID'] = str(uuid.uuid4())
893
                    ___node = SubElement(__node, 'CONNECTEDITEM')
894
                    ___node.text = 'None'
895
                    ___node = SubElement(__node, 'CONNECTPOINT')
896
                    ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
897
                    ___node = SubElement(__node, 'SCENECONNECTPOINT')
898
                    ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
899
                """up to here"""
900
                '''
901

  
902 869
            return node
903
        
904 870
        except Exception as ex:
905 871
            from App import App
906 872
            from AppDocData import MessageType
......
910 876

  
911 877
            App.mainWnd().addMessage.emit(MessageType.Error, message)
912 878

  
879
        return None
880

  
913 881
def close(self):
914
    QDialog.reject(self)
882
    QDialog.reject(self)
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
335 335

  
336 336
        return (dx, dy)
337 337

  
338
    '''
338
    def angle(self):
339
        """
339 340
        @brief  return angle of line in radian
340 341
        @author humkyung
341
        @date   2018.04.22
342
    '''
342
        """
343 343

  
344
    def angle(self):
345 344
        import math
346 345

  
347 346
        startPt = self.start_point()
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
1597 1597

  
1598 1598
                currentPointModeIndex = node.find('CURRENTPOINTMODEINDEX')
1599 1599
                if currentPointModeIndex is not None:
1600
                    item.currentPointModeIndex = int(currentPointModeIndex.text)
1600
                    item.currentPointModeIndex = int(currentPointModeIndex.text) if currentPointModeIndex.text else 0
1601 1601
        except Exception as ex:
1602 1602
            from App import App
1603 1603
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
DTI_PID/DTI_PID/SymbolBase.py
4 4

  
5 5
from Area import Area
6 6

  
7
class SymbolBase():
7

  
8
class SymbolBase:
8 9
    def __init__(self, sName, sType, threshold = None, minMatchCount = 0
9 10
                 , isDetectOnOrigin = False, rotationCount = 4, ocrOption = OCR_OPTION_NOT_EXEC, isContainChild = 0
10 11
                 , originalPoint = None, connectionPoint = None, baseSymbol = None, additionalSymbol = None
......
135 136
    def getOriginalPoint(self):
136 137
        return self.originalPoint
137 138

  
139
    def parse_connection_pts(self, origin: list) -> list:
140
        """parse connection points and add origin point"""
141
        res = []
142

  
143
        for param in self.connectionPoint.split('/'):
144
            tokens = param.split(',')
145
            res.append(
146
                ('AUTO', origin[0] + float(tokens[0]), origin[1] + float(tokens[1]), '0') if len(tokens) == 2 else
147
                (tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), '0') if len(tokens) == 3 else
148
                (tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), tokens[3]))
149

  
150
        return res
151

  
138 152
    def setConnectionPoint(self, connectionPoint):
139 153
        self.connectionPoint = connectionPoint
140 154

  
......
207 221
            return project.getSvgFilePath() + "/" + self.getType() + "/" + self.getName() + ".svg"
208 222
        return None
209 223

  
224

  
210 225
class imgLine():
211 226
    def __init__(self, start, end):
212 227
        self.start = start

내보내기 Unified diff

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