civil-tools-v 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CivilTools/Const/CAD.py +2 -0
- CivilTools/Const/Concrete.py +144 -0
- CivilTools/Const/Steel.py +21 -0
- CivilTools/Const/__init__.py +3 -0
- CivilTools/DXFGenerator/BasicDXF.py +238 -1
- CivilTools/DXFGenerator/DetailDXF.py +324 -0
- CivilTools/DXFGenerator/DrawingAttribs.py +45 -0
- CivilTools/DXFGenerator/LayerManager.py +37 -0
- CivilTools/DXFGenerator/__init__.py +3 -0
- CivilTools/FigureGenerator/BasicPNGPlotter.py +28 -25
- CivilTools/FigureGenerator/BasicPltPlotter.py +115 -1
- CivilTools/FigureGenerator/SeismicReport/ShearMassRatio.py +73 -0
- CivilTools/FigureGenerator/SeismicReport/ShearMoment.py +71 -0
- CivilTools/FigureGenerator/SeismicReport/__init__.py +2 -0
- CivilTools/FigureGenerator/StairCalculationSheetPNGPlotter.py +2 -8
- CivilTools/ReportGenerator/BasicGenerator.py +109 -83
- CivilTools/ReportGenerator/DocParagraph.py +3 -5
- CivilTools/ReportGenerator/DocPicture.py +7 -8
- CivilTools/ReportGenerator/DocTable.py +11 -11
- CivilTools/ReportGenerator/SeismicReport.py +302 -143
- CivilTools/ReportGenerator/SeismicReportTemplate.py +523 -202
- CivilTools/ReportGenerator/StairCalculationReport.py +249 -185
- CivilTools/ReportGenerator/UtilFunctions.py +108 -104
- CivilTools/ReportGenerator/__init__.py +2 -2
- CivilTools/YDBLoader/BuildingDefine/Beam/Beam.py +12 -15
- CivilTools/YDBLoader/BuildingDefine/Column/Column.py +5 -5
- CivilTools/YDBLoader/BuildingDefine/ComponentType.py +1 -1
- CivilTools/YDBLoader/BuildingDefine/Geometry/Grid.py +8 -12
- CivilTools/YDBLoader/BuildingDefine/Geometry/Joint.py +11 -10
- CivilTools/YDBLoader/BuildingDefine/Geometry/StandFloor.py +1 -1
- CivilTools/YDBLoader/BuildingDefine/GlobalResult/BasicResult.py +44 -24
- CivilTools/YDBLoader/BuildingDefine/GlobalResult/SeismicResult.py +168 -54
- CivilTools/YDBLoader/BuildingDefine/Section/Section.py +26 -31
- CivilTools/YDBLoader/BuildingDefine/Section/ShapeEnum.py +9 -9
- CivilTools/YDBLoader/BuildingDefine/Slab/Slab.py +1 -1
- CivilTools/YDBLoader/BuildingDefine/StairPart/LoadDefine.py +16 -10
- CivilTools/YDBLoader/BuildingDefine/StairPart/StairComponent.py +41 -37
- CivilTools/YDBLoader/BuildingDefine/StairPart/StairPart.py +133 -78
- CivilTools/YDBLoader/SQLiteConnector/Connector.py +16 -8
- CivilTools/YDBLoader/SQLiteConnector/RowDataFactory.py +19 -17
- CivilTools/YDBLoader/SQLiteConnector/YDBTableName.py +31 -20
- CivilTools/YDBLoader/YDBLoader.py +128 -110
- {civil_tools_v-0.0.1.dist-info → civil_tools_v-0.0.3.dist-info}/METADATA +88 -5
- civil_tools_v-0.0.3.dist-info/RECORD +60 -0
- {civil_tools_v-0.0.1.dist-info → civil_tools_v-0.0.3.dist-info}/WHEEL +1 -1
- civil_tools_v-0.0.1.dist-info/RECORD +0 -50
- {civil_tools_v-0.0.1.dist-info → civil_tools_v-0.0.3.dist-info}/LICENSE +0 -0
- {civil_tools_v-0.0.1.dist-info → civil_tools_v-0.0.3.dist-info}/top_level.txt +0 -0
    
        CivilTools/Const/CAD.py
    ADDED
    
    
| @@ -0,0 +1,144 @@ | |
| 1 | 
            +
            class ConcreteLevel:
         | 
| 2 | 
            +
                def __init__(
         | 
| 3 | 
            +
                    self,
         | 
| 4 | 
            +
                    level: int,
         | 
| 5 | 
            +
                    fck: float,
         | 
| 6 | 
            +
                    ftk: float,
         | 
| 7 | 
            +
                    fc: float,
         | 
| 8 | 
            +
                    ft: float,
         | 
| 9 | 
            +
                    elastic_module: float,
         | 
| 10 | 
            +
                ):
         | 
| 11 | 
            +
                    self.__level = level
         | 
| 12 | 
            +
                    self.__fck = fck
         | 
| 13 | 
            +
                    self.__ftk = ftk
         | 
| 14 | 
            +
                    self.__fc = fc
         | 
| 15 | 
            +
                    self.__ft = ft
         | 
| 16 | 
            +
                    self.__elastic_module = elastic_module
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                @property
         | 
| 19 | 
            +
                def name(self):
         | 
| 20 | 
            +
                    return f"C{self.__level}"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                @property
         | 
| 23 | 
            +
                def fck(self):
         | 
| 24 | 
            +
                    """混凝土轴心抗压强度标准值,MPa"""
         | 
| 25 | 
            +
                    return self.__fck
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                @property
         | 
| 28 | 
            +
                def ftk(self):
         | 
| 29 | 
            +
                    """混凝土轴心抗拉强度标准值,MPa"""
         | 
| 30 | 
            +
                    return self.__ftk
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                @property
         | 
| 33 | 
            +
                def fc(self):
         | 
| 34 | 
            +
                    """混凝土轴心抗压强度设计值,MPa"""
         | 
| 35 | 
            +
                    return self.__fc
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                @property
         | 
| 38 | 
            +
                def ft(self):
         | 
| 39 | 
            +
                    """混凝土轴心抗拉强度设计值,MPa"""
         | 
| 40 | 
            +
                    return self.__ft
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                @property
         | 
| 43 | 
            +
                def elastic_module(self):
         | 
| 44 | 
            +
                    """混凝土弹性模量,MPa"""
         | 
| 45 | 
            +
                    return self.__elastic_module
         | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
            fck = {
         | 
| 49 | 
            +
                15: 10.0,
         | 
| 50 | 
            +
                20: 13.4,
         | 
| 51 | 
            +
                25: 16.7,
         | 
| 52 | 
            +
                30: 20.1,
         | 
| 53 | 
            +
                35: 23.4,
         | 
| 54 | 
            +
                40: 26.8,
         | 
| 55 | 
            +
                45: 29.6,
         | 
| 56 | 
            +
                50: 32.4,
         | 
| 57 | 
            +
                55: 35.5,
         | 
| 58 | 
            +
                60: 38.5,
         | 
| 59 | 
            +
                65: 41.5,
         | 
| 60 | 
            +
                70: 44.5,
         | 
| 61 | 
            +
                75: 47.4,
         | 
| 62 | 
            +
                80: 50.2,
         | 
| 63 | 
            +
            }
         | 
| 64 | 
            +
            ftk = {
         | 
| 65 | 
            +
                15: 1.27,
         | 
| 66 | 
            +
                20: 1.54,
         | 
| 67 | 
            +
                25: 1.78,
         | 
| 68 | 
            +
                30: 2.01,
         | 
| 69 | 
            +
                35: 2.2,
         | 
| 70 | 
            +
                40: 2.39,
         | 
| 71 | 
            +
                45: 2.51,
         | 
| 72 | 
            +
                50: 2.64,
         | 
| 73 | 
            +
                55: 2.74,
         | 
| 74 | 
            +
                60: 2.85,
         | 
| 75 | 
            +
                65: 2.93,
         | 
| 76 | 
            +
                70: 2.99,
         | 
| 77 | 
            +
                75: 3.05,
         | 
| 78 | 
            +
                80: 3.11,
         | 
| 79 | 
            +
            }
         | 
| 80 | 
            +
            fc = {
         | 
| 81 | 
            +
                15: 7.2,
         | 
| 82 | 
            +
                20: 9.6,
         | 
| 83 | 
            +
                25: 11.9,
         | 
| 84 | 
            +
                30: 14.3,
         | 
| 85 | 
            +
                35: 16.7,
         | 
| 86 | 
            +
                40: 19.1,
         | 
| 87 | 
            +
                45: 21.1,
         | 
| 88 | 
            +
                50: 23.1,
         | 
| 89 | 
            +
                55: 25.3,
         | 
| 90 | 
            +
                60: 27.5,
         | 
| 91 | 
            +
                65: 29.7,
         | 
| 92 | 
            +
                70: 31.8,
         | 
| 93 | 
            +
                75: 33.8,
         | 
| 94 | 
            +
                80: 35.9,
         | 
| 95 | 
            +
            }
         | 
| 96 | 
            +
            ft = {
         | 
| 97 | 
            +
                15: 0.91,
         | 
| 98 | 
            +
                20: 1.1,
         | 
| 99 | 
            +
                25: 1.27,
         | 
| 100 | 
            +
                30: 1.43,
         | 
| 101 | 
            +
                35: 1.57,
         | 
| 102 | 
            +
                40: 1.71,
         | 
| 103 | 
            +
                45: 1.8,
         | 
| 104 | 
            +
                50: 1.89,
         | 
| 105 | 
            +
                55: 1.96,
         | 
| 106 | 
            +
                60: 2.04,
         | 
| 107 | 
            +
                65: 2.09,
         | 
| 108 | 
            +
                70: 2.14,
         | 
| 109 | 
            +
                75: 2.18,
         | 
| 110 | 
            +
                80: 2.22,
         | 
| 111 | 
            +
            }
         | 
| 112 | 
            +
            e = {
         | 
| 113 | 
            +
                15: 22000,
         | 
| 114 | 
            +
                20: 25500,
         | 
| 115 | 
            +
                25: 28000,
         | 
| 116 | 
            +
                30: 30000,
         | 
| 117 | 
            +
                35: 31500,
         | 
| 118 | 
            +
                40: 32500,
         | 
| 119 | 
            +
                45: 33500,
         | 
| 120 | 
            +
                50: 34500,
         | 
| 121 | 
            +
                55: 35500,
         | 
| 122 | 
            +
                60: 36000,
         | 
| 123 | 
            +
                65: 36500,
         | 
| 124 | 
            +
                70: 37000,
         | 
| 125 | 
            +
                75: 37500,
         | 
| 126 | 
            +
                80: 38000,
         | 
| 127 | 
            +
            }
         | 
| 128 | 
            +
             | 
| 129 | 
            +
             | 
| 130 | 
            +
            class Concrete:
         | 
| 131 | 
            +
                C15 = ConcreteLevel(15, fck[15], ftk[15], fc[15], ft[15], e[15])
         | 
| 132 | 
            +
                C20 = ConcreteLevel(20, fck[20], ftk[20], fc[20], ft[20], e[20])
         | 
| 133 | 
            +
                C25 = ConcreteLevel(25, fck[25], ftk[25], fc[25], ft[25], e[25])
         | 
| 134 | 
            +
                C30 = ConcreteLevel(30, fck[30], ftk[30], fc[30], ft[30], e[30])
         | 
| 135 | 
            +
                C35 = ConcreteLevel(35, fck[35], ftk[35], fc[35], ft[35], e[35])
         | 
| 136 | 
            +
                C40 = ConcreteLevel(40, fck[40], ftk[40], fc[40], ft[40], e[40])
         | 
| 137 | 
            +
                C45 = ConcreteLevel(45, fck[45], ftk[45], fc[45], ft[45], e[45])
         | 
| 138 | 
            +
                C50 = ConcreteLevel(50, fck[50], ftk[50], fc[50], ft[50], e[50])
         | 
| 139 | 
            +
                C55 = ConcreteLevel(55, fck[55], ftk[55], fc[55], ft[55], e[55])
         | 
| 140 | 
            +
                C60 = ConcreteLevel(60, fck[60], ftk[60], fc[60], ft[60], e[60])
         | 
| 141 | 
            +
                C65 = ConcreteLevel(65, fck[65], ftk[65], fc[65], ft[65], e[65])
         | 
| 142 | 
            +
                C70 = ConcreteLevel(70, fck[70], ftk[70], fc[70], ft[70], e[70])
         | 
| 143 | 
            +
                C75 = ConcreteLevel(75, fck[75], ftk[75], fc[75], ft[75], e[75])
         | 
| 144 | 
            +
                C80 = ConcreteLevel(80, fck[80], ftk[80], fc[80], ft[80], e[80])
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            class SteelLevel:
         | 
| 2 | 
            +
                def __init__(
         | 
| 3 | 
            +
                    self,
         | 
| 4 | 
            +
                    name: str,
         | 
| 5 | 
            +
                    fy: float,
         | 
| 6 | 
            +
                    elastic_module: float,
         | 
| 7 | 
            +
                ):
         | 
| 8 | 
            +
                    self.name = name
         | 
| 9 | 
            +
                    self.fy = fy
         | 
| 10 | 
            +
                    self.elastic_module = elastic_module
         | 
| 11 | 
            +
             | 
| 12 | 
            +
             | 
| 13 | 
            +
            class Steel:
         | 
| 14 | 
            +
                HRB300 = SteelLevel("HRB300", 300, 2000000)
         | 
| 15 | 
            +
                HRB355 = SteelLevel("HRB355", 300, 2000000)
         | 
| 16 | 
            +
                HRB400 = SteelLevel("HRB400", 300, 2000000)
         | 
| 17 | 
            +
                HRB500 = SteelLevel("HRB500", 300, 2000000)
         | 
| 18 | 
            +
                Q235 = SteelLevel("Q235", 111, 2000000)
         | 
| 19 | 
            +
                Q345 = SteelLevel("Q345", 111, 2000000)
         | 
| 20 | 
            +
                Q355 = SteelLevel("Q355", 111, 2000000)
         | 
| 21 | 
            +
                Q420 = SteelLevel("Q420", 111, 2000000)
         | 
| @@ -1,3 +1,240 @@ | |
| 1 | 
            +
            import ezdxf
         | 
| 2 | 
            +
            from ezdxf.enums import TextEntityAlignment
         | 
| 3 | 
            +
            from ezdxf.addons.drawing import RenderContext, Frontend
         | 
| 4 | 
            +
            from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
         | 
| 5 | 
            +
            import matplotlib.pyplot as plt
         | 
| 6 | 
            +
            import warnings
         | 
| 7 | 
            +
            from math import inf
         | 
| 8 | 
            +
            from typing import List, Iterable, Tuple
         | 
| 9 | 
            +
            from .LayerManager import CADLayer, CADColor, CADLineType
         | 
| 10 | 
            +
            from .DrawingAttribs import DrawingAttribs, PolylineAttribs, TextAttribs
         | 
| 11 | 
            +
            from CivilTools.Const import CADConst
         | 
| 12 | 
            +
             | 
| 1 13 |  | 
| 2 14 | 
             
            class BasicDXF:
         | 
| 3 | 
            -
                 | 
| 15 | 
            +
                file_extension = ".dxf"
         | 
| 16 | 
            +
                DXF2007 = "AC1021"
         | 
| 17 | 
            +
                line_type_patterns = {
         | 
| 18 | 
            +
                    CADLineType.Continuous: [1, 1],
         | 
| 19 | 
            +
                    CADLineType.CENTER: [1, 0.4, -0.2, 0.1, -0.3],
         | 
| 20 | 
            +
                    CADLineType.DASHDOT: [1, 0.6, -0.2, 0, -0.2],
         | 
| 21 | 
            +
                    CADLineType.DASHED: [1, 0.7, -0.3],
         | 
| 22 | 
            +
                }
         | 
| 23 | 
            +
                """线型及其Pattern定义,Pattern定义可参考ezdxf内的定义
         | 
| 24 | 
            +
                The simple line type pattern is a list of
         | 
| 25 | 
            +
                floats :code:`[total_pattern_length, elem1, elem2, ...]`
         | 
| 26 | 
            +
                where an element > 0 is a line, an element < 0 is a gap and  an
         | 
| 27 | 
            +
                element == 0.0 is a dot.
         | 
| 28 | 
            +
                """
         | 
| 29 | 
            +
                DIM_STYLE_PREFIX = "CT"
         | 
| 30 | 
            +
                TEXT_STYLE_NAME = "CT2025"
         | 
| 31 | 
            +
                TEXT_SHX = "xd-hzs.shx"
         | 
| 32 | 
            +
                TEXT_BIG_SHX = "xd-hztxt.shx"
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def __init__(self):
         | 
| 35 | 
            +
                    self.doc = ezdxf.new(BasicDXF.DXF2007)
         | 
| 36 | 
            +
                    self.model_space = self.doc.modelspace()
         | 
| 37 | 
            +
                    self.__loaded_line_types = []
         | 
| 38 | 
            +
                    self.__min_point = [inf, inf]
         | 
| 39 | 
            +
                    self.__max_point = [-inf, -inf]
         | 
| 40 | 
            +
                    self.__load_text_type()
         | 
| 41 | 
            +
                    self.__load_dim_type(100)
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def init_layers(self, layer_list: List[CADLayer]):
         | 
| 44 | 
            +
                    layers = self.doc.layers
         | 
| 45 | 
            +
                    for my_layer in layer_list:
         | 
| 46 | 
            +
                        # 如果图层名称已存在,则不进行新增
         | 
| 47 | 
            +
                        if my_layer.name in [l.dxf.name for l in layers]:
         | 
| 48 | 
            +
                            warnings.warn(f"Layer {my_layer.name} already existed.")
         | 
| 49 | 
            +
                            continue
         | 
| 50 | 
            +
                        temp_layer = layers.new(name=my_layer.name)
         | 
| 51 | 
            +
                        temp_layer.color = my_layer.color.value
         | 
| 52 | 
            +
                        self.__load_line_type(
         | 
| 53 | 
            +
                            my_layer.line_type.name, BasicDXF.line_type_patterns[my_layer.line_type]
         | 
| 54 | 
            +
                        )
         | 
| 55 | 
            +
                        temp_layer.dxf.linetype = my_layer.line_type.name
         | 
| 56 | 
            +
                        self.doc.header["$CLAYER"] = my_layer.name
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                def _add_horizental_line(
         | 
| 59 | 
            +
                    self, start_x, start_y, length: float, attribs: PolylineAttribs | None = None
         | 
| 60 | 
            +
                ):
         | 
| 61 | 
            +
                    self._add_polyline([[start_x, start_y], [start_x + length, start_y]], attribs)
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                def _add_vertical_line(
         | 
| 64 | 
            +
                    self, start_x, start_y, length: float, attribs: PolylineAttribs | None = None
         | 
| 65 | 
            +
                ):
         | 
| 66 | 
            +
                    self._add_polyline([[start_x, start_y], [start_x, start_y + length]], attribs)
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def _add_rectangle(
         | 
| 69 | 
            +
                    self,
         | 
| 70 | 
            +
                    start_x,
         | 
| 71 | 
            +
                    start_y,
         | 
| 72 | 
            +
                    width: float,
         | 
| 73 | 
            +
                    height: float,
         | 
| 74 | 
            +
                    attribs: PolylineAttribs | None = None,
         | 
| 75 | 
            +
                ):
         | 
| 76 | 
            +
                    pts = [
         | 
| 77 | 
            +
                        [start_x, start_y],
         | 
| 78 | 
            +
                        [start_x + width, start_y],
         | 
| 79 | 
            +
                        [start_x + width, start_y + height],
         | 
| 80 | 
            +
                        [start_x, start_y + height],
         | 
| 81 | 
            +
                    ]
         | 
| 82 | 
            +
                    attribs.close = True
         | 
| 83 | 
            +
                    self._add_polyline(pts, attribs)
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def _add_polyline(
         | 
| 86 | 
            +
                    self,
         | 
| 87 | 
            +
                    points: Iterable[Tuple[float, float]],
         | 
| 88 | 
            +
                    attribs: PolylineAttribs | None = None,
         | 
| 89 | 
            +
                ):
         | 
| 90 | 
            +
                    polyline = self.model_space.add_lwpolyline(points, close=attribs.close)
         | 
| 91 | 
            +
                    if attribs != None:
         | 
| 92 | 
            +
                        polyline.dxf.layer = attribs.layer
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                    max_x = max([pt[0] for pt in points])
         | 
| 95 | 
            +
                    max_y = max([pt[1] for pt in points])
         | 
| 96 | 
            +
                    min_x = min([pt[0] for pt in points])
         | 
| 97 | 
            +
                    min_y = min([pt[1] for pt in points])
         | 
| 98 | 
            +
                    self.__update_boundary(max_x, max_y)
         | 
| 99 | 
            +
                    self.__update_boundary(min_x, min_y)
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                def _add_circle(
         | 
| 102 | 
            +
                    self,
         | 
| 103 | 
            +
                    center_point: Iterable[float],
         | 
| 104 | 
            +
                    radius: float,
         | 
| 105 | 
            +
                    attribs: DrawingAttribs | None = None,
         | 
| 106 | 
            +
                ):
         | 
| 107 | 
            +
                    circle = self.model_space.add_circle(center_point, radius)
         | 
| 108 | 
            +
                    if attribs != None:
         | 
| 109 | 
            +
                        circle.dxf.layer = attribs.layer
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                def _add_dimension(
         | 
| 112 | 
            +
                    self,
         | 
| 113 | 
            +
                    start_point: Iterable[float],
         | 
| 114 | 
            +
                    end_point: Iterable[float],
         | 
| 115 | 
            +
                    attribs: DrawingAttribs | None = None,
         | 
| 116 | 
            +
                ):
         | 
| 117 | 
            +
                    dimension = self.model_space.add_linear_dim(
         | 
| 118 | 
            +
                        (0, 0), start_point, end_point, dimstyle="CT-100"
         | 
| 119 | 
            +
                    ).render()
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                    if attribs != None:
         | 
| 122 | 
            +
                        # 这里.dimension才是Dimension对象,才有dxf属性
         | 
| 123 | 
            +
                        dimension.dimension.dxf.layer = attribs.layer
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                def _add_text(self, context: str, insert_point, attribs: TextAttribs):
         | 
| 126 | 
            +
                    text = self.model_space.add_text(context, height=attribs.text_height)
         | 
| 127 | 
            +
                    text.dxf.style = BasicDXF.TEXT_STYLE_NAME
         | 
| 128 | 
            +
                    # width就是宽度因子系数
         | 
| 129 | 
            +
                    text.dxf.width = attribs.text_width_factor
         | 
| 130 | 
            +
                    text.dxf.layer = attribs.layer
         | 
| 131 | 
            +
                    text.dxf.color = attribs.color_index
         | 
| 132 | 
            +
                    text.set_placement(insert_point, align=attribs.text_align)
         | 
| 133 | 
            +
                    max_x = insert_point[0]
         | 
| 134 | 
            +
                    min_x = insert_point[0]
         | 
| 135 | 
            +
                    max_y = insert_point[1] + attribs.text_height
         | 
| 136 | 
            +
                    min_y = insert_point[1] - attribs.text_height
         | 
| 137 | 
            +
                    self.__update_boundary(max_x, max_y)
         | 
| 138 | 
            +
                    self.__update_boundary(min_x, min_y)
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                def _save(self, path: str):
         | 
| 141 | 
            +
                    self.__change_view()
         | 
| 142 | 
            +
                    if not path.endswith(BasicDXF.file_extension):
         | 
| 143 | 
            +
                        path += BasicDXF.file_extension
         | 
| 144 | 
            +
                    for _ in range(10):
         | 
| 145 | 
            +
                        try:
         | 
| 146 | 
            +
                            self.doc.saveas(path)
         | 
| 147 | 
            +
                        except Exception:
         | 
| 148 | 
            +
                            path = path.replace(
         | 
| 149 | 
            +
                                BasicDXF.file_extension, "1" + BasicDXF.file_extension
         | 
| 150 | 
            +
                            )
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                def __change_view(self):
         | 
| 153 | 
            +
                    if inf in self.__max_point or -inf in self.__min_point:
         | 
| 154 | 
            +
                        return
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                    y_range = self.__max_point[1] - self.__min_point[1]
         | 
| 157 | 
            +
                    x_range = self.__max_point[0] - self.__min_point[0]
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    y_middle = (self.__max_point[1] + self.__min_point[1]) / 2
         | 
| 160 | 
            +
                    # 为了使得内容靠右些,避免左侧panel占位的视觉影响
         | 
| 161 | 
            +
                    x_middle = (self.__max_point[0] + self.__min_point[0] * 3) / 4
         | 
| 162 | 
            +
                    # 乘以1.1的系数,增加了一些margin
         | 
| 163 | 
            +
                    self.doc.set_modelspace_vport(
         | 
| 164 | 
            +
                        max(x_range * 1.1, y_range * 1.1), (x_middle, y_middle)
         | 
| 165 | 
            +
                    )
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                def __update_boundary(self, x, y):
         | 
| 168 | 
            +
                    temp_x1 = self.__min_point[0]
         | 
| 169 | 
            +
                    temp_y1 = self.__min_point[1]
         | 
| 170 | 
            +
                    self.__min_point = [min(temp_x1, x), min(temp_y1, y)]
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                    temp_x2 = self.__max_point[0]
         | 
| 173 | 
            +
                    temp_y2 = self.__max_point[1]
         | 
| 174 | 
            +
                    self.__max_point = [max(temp_x2, x), max(temp_y2, y)]
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                def __load_line_type(self, name: str, pattern: List[float]):
         | 
| 177 | 
            +
                    if name in self.__loaded_line_types:
         | 
| 178 | 
            +
                        return
         | 
| 179 | 
            +
                    self.doc.linetypes.add(name, pattern)
         | 
| 180 | 
            +
                    self.__loaded_line_types.append(name)
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                def __load_dim_type(self, scale: int):
         | 
| 183 | 
            +
                    # 获取标注样式表
         | 
| 184 | 
            +
                    dimstyles = self.doc.dimstyles
         | 
| 185 | 
            +
                    # 定义新标注样式的名称
         | 
| 186 | 
            +
                    new_dimstyle_name = f"{BasicDXF.DIM_STYLE_PREFIX}-{scale}"
         | 
| 187 | 
            +
                    # 创建新的标注样式
         | 
| 188 | 
            +
                    new_dimstyle = dimstyles.new(new_dimstyle_name)
         | 
| 189 | 
            +
                    # 设置标注文字样式
         | 
| 190 | 
            +
                    new_dimstyle.dxf.dimtxsty = BasicDXF.TEXT_STYLE_NAME
         | 
| 191 | 
            +
                    # 设置标注文字高度
         | 
| 192 | 
            +
                    new_dimstyle.dxf.dimtxt = 2.5
         | 
| 193 | 
            +
                    # 设置箭头大小
         | 
| 194 | 
            +
                    new_dimstyle.dxf.dimasz = 1
         | 
| 195 | 
            +
                    # 设置标注线超出尺寸界线的长度
         | 
| 196 | 
            +
                    new_dimstyle.dxf.dimexo = 0.625
         | 
| 197 | 
            +
                    # 设置尺寸界线起点偏移量
         | 
| 198 | 
            +
                    new_dimstyle.dxf.dimse1 = 0.625
         | 
| 199 | 
            +
                    #  设置全局比例
         | 
| 200 | 
            +
                    new_dimstyle.dxf.dimscale = scale
         | 
| 201 | 
            +
                    # 保留至整数
         | 
| 202 | 
            +
                    new_dimstyle.dxf.dimrnd = 1
         | 
| 203 | 
            +
                    # 改为建筑箭头
         | 
| 204 | 
            +
                    new_dimstyle.dxf.dimblk = "ARCHTICK"
         | 
| 205 | 
            +
                    new_dimstyle.dxf.dimblk1 = "ARCHTICK"
         | 
| 206 | 
            +
                    new_dimstyle.dxf.dimblk2 = "ARCHTICK"
         | 
| 207 | 
            +
                    self.doc.header["$DIMSTYLE"] = new_dimstyle_name
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                def __load_text_type(self):
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                    text_styles = self.doc.styles
         | 
| 212 | 
            +
                    # 定义新文字样式的名称
         | 
| 213 | 
            +
                    new_style_name = BasicDXF.TEXT_STYLE_NAME
         | 
| 214 | 
            +
                    # 创建新的文字样式
         | 
| 215 | 
            +
                    new_style = text_styles.new(new_style_name)
         | 
| 216 | 
            +
                    # 设置文字样式的属性
         | 
| 217 | 
            +
                    # 指定字体文件,例如 Arial 字体
         | 
| 218 | 
            +
                    new_style.dxf.font = BasicDXF.TEXT_SHX
         | 
| 219 | 
            +
                    new_style.dxf.bigfont = BasicDXF.TEXT_BIG_SHX
         | 
| 220 | 
            +
                    # 设置文字高度
         | 
| 221 | 
            +
                    new_style.dxf.height = 0
         | 
| 222 | 
            +
                    new_style.dxf.width = 0.7
         | 
| 223 | 
            +
                    # 修改当前选择的文字样式
         | 
| 224 | 
            +
                    self.doc.header["$TEXTSTYLE"] = new_style_name
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                def _remove_all_entities(self):
         | 
| 227 | 
            +
                    self.model_space.delete_all_entities()
         | 
| 228 | 
            +
                    self.__min_point = [inf, inf]
         | 
| 229 | 
            +
                    self.__max_point = [-inf, -inf]
         | 
| 230 | 
            +
             | 
| 231 | 
            +
                def _repr_png_(self):
         | 
| 232 | 
            +
                    """可以在jupyter中实时显示绘制的图像情况"""
         | 
| 233 | 
            +
                    ctx = RenderContext(self.doc)
         | 
| 234 | 
            +
                    fig, ax = plt.subplots()
         | 
| 235 | 
            +
                    fig.patch.set_facecolor("black")
         | 
| 236 | 
            +
                    ax.patch.set_facecolor("black")
         | 
| 237 | 
            +
                    plt.axis("off")
         | 
| 238 | 
            +
                    backend = MatplotlibBackend(ax)
         | 
| 239 | 
            +
                    Frontend(ctx, backend).draw_layout(self.model_space)
         | 
| 240 | 
            +
                    plt.show()
         |