Skip to content

models

AnnotatinoStyleParam

Bases: ParamModel

注释样式参数(保留历史拼写)

Source code in dimine_python_sdk\lib\io\models.py
90
91
92
93
94
95
96
97
98
class AnnotatinoStyleParam(ParamModel):
    """注释样式参数(保留历史拼写)"""

    annotation_position: float = 0.0
    style_bottom: str = ""
    style_left: str = ""
    style_right: str = ""
    style_top: str = ""
    text_size: float = 0.5

BlockHatch

Bases: ParamModel

块填充参数

Source code in dimine_python_sdk\lib\io\models.py
40
41
42
43
44
45
46
class BlockHatch(ParamModel):
    """块填充参数"""

    angle: float
    block_name: str
    color: int
    ratio: float

DmfEntityType

Bases: IntEnum

DMF 实体类型枚举,与 C++ EntityType 一致

Source code in dimine_python_sdk\lib\io\models.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
class DmfEntityType(IntEnum):
    """DMF 实体类型枚举,与 C++ EntityType 一致"""

    UNKNOWN = -1
    POINT = 0
    LINE = 1
    POLYLINE = 2
    SHELL = 3
    TEXT = 4
    ARC = 5
    CIRCLE = 6
    ELLIPSE = 7
    SPLINE = 8
    POLYGON = 9
    ANNOTATION = 10
    SPHERE = 11
    UGRID = 12
    WORKPLANE = 13
    NET_NODE = 15
    NET_EDGE = 16
    MODEL = 17
    COMPLEX = 18
    POLYLINE_2D = 19
    LWPOLYLINE = 20
    BLOCK = 21
    MBLOCK = 22
    HATCH = 23
    MESH = 34
    CUSTOM_START = 100

DmfFeature

Bases: FeatureInfo

DmfFile 使用的要素定义(名称 + 属性列表)

Source code in dimine_python_sdk\lib\io\models.py
173
174
175
class DmfFeature(FeatureInfo):
    """DmfFile 使用的要素定义(名称 + 属性列表)"""
    pass

DmfLayer

Bases: LayerInfo

DMF 图层,继承自 LayerInfo,附加实体列表和插入方法

Source code in dimine_python_sdk\lib\io\models.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
class DmfLayer(LayerInfo):
    """DMF 图层,继承自 ``LayerInfo``,附加实体列表和插入方法"""

    model_config = {"arbitrary_types_allowed": True, "frozen": False}

    entities: List[DmfEntity] = Field(default_factory=list, description="实体列表")

    @property
    def entity_count(self) -> int:
        """实体数量(与 ``entities`` 实时同步)"""
        return len(self.entities)

    # ------------------------------------------------------------------
    # 实体插入(直接操作内存模型)
    # ------------------------------------------------------------------

    def insert_point(self, position: np.ndarray, *, name: str = "") -> None:
        """向本图层插入点实体"""
        from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

        pt = np.asarray(position, dtype=np.float64).ravel()
        if pt.shape[0] < 3:
            raise DmfInsertError(f"点坐标至少需要3个分量,当前: {pt.shape[0]}")
        self.entities.append(Point(feature=name, geometry=pt[:3].astype(np.float32)))

    def insert_line(self, start: np.ndarray, end: np.ndarray, *, name: str = "") -> None:
        """向本图层插入直线"""
        from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

        s = np.asarray(start, dtype=np.float64).ravel()
        e = np.asarray(end, dtype=np.float64).ravel()
        if s.shape[0] < 3 or e.shape[0] < 3:
            raise DmfInsertError("线端点至少需要3个分量")

        coords = np.array([s[:3], e[:3]], dtype=np.float32)
        self.entities.append(Line(feature=name, geometry=coords))

    def insert_polyline(self, points: np.ndarray, *, name: str = "") -> None:
        """向本图层插入多段线"""
        from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

        pts = np.asarray(points, dtype=np.float64)
        if pts.ndim == 1:
            pts = pts.reshape(1, -1)
        if pts.shape[1] < 3:
            raise DmfInsertError(f"多段线顶点至少需要3个分量,当前: {pts.shape[1]}")

        coords = pts[:, :3].astype(np.float32)
        self.entities.append(Line(feature=name, geometry=coords))

    def insert_shell(self, points: np.ndarray, faces: np.ndarray, *, name: str = "") -> None:
        """向本图层插入三维实体(Shell)"""
        from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

        pts = np.asarray(points, dtype=np.float64)
        if pts.ndim == 1:
            pts = pts.reshape(1, -1)
        if pts.shape[1] < 3:
            raise DmfInsertError(f"Shell 顶点至少需要3个分量,当前: {pts.shape[1]}")

        fcs = np.asarray(faces, dtype=np.int32)
        if fcs.ndim == 1:
            fcs = fcs.reshape(1, -1)

        tin = TINGeometry(points=pts[:, :3], faces=fcs)
        self.entities.append(Shell(feature=name, geometry=tin))

    def insert_text(self, position: np.ndarray, text: str, *, name: str = "") -> None:
        """向本图层插入文本标注"""
        from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

        pos = np.asarray(position, dtype=np.float64).ravel()
        if pos.shape[0] < 3:
            raise DmfInsertError(f"文本位置至少需要3个分量,当前: {pos.shape[0]}")

        self.entities.append(TextInfo(feature=name, text=text, position=pos[:3].tolist()))

entity_count property

实体数量(与 entities 实时同步)

insert_line(start, end, *, name='')

向本图层插入直线

Source code in dimine_python_sdk\lib\io\models.py
261
262
263
264
265
266
267
268
269
270
271
def insert_line(self, start: np.ndarray, end: np.ndarray, *, name: str = "") -> None:
    """向本图层插入直线"""
    from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

    s = np.asarray(start, dtype=np.float64).ravel()
    e = np.asarray(end, dtype=np.float64).ravel()
    if s.shape[0] < 3 or e.shape[0] < 3:
        raise DmfInsertError("线端点至少需要3个分量")

    coords = np.array([s[:3], e[:3]], dtype=np.float32)
    self.entities.append(Line(feature=name, geometry=coords))

insert_point(position, *, name='')

向本图层插入点实体

Source code in dimine_python_sdk\lib\io\models.py
252
253
254
255
256
257
258
259
def insert_point(self, position: np.ndarray, *, name: str = "") -> None:
    """向本图层插入点实体"""
    from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

    pt = np.asarray(position, dtype=np.float64).ravel()
    if pt.shape[0] < 3:
        raise DmfInsertError(f"点坐标至少需要3个分量,当前: {pt.shape[0]}")
    self.entities.append(Point(feature=name, geometry=pt[:3].astype(np.float32)))

insert_polyline(points, *, name='')

向本图层插入多段线

Source code in dimine_python_sdk\lib\io\models.py
273
274
275
276
277
278
279
280
281
282
283
284
def insert_polyline(self, points: np.ndarray, *, name: str = "") -> None:
    """向本图层插入多段线"""
    from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

    pts = np.asarray(points, dtype=np.float64)
    if pts.ndim == 1:
        pts = pts.reshape(1, -1)
    if pts.shape[1] < 3:
        raise DmfInsertError(f"多段线顶点至少需要3个分量,当前: {pts.shape[1]}")

    coords = pts[:, :3].astype(np.float32)
    self.entities.append(Line(feature=name, geometry=coords))

insert_shell(points, faces, *, name='')

向本图层插入三维实体(Shell)

Source code in dimine_python_sdk\lib\io\models.py
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
def insert_shell(self, points: np.ndarray, faces: np.ndarray, *, name: str = "") -> None:
    """向本图层插入三维实体(Shell)"""
    from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

    pts = np.asarray(points, dtype=np.float64)
    if pts.ndim == 1:
        pts = pts.reshape(1, -1)
    if pts.shape[1] < 3:
        raise DmfInsertError(f"Shell 顶点至少需要3个分量,当前: {pts.shape[1]}")

    fcs = np.asarray(faces, dtype=np.int32)
    if fcs.ndim == 1:
        fcs = fcs.reshape(1, -1)

    tin = TINGeometry(points=pts[:, :3], faces=fcs)
    self.entities.append(Shell(feature=name, geometry=tin))

insert_text(position, text, *, name='')

向本图层插入文本标注

Source code in dimine_python_sdk\lib\io\models.py
303
304
305
306
307
308
309
310
311
def insert_text(self, position: np.ndarray, text: str, *, name: str = "") -> None:
    """向本图层插入文本标注"""
    from dimine_python_sdk.lib.io.dmf_file import DmfInsertError

    pos = np.asarray(position, dtype=np.float64).ravel()
    if pos.shape[0] < 3:
        raise DmfInsertError(f"文本位置至少需要3个分量,当前: {pos.shape[0]}")

    self.entities.append(TextInfo(feature=name, text=text, position=pos[:3].tolist()))

LayoutParam

Bases: ParamModel

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

Source code in dimine_python_sdk\lib\io\models.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class LayoutParam(ParamModel):
    """包含原点坐标、法向量、坐标轴、厚度等核心布局参数"""

    origin_x: float = Field(..., description="原点X坐标")
    origin_y: float = Field(..., description="原点Y坐标")
    origin_z: float = Field(..., description="原点Z坐标")

    normal_x: float = Field(..., description="法向量X分量")
    normal_y: float = Field(..., description="法向量Y分量")
    normal_z: float = Field(..., description="法向量Z分量")

    x_axis_x: float = Field(..., description="X轴向量X分量")
    x_axis_y: float = Field(..., description="X轴向量Y分量")
    x_axis_z: float = Field(..., description="X轴向量Z分量")

    y_axis_x: float = Field(..., description="Y轴向量X分量")
    y_axis_y: float = Field(..., description="Y轴向量Y分量")
    y_axis_z: float = Field(..., description="Y轴向量Z分量")

    forward_thickness: float = Field(..., description="正向厚度")
    reverse_thickness: float = Field(..., description="反向厚度")

ParamModel

Bases: BaseModel

参数模型基类,提供 model_dump 的 to_dict 别名以兼容旧代码

Source code in dimine_python_sdk\lib\_base.py
15
16
17
18
19
20
21
class ParamModel(BaseModel):
    """参数模型基类,提供 model_dump 的 to_dict 别名以兼容旧代码"""

    model_config = ConfigDict(populate_by_name=True)

    def to_dict(self) -> Dict[str, Any]:
        return self.model_dump(by_alias=True)

PatternHatch

Bases: ParamModel

图案填充参数

Source code in dimine_python_sdk\lib\io\models.py
49
50
51
52
53
54
55
56
class PatternHatch(ParamModel):
    """图案填充参数"""

    angle: float
    backcolor: int
    color: int
    pattern_name: str
    ratio: float

PlotBlockParam

Bases: ParamModel

块参数

Source code in dimine_python_sdk\lib\io\models.py
82
83
84
85
86
87
class PlotBlockParam(ParamModel):
    """块参数"""

    display_mode: int
    enable: bool
    shrinkage_coefficient: float

PlotDrillParam

Bases: ParamModel

钻孔参数

Source code in dimine_python_sdk\lib\io\models.py
101
102
103
104
105
106
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
class PlotDrillParam(ParamModel):
    """钻孔参数"""

    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

Bases: ParamModel

网格参数(保留历史拼写 Gird)

Source code in dimine_python_sdk\lib\io\models.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
class PlotGirdParam(ParamModel):
    """网格参数(保留历史拼写 Gird)"""

    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

Bases: ParamModel

项目参数集合

Source code in dimine_python_sdk\lib\io\models.py
74
75
76
77
78
79
class PlotProjectParam(ParamModel):
    """项目参数集合"""

    enable: bool
    file_project_param: List[ProjectHatchItem] = Field(default_factory=list)
    type: int = 0

ProjectHatchItem

Bases: ParamModel

单个项目的 Hatch 参数

Source code in dimine_python_sdk\lib\io\models.py
59
60
61
62
63
64
65
66
67
68
69
70
71
class ProjectHatchItem(ParamModel):
    """单个项目的 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

Bases: ParamModel

主配置参数类

Source code in dimine_python_sdk\lib\io\models.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
class SetupParams(ParamModel):
    """主配置参数类"""

    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序列化"""
        return self.model_dump()

to_dict()

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

Source code in dimine_python_sdk\lib\io\models.py
164
165
166
def to_dict(self) -> Dict[str, Any]:
    """转换为嵌套字典,支持JSON序列化"""
    return self.model_dump()