Skip to content

models

LayoutParam dataclass

包含原点坐标、法向量、坐标轴、厚度等核心布局参数

Source code in dimine_python_sdk\lib\io\models.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@dataclass
class LayoutParam:
    """
    包含原点坐标、法向量、坐标轴、厚度等核心布局参数
    """
    # 原点坐标
    origin_x: float  # 原点X坐标
    origin_y: float  # 原点Y坐标
    origin_z: float  # 原点Z坐标

    # 法向量
    normal_x: float  # 法向量X分量
    normal_y: float  # 法向量Y分量
    normal_z: float  # 法向量Z分量

    # X轴向量
    x_axis_x: float  # X轴向量X分量
    x_axis_y: float  # X轴向量Y分量
    x_axis_z: float  # X轴向量Z分量

    # Y轴向量
    y_axis_x: float  # Y轴向量X分量
    y_axis_y: float  # Y轴向量Y分量
    y_axis_z: float  # Y轴向量Z分量

    # 厚度参数
    forward_thickness: float  # 正向厚度
    reverse_thickness: float  # 反向厚度

    def to_dict(self) -> Dict[str, Any]:
        """转换为字典,便于JSON序列化"""
        return {
            "origin_x": self.origin_x,
            "origin_y": self.origin_y,
            "origin_z": self.origin_z,
            "normal_x": self.normal_x,
            "normal_y": self.normal_y,
            "normal_z": self.normal_z,
            "x_axis_x": self.x_axis_x,
            "x_axis_y": self.x_axis_y,
            "x_axis_z": self.x_axis_z,
            "y_axis_x": self.y_axis_x,
            "y_axis_y": self.y_axis_y,
            "y_axis_z": self.y_axis_z,
            "forward_thickness": self.forward_thickness,
            "reverse_thickness": self.reverse_thickness
        }

to_dict()

转换为字典,便于JSON序列化

Source code in dimine_python_sdk\lib\io\models.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def to_dict(self) -> Dict[str, Any]:
    """转换为字典,便于JSON序列化"""
    return {
        "origin_x": self.origin_x,
        "origin_y": self.origin_y,
        "origin_z": self.origin_z,
        "normal_x": self.normal_x,
        "normal_y": self.normal_y,
        "normal_z": self.normal_z,
        "x_axis_x": self.x_axis_x,
        "x_axis_y": self.x_axis_y,
        "x_axis_z": self.x_axis_z,
        "y_axis_x": self.y_axis_x,
        "y_axis_y": self.y_axis_y,
        "y_axis_z": self.y_axis_z,
        "forward_thickness": self.forward_thickness,
        "reverse_thickness": self.reverse_thickness
    }

PlotBlockParam dataclass

块参数

Source code in dimine_python_sdk\lib\io\models.py
91
92
93
94
95
96
@dataclass
class PlotBlockParam:
    """块参数"""
    display_mode: int
    enable: bool
    shrinkage_coefficient: float

PlotDrillParam dataclass

钻孔参数

Source code in dimine_python_sdk\lib\io\models.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@dataclass
class PlotDrillParam:
    """钻孔参数"""
    AnnotatinoStyle: AnnotatinoStyleParam
    annotation_collar_triangle: bool = False
    annotation_cutting_point_circle: bool = False
    annotation_drill_name: bool = False
    annotation_hole_bottom_line: bool = False
    annotation_position: float = 0.0
    annotation_text_height: float = 0.0
    collar_triangle_ratio: float = 0.0
    cutting_into_point: bool = False
    cutting_point_circle: float = 0.0
    draw_sample_tray: bool = False
    enable: bool = True
    gram_per_ton_field_set: str = ""
    have_intersetion_projection_track: bool = False
    hole_bottom_line_length: float = 0.0
    is_multiple_table: bool = False
    negative_thickness: float = 20.0
    no_intersetion_projection_track: bool = False
    other_field_set: str = ""
    output_drill_section: bool = False
    output_param_table: bool = False
    output_sample_info_table: bool = False
    percentage_field_set: str = ""
    positive_thickness: float = 20.0
    reserve_drill_track_outside_layout: bool = False
    sample_tray_content: str = ""
    sample_tray_interval: float = 0.0
    sample_tray_text_height: float = 0.0
    sample_tray_width: float = 0.0

PlotGirdParam dataclass

网格参数

Source code in dimine_python_sdk\lib\io\models.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@dataclass
class PlotGirdParam:
    """网格参数"""
    check_x: bool
    check_y: bool
    check_z: bool
    color: int
    enable: bool
    mode: int
    separated: bool
    text_height: float
    x: float = 50.0
    y: float = 50.0
    z: float = 50.0
    transverse: bool = False

PlotProjectParam dataclass

项目参数集合

Source code in dimine_python_sdk\lib\io\models.py
83
84
85
86
87
88
@dataclass
class PlotProjectParam:
    """项目参数集合"""
    enable: bool
    file_project_param: List[ProjectHatchItem] = field(default_factory=list)
    type: int = 0

ProjectHatchItem dataclass

单个项目的 Hatch 参数

Source code in dimine_python_sdk\lib\io\models.py
68
69
70
71
72
73
74
75
76
77
78
79
80
@dataclass
class ProjectHatchItem:
    """单个项目的 Hatch 参数"""
    annotation_property: str
    annotation_style: str
    block_hatch: BlockHatch
    pattern_hatch: PatternHatch
    color: int = 0
    line_style: str = "Continuous"
    line_style_ratio: float = 1.0
    line_weight: int = 6
    name: str = ""
    output_mode: int = 2

SetupParams dataclass

主配置参数类

Source code in dimine_python_sdk\lib\io\models.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
@dataclass
class SetupParams:
    """主配置参数类"""
    current: bool
    name: str
    plot_block_param: PlotBlockParam
    plot_drill_param: PlotDrillParam
    plot_gird_param: PlotGirdParam
    plot_hatch_param: Dict[str, Any] = field(default_factory=lambda: {"enable": False})
    plot_project_param: PlotProjectParam = field(default_factory=PlotProjectParam)
    uuid: str = ""

    def to_dict(self) -> Dict[str, Any]:
        """转换为嵌套字典,支持JSON序列化"""
        def dc_to_dict(obj):
            if isinstance(obj, (int, float, str, bool)):
                return obj
            elif hasattr(obj, '__dataclass_fields__'):
                return {k: dc_to_dict(getattr(obj, k)) for k in obj.__dataclass_fields__}
            elif isinstance(obj, list):
                return [dc_to_dict(item) for item in obj]
            elif isinstance(obj, dict):
                return {k: dc_to_dict(v) for k, v in obj.items()}
            return obj
        return dc_to_dict(self)

to_dict()

转换为嵌套字典,支持JSON序列化

Source code in dimine_python_sdk\lib\io\models.py
168
169
170
171
172
173
174
175
176
177
178
179
180
def to_dict(self) -> Dict[str, Any]:
    """转换为嵌套字典,支持JSON序列化"""
    def dc_to_dict(obj):
        if isinstance(obj, (int, float, str, bool)):
            return obj
        elif hasattr(obj, '__dataclass_fields__'):
            return {k: dc_to_dict(getattr(obj, k)) for k in obj.__dataclass_fields__}
        elif isinstance(obj, list):
            return [dc_to_dict(item) for item in obj]
        elif isinstance(obj, dict):
            return {k: dc_to_dict(v) for k, v in obj.items()}
        return obj
    return dc_to_dict(self)