Skip to content

entity

DmDbEntity

所有实体对象都继承自该类,包括获取实体类型函数GetType、 将三维实体转换到dmPolyData对象函数ToPolyData、 将对象转换为三维实体对象函数ConvertToShell、 将对象转换为三维多段线对象函数ConvertToPolyline、 将对象转换为直线对象函数ConvertToLine、 将对象转换为点对象函数ConvertToPoint、 设置实体颜色函数SetColor、 获取实体类型名称函数GetEntityTypeName、 获取实体名称函数GetEntityName等

example:

dmf = DmDbDatabase()
db = dmf.load('E:/dassistant/tests/123.dmf')
print("获取图层数量:",dmf.get_layers_count())
act_layer = dmf.get_active_layer()

layerCount = dmf.get_layers_count()
for i in range(layerCount):
    layer = dmf.get_layer_by_index(i)
    if layer is None:
        continue

    print("图层实体数量:",layer.get_entities_count())

    layer.start_query_entity()
    entity = layer.open_next_entity()
    while entity is not None:
        nType = entity.get_type()
        #print("实体类型:",nType)
        if nType == EntityType.ETT_POLYLINE:
            print("实体类型名称:", entity.get_entity_type_name())
            polydata = entity.to_poly_data()
            print("获取多边形点集:",polydata.get_dm_points())
            print("获取多边形包围盒:",polydata.get_bounds())
        elif nType == EntityType.ETT_POINT:
            print("实体类型名称:", entity.get_entity_type_name())
            point = entity.convert_to_point().get_graph_data()
            print(type(point))
            print("获取点数据:",point)
        elif nType == EntityType.ETT_LINE:
            print("实体类型名称:", entity.get_entity_type_name())
            line = entity.convert_to_line()
            print(type(line))
            print("获取线数据:",line)
            entity.set_color(255,0,0)
        entity = layer.open_next_entity()
Source code in dimine_python_sdk\lib\types\entity.py
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
class DmDbEntity:
    """所有实体对象都继承自该类,包括获取实体类型函数GetType、
    将三维实体转换到dmPolyData对象函数ToPolyData、
    将对象转换为三维实体对象函数ConvertToShell、
    将对象转换为三维多段线对象函数ConvertToPolyline、
    将对象转换为直线对象函数ConvertToLine、
    将对象转换为点对象函数ConvertToPoint、
    设置实体颜色函数SetColor、
    获取实体类型名称函数GetEntityTypeName、
    获取实体名称函数GetEntityName等

    example:
    ```python
    dmf = DmDbDatabase()
    db = dmf.load('E:/dassistant/tests/123.dmf')
    print("获取图层数量:",dmf.get_layers_count())
    act_layer = dmf.get_active_layer()

    layerCount = dmf.get_layers_count()
    for i in range(layerCount):
        layer = dmf.get_layer_by_index(i)
        if layer is None:
            continue

        print("图层实体数量:",layer.get_entities_count())

        layer.start_query_entity()
        entity = layer.open_next_entity()
        while entity is not None:
            nType = entity.get_type()
            #print("实体类型:",nType)
            if nType == EntityType.ETT_POLYLINE:
                print("实体类型名称:", entity.get_entity_type_name())
                polydata = entity.to_poly_data()
                print("获取多边形点集:",polydata.get_dm_points())
                print("获取多边形包围盒:",polydata.get_bounds())
            elif nType == EntityType.ETT_POINT:
                print("实体类型名称:", entity.get_entity_type_name())
                point = entity.convert_to_point().get_graph_data()
                print(type(point))
                print("获取点数据:",point)
            elif nType == EntityType.ETT_LINE:
                print("实体类型名称:", entity.get_entity_type_name())
                line = entity.convert_to_line()
                print(type(line))
                print("获取线数据:",line)
                entity.set_color(255,0,0)
            entity = layer.open_next_entity()
    ```
    """

    # def __init__(self):
    #     self._obj = None


    @classmethod
    def _from_obj(cls, obj):
        """
        原生DmDbEntity对象创建封装实例
        :param obj: 原生DmDbEntity对象(bind11封装后)
        :return: DmDbEntity实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

    def get_type(self) -> int:
        """
        获取实体类型编码
        :return: 实体类型的整数编码
        """
        return self._obj.GetType()

    def to_poly_data(self) -> DmPolyData:
        """
        将实体转换为多边形数据
        :return: 转换后的DmPolyData实例(需提前实现该类及_from_obj方法)
        """
        cpp_result = self._obj.ToPolyData()
        return DmPolyData._from_obj(cpp_result)

    def convert_to_shell(self) -> DmDbShell:
        """
        将实体转换为Shell对象
        :return: 转换后的DmDbShell实例
        """
        cpp_result = self._obj.ConvertToShell()
        return DmDbShell._from_obj(cpp_result)

    def convert_to_polyline(self) -> DmDbPolyline:
        """
        将实体转换为多段线对象
        :return: 转换后的DmDbPolyline实例
        """
        cpp_result = self._obj.ConvertToPolyline()
        return DmDbPolyline._from_obj(cpp_result)

    def convert_to_line(self) -> DmDbLine:
        """
        将实体转换为线对象
        :return: 转换后的DmDbLine实例
        """
        cpp_result = self._obj.ConvertToLine()
        return DmDbLine._from_obj(cpp_result)

    def convert_to_point(self) -> DmDbPoint:
        """
        将实体转换为点对象
        :return: 转换后的DmDbPoint实例
        """
        cpp_result = self._obj.ConvertToPoint()
        return DmDbPoint._from_obj(cpp_result)

    def set_color(self, red: int, green: int, blue: int) -> None:
        """
        设置实体颜色
        :param red: 红色分量(0-255)
        :param green: 绿色分量(0-255)
        :param blue: 蓝色分量(0-255)

        example:
        ```python
        entity = DmDbEntity()
        entity.set_color(255, 0, 0)
        ```
        """
        self._obj.SetColor(red, green, blue)

    def get_entity_type_name(self) -> str:
        """
        获取实体类型名称(UTF-8编码)
        :return: 实体类型名称字符串

        example:
        ```python
        entity = DmDbEntity()
        entity_type_name = entity.get_entity_type_name()
        ```
        """
        return self._obj.GetEntityTypeName()

    def get_entity_name(self) -> str:
        """
        获取实体名称(UTF-8编码)
        :return: 实体名称字符串

        example:
        ```python
        entity = DmDbEntity()
        entity_name = entity.get_entity_name()
        ```
        """
        return self._obj.GetEntityName()

convert_to_line()

将实体转换为线对象 :return: 转换后的DmDbLine实例

Source code in dimine_python_sdk\lib\types\entity.py
446
447
448
449
450
451
452
def convert_to_line(self) -> DmDbLine:
    """
    将实体转换为线对象
    :return: 转换后的DmDbLine实例
    """
    cpp_result = self._obj.ConvertToLine()
    return DmDbLine._from_obj(cpp_result)

convert_to_point()

将实体转换为点对象 :return: 转换后的DmDbPoint实例

Source code in dimine_python_sdk\lib\types\entity.py
454
455
456
457
458
459
460
def convert_to_point(self) -> DmDbPoint:
    """
    将实体转换为点对象
    :return: 转换后的DmDbPoint实例
    """
    cpp_result = self._obj.ConvertToPoint()
    return DmDbPoint._from_obj(cpp_result)

convert_to_polyline()

将实体转换为多段线对象 :return: 转换后的DmDbPolyline实例

Source code in dimine_python_sdk\lib\types\entity.py
438
439
440
441
442
443
444
def convert_to_polyline(self) -> DmDbPolyline:
    """
    将实体转换为多段线对象
    :return: 转换后的DmDbPolyline实例
    """
    cpp_result = self._obj.ConvertToPolyline()
    return DmDbPolyline._from_obj(cpp_result)

convert_to_shell()

将实体转换为Shell对象 :return: 转换后的DmDbShell实例

Source code in dimine_python_sdk\lib\types\entity.py
430
431
432
433
434
435
436
def convert_to_shell(self) -> DmDbShell:
    """
    将实体转换为Shell对象
    :return: 转换后的DmDbShell实例
    """
    cpp_result = self._obj.ConvertToShell()
    return DmDbShell._from_obj(cpp_result)

get_entity_name()

获取实体名称(UTF-8编码) :return: 实体名称字符串

example:

entity = DmDbEntity()
entity_name = entity.get_entity_name()
Source code in dimine_python_sdk\lib\types\entity.py
490
491
492
493
494
495
496
497
498
499
500
501
def get_entity_name(self) -> str:
    """
    获取实体名称(UTF-8编码)
    :return: 实体名称字符串

    example:
    ```python
    entity = DmDbEntity()
    entity_name = entity.get_entity_name()
    ```
    """
    return self._obj.GetEntityName()

get_entity_type_name()

获取实体类型名称(UTF-8编码) :return: 实体类型名称字符串

example:

entity = DmDbEntity()
entity_type_name = entity.get_entity_type_name()
Source code in dimine_python_sdk\lib\types\entity.py
477
478
479
480
481
482
483
484
485
486
487
488
def get_entity_type_name(self) -> str:
    """
    获取实体类型名称(UTF-8编码)
    :return: 实体类型名称字符串

    example:
    ```python
    entity = DmDbEntity()
    entity_type_name = entity.get_entity_type_name()
    ```
    """
    return self._obj.GetEntityTypeName()

get_type()

获取实体类型编码 :return: 实体类型的整数编码

Source code in dimine_python_sdk\lib\types\entity.py
415
416
417
418
419
420
def get_type(self) -> int:
    """
    获取实体类型编码
    :return: 实体类型的整数编码
    """
    return self._obj.GetType()

set_color(red, green, blue)

设置实体颜色 :param red: 红色分量(0-255) :param green: 绿色分量(0-255) :param blue: 蓝色分量(0-255)

example:

entity = DmDbEntity()
entity.set_color(255, 0, 0)
Source code in dimine_python_sdk\lib\types\entity.py
462
463
464
465
466
467
468
469
470
471
472
473
474
475
def set_color(self, red: int, green: int, blue: int) -> None:
    """
    设置实体颜色
    :param red: 红色分量(0-255)
    :param green: 绿色分量(0-255)
    :param blue: 蓝色分量(0-255)

    example:
    ```python
    entity = DmDbEntity()
    entity.set_color(255, 0, 0)
    ```
    """
    self._obj.SetColor(red, green, blue)

to_poly_data()

将实体转换为多边形数据 :return: 转换后的DmPolyData实例(需提前实现该类及_from_obj方法)

Source code in dimine_python_sdk\lib\types\entity.py
422
423
424
425
426
427
428
def to_poly_data(self) -> DmPolyData:
    """
    将实体转换为多边形数据
    :return: 转换后的DmPolyData实例(需提前实现该类及_from_obj方法)
    """
    cpp_result = self._obj.ToPolyData()
    return DmPolyData._from_obj(cpp_result)

DmDbShell

shell类

Source code in dimine_python_sdk\lib\types\entity.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class DmDbShell:
    """shell类"""
    def __init__(self):
        """构造函数,初始化Shell对象"""
        self._obj = Dm.dmDbShell()

    @classmethod
    def _from_obj(cls, obj):
        """
        原生对象创建封装实例
        :param obj: 原生dmDbShell对象
        :return: DmDbShell实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

    def parse_to_json(self)->dict:
        """转换为JSON字符串
            :return  dict {"indexs":[[1,2,3]], "points":["1.0", "2.0", "3.0"]}
        """
        data = self._obj.ParseToJson()
        return json.loads(data)

__init__()

构造函数,初始化Shell对象

Source code in dimine_python_sdk\lib\types\entity.py
71
72
73
def __init__(self):
    """构造函数,初始化Shell对象"""
    self._obj = Dm.dmDbShell()

parse_to_json()

转换为JSON字符串 :return dict {"indexs":[[1,2,3]], "points":["1.0", "2.0", "3.0"]}

Source code in dimine_python_sdk\lib\types\entity.py
86
87
88
89
90
91
def parse_to_json(self)->dict:
    """转换为JSON字符串
        :return  dict {"indexs":[[1,2,3]], "points":["1.0", "2.0", "3.0"]}
    """
    data = self._obj.ParseToJson()
    return json.loads(data)

DmDbWorkPlane

Source code in dimine_python_sdk\lib\types\entity.py
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
class DmDbWorkPlane:
    def __init__(self):
        """
        构造工作平面
        """
        self._obj = Dm.dmDbWorkPlane()

    def set_normal(self, normal: DmDPoint) -> None:
        """设置法向量"""
        self._obj.SetNormal(normal._obj)

    def set_origin(self, origin: DmDPoint) -> None:
        """设置原点"""
        self._obj.SetOrigin(origin._obj)

    def set_x_axis(self, x_axis: DmDPoint) -> None:
        """设置X轴方向"""
        self._obj.SetXAxis(x_axis._obj)

    def set_y_axis(self, y_axis: DmDPoint) -> None:
        """设置Y轴方向"""
        self._obj.SetYAxis(y_axis._obj)

    @classmethod
    def _from_obj(cls, obj):
        """
        原生dmDbWorkPlane对象创建封装实例
        :param obj: 原生dmDbWorkPlane对象(bind11封装后)
        :return: DmDbWorkPlane实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

__init__()

构造工作平面

Source code in dimine_python_sdk\lib\types\entity.py
506
507
508
509
510
def __init__(self):
    """
    构造工作平面
    """
    self._obj = Dm.dmDbWorkPlane()

set_normal(normal)

设置法向量

Source code in dimine_python_sdk\lib\types\entity.py
512
513
514
def set_normal(self, normal: DmDPoint) -> None:
    """设置法向量"""
    self._obj.SetNormal(normal._obj)

set_origin(origin)

设置原点

Source code in dimine_python_sdk\lib\types\entity.py
516
517
518
def set_origin(self, origin: DmDPoint) -> None:
    """设置原点"""
    self._obj.SetOrigin(origin._obj)

set_x_axis(x_axis)

设置X轴方向

Source code in dimine_python_sdk\lib\types\entity.py
520
521
522
def set_x_axis(self, x_axis: DmDPoint) -> None:
    """设置X轴方向"""
    self._obj.SetXAxis(x_axis._obj)

set_y_axis(y_axis)

设置Y轴方向

Source code in dimine_python_sdk\lib\types\entity.py
524
525
526
def set_y_axis(self, y_axis: DmDPoint) -> None:
    """设置Y轴方向"""
    self._obj.SetYAxis(y_axis._obj)

DmPolyData

多边形数据类

Source code in dimine_python_sdk\lib\types\entity.py
 94
 95
 96
 97
 98
 99
100
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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
230
231
232
233
234
235
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
class DmPolyData:
    """多边形数据类"""

    def __init__(self):
        """
        构造函数:初始化多边形数据对象
        :return: None
        """
        self._obj = Dm.dmPolyData()

    # ---------------------- 基础属性获取 ----------------------
    def get_data_type(self) -> int:
        """
        获取多边形数据类型
        :return: 数据类型编码(整数)

        example:
        ```python
        poly_data = DmPolyData()
        data_type = poly_data.get_data_type()
        ```
        """
        return self._obj.GetDataType()

    def get_number_of_cells(self) -> int:
        """
        获取单元格数量
        :return: 单元格数量(整数)

        example:
        ```python
        poly_data = DmPolyData()
        num_cells = poly_data.get_number_of_cells()
        ```
        """
        return self._obj.GetNumberOfCells()

    def get_number_of_verts(self) -> int:
        """
        获取顶点数量
        :return: 顶点数量(整数)

        example:
        ```python
        poly_data = DmPolyData()
        num_verts = poly_data.get_number_of_verts()
        ```
        """
        return self._obj.GetNumberOfVerts()

    def get_number_of_lines(self) -> int:
        """
        获取线段数量
        :return: 线段数量(整数)

        example:
        ```python
        poly_data = DmPolyData()
        num_lines = poly_data.get_number_of_lines()
        ```
        """
        return self._obj.GetNumberOfLines()

    def get_number_of_polys(self) -> int:
        """
        获取多边形数量
        :return: 多边形数量(整数)

        example:
        ```python
        poly_data = DmPolyData()
        num_polys = poly_data.get_number_of_polys()
        ```
        """
        return self._obj.GetNumberOfPolys()

    def get_number_of_points(self) -> int:
        """
        获取点的总数量
        :return: 点数量(整数)

        example:
        ```python
        poly_data = DmPolyData()
        num_points = poly_data.get_number_of_points()
        ```
        """
        return self._obj.GetNumberOfPoints()

    def get_bounds(self) -> list[float]:
        """
        获取数据的包围盒
        :return: 包围盒坐标列表 [min_x, max_x, min_y, max_y, min_z, max_z]

        example:
        ```python
        poly_data = DmPolyData()
        bounds = poly_data.get_bounds()
        ```
        """
        return self._obj.GetBounds()

    # ---------------------- 单元格插入 ----------------------
    def insert_next_vert_cell(self, point_indexes: list[int]) -> None:
        """
        插入顶点单元格
        :param point_indexes: 点索引列表(整数列表)

        example:
        ```python
        poly_data = DmPolyData()
        poly_data.insert_next_vert_cell([0, 1, 2])
        ```
        """
        self._obj.InsertNextVertCell(point_indexes)

    def insert_next_line_cell(self, point_indexes: list[int]) -> None:
        """
        插入线段单元格
        :param point_indexes: 点索引列表(整数列表)

        example:
        ```python
        poly_data = DmPolyData()
        poly_data.insert_next_line_cell([0, 1, 2])
        ```
        """
        self._obj.InsertNextLineCell(point_indexes)

    def insert_next_poly_cell(self, point_indexes: list[int]) -> None:
        """
        插入多边形单元格
        :param point_indexes: 点索引列表(整数列表)

        example:
        ```python
        poly_data = DmPolyData()
        poly_data.insert_next_poly_cell([0, 1, 2])
        ```
        """
        self._obj.InsertNextPolyCell(point_indexes)

    # ---------------------- 点操作 ----------------------
    def insert_unique_point(self, point: DmDPoint) -> int:
        """
        插入唯一的点(自动去重)
        :param point: 待插入的点(DmDPoint实例)
        :return: 点的唯一ID(整数)

        example:
        ```python
        poly_data = DmPolyData()
        point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
        ```
        """
        return self._obj.InsertUniquePoint(point._obj)

    def get_point(self, point_id: int) -> DmDPoint:
        """
        根据ID获取点
        :param point_id: 点的唯一ID(整数)
        :return: 对应的DmDPoint实例

        example:
        ```python
        poly_data = DmPolyData()
        point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
        point = poly_data.get_point(point_id)
        ```
        """
        cpp_point = self._obj.GetPoint(point_id)
        return DmDPoint._from_obj(cpp_point)

    def set_dm_points(self, points: DmPoints) -> None:
        """
        设置关联的点集合
        :param points: DmPoints实例

        example:
        ```python
        poly_data = DmPolyData()
        points = DmPoints()
        poly_data.set_dm_points(points)
        ```
        """
        self._obj.SetDmPoints(points._obj)

    def get_dm_points(self) -> DmPoints:
        """
        获取关联的点集合
        :return: DmPoints实例

        example:
        ```python
        poly_data = DmPolyData()
        points = DmPoints()
        poly_data.set_dm_points(points)
        dm_points = poly_data.get_dm_points()
        ```
        """
        cpp_points = self._obj.GetDmPoints()
        return DmPoints._from_obj(cpp_points)

    # ---------------------- 多边形数据获取 ----------------------
    def get_poly_cell(self, cell_index: int) -> list[int]:
        """
        获取指定索引的多边形单元格的点索引
        :param cell_index: 单元格索引(整数)
        :return: 点索引列表(整数列表)

        example:
        ```python
        poly_data = DmPolyData()
        cell_index = 0
        point_indexes = poly_data.get_poly_cell(cell_index)
        ```
        """
        return self._obj.GetPolyCell(cell_index)

    # ---------------------- 提取多段线 ----------------------
    def extract_polylines(self) -> list[DmDbPolyline]:
        """
        提取多段线实体
        :return: 多段线列表,每个元素为DmDbPolyline实例

        example:
        ```python
        poly_data = DmPolyData()
        polylines = poly_data.extract_polylines()
        ```
        """
        cpp_list = self._obj.ExtractPolylines()
        return [DmDbPolyline._from_obj(item) for item in cpp_list]

    # ---------------------- 字符串表示 ----------------------
    def __repr__(self) -> str:
        """
        字符串表示
        :return: 多边形数据的标准字符串表示
        """
        return self._obj.__repr__()

    # ---------------------- 桥接方法 ----------------------
    @classmethod
    def _from_obj(cls, obj):
        """
        原生对象创建封装实例
        :param obj: 原生dmPolyData对象
        :return: DmPolyData实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

__init__()

构造函数:初始化多边形数据对象 :return: None

Source code in dimine_python_sdk\lib\types\entity.py
 97
 98
 99
100
101
102
def __init__(self):
    """
    构造函数:初始化多边形数据对象
    :return: None
    """
    self._obj = Dm.dmPolyData()

__repr__()

字符串表示 :return: 多边形数据的标准字符串表示

Source code in dimine_python_sdk\lib\types\entity.py
329
330
331
332
333
334
def __repr__(self) -> str:
    """
    字符串表示
    :return: 多边形数据的标准字符串表示
    """
    return self._obj.__repr__()

extract_polylines()

提取多段线实体 :return: 多段线列表,每个元素为DmDbPolyline实例

example:

poly_data = DmPolyData()
polylines = poly_data.extract_polylines()
Source code in dimine_python_sdk\lib\types\entity.py
314
315
316
317
318
319
320
321
322
323
324
325
326
def extract_polylines(self) -> list[DmDbPolyline]:
    """
    提取多段线实体
    :return: 多段线列表,每个元素为DmDbPolyline实例

    example:
    ```python
    poly_data = DmPolyData()
    polylines = poly_data.extract_polylines()
    ```
    """
    cpp_list = self._obj.ExtractPolylines()
    return [DmDbPolyline._from_obj(item) for item in cpp_list]

get_bounds()

获取数据的包围盒 :return: 包围盒坐标列表 [min_x, max_x, min_y, max_y, min_z, max_z]

example:

poly_data = DmPolyData()
bounds = poly_data.get_bounds()
Source code in dimine_python_sdk\lib\types\entity.py
183
184
185
186
187
188
189
190
191
192
193
194
def get_bounds(self) -> list[float]:
    """
    获取数据的包围盒
    :return: 包围盒坐标列表 [min_x, max_x, min_y, max_y, min_z, max_z]

    example:
    ```python
    poly_data = DmPolyData()
    bounds = poly_data.get_bounds()
    ```
    """
    return self._obj.GetBounds()

get_data_type()

获取多边形数据类型 :return: 数据类型编码(整数)

example:

poly_data = DmPolyData()
data_type = poly_data.get_data_type()
Source code in dimine_python_sdk\lib\types\entity.py
105
106
107
108
109
110
111
112
113
114
115
116
def get_data_type(self) -> int:
    """
    获取多边形数据类型
    :return: 数据类型编码(整数)

    example:
    ```python
    poly_data = DmPolyData()
    data_type = poly_data.get_data_type()
    ```
    """
    return self._obj.GetDataType()

get_dm_points()

获取关联的点集合 :return: DmPoints实例

example:

poly_data = DmPolyData()
points = DmPoints()
poly_data.set_dm_points(points)
dm_points = poly_data.get_dm_points()
Source code in dimine_python_sdk\lib\types\entity.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
def get_dm_points(self) -> DmPoints:
    """
    获取关联的点集合
    :return: DmPoints实例

    example:
    ```python
    poly_data = DmPolyData()
    points = DmPoints()
    poly_data.set_dm_points(points)
    dm_points = poly_data.get_dm_points()
    ```
    """
    cpp_points = self._obj.GetDmPoints()
    return DmPoints._from_obj(cpp_points)

get_number_of_cells()

获取单元格数量 :return: 单元格数量(整数)

example:

poly_data = DmPolyData()
num_cells = poly_data.get_number_of_cells()
Source code in dimine_python_sdk\lib\types\entity.py
118
119
120
121
122
123
124
125
126
127
128
129
def get_number_of_cells(self) -> int:
    """
    获取单元格数量
    :return: 单元格数量(整数)

    example:
    ```python
    poly_data = DmPolyData()
    num_cells = poly_data.get_number_of_cells()
    ```
    """
    return self._obj.GetNumberOfCells()

get_number_of_lines()

获取线段数量 :return: 线段数量(整数)

example:

poly_data = DmPolyData()
num_lines = poly_data.get_number_of_lines()
Source code in dimine_python_sdk\lib\types\entity.py
144
145
146
147
148
149
150
151
152
153
154
155
def get_number_of_lines(self) -> int:
    """
    获取线段数量
    :return: 线段数量(整数)

    example:
    ```python
    poly_data = DmPolyData()
    num_lines = poly_data.get_number_of_lines()
    ```
    """
    return self._obj.GetNumberOfLines()

get_number_of_points()

获取点的总数量 :return: 点数量(整数)

example:

poly_data = DmPolyData()
num_points = poly_data.get_number_of_points()
Source code in dimine_python_sdk\lib\types\entity.py
170
171
172
173
174
175
176
177
178
179
180
181
def get_number_of_points(self) -> int:
    """
    获取点的总数量
    :return: 点数量(整数)

    example:
    ```python
    poly_data = DmPolyData()
    num_points = poly_data.get_number_of_points()
    ```
    """
    return self._obj.GetNumberOfPoints()

get_number_of_polys()

获取多边形数量 :return: 多边形数量(整数)

example:

poly_data = DmPolyData()
num_polys = poly_data.get_number_of_polys()
Source code in dimine_python_sdk\lib\types\entity.py
157
158
159
160
161
162
163
164
165
166
167
168
def get_number_of_polys(self) -> int:
    """
    获取多边形数量
    :return: 多边形数量(整数)

    example:
    ```python
    poly_data = DmPolyData()
    num_polys = poly_data.get_number_of_polys()
    ```
    """
    return self._obj.GetNumberOfPolys()

get_number_of_verts()

获取顶点数量 :return: 顶点数量(整数)

example:

poly_data = DmPolyData()
num_verts = poly_data.get_number_of_verts()
Source code in dimine_python_sdk\lib\types\entity.py
131
132
133
134
135
136
137
138
139
140
141
142
def get_number_of_verts(self) -> int:
    """
    获取顶点数量
    :return: 顶点数量(整数)

    example:
    ```python
    poly_data = DmPolyData()
    num_verts = poly_data.get_number_of_verts()
    ```
    """
    return self._obj.GetNumberOfVerts()

get_point(point_id)

根据ID获取点 :param point_id: 点的唯一ID(整数) :return: 对应的DmDPoint实例

example:

poly_data = DmPolyData()
point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
point = poly_data.get_point(point_id)
Source code in dimine_python_sdk\lib\types\entity.py
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
def get_point(self, point_id: int) -> DmDPoint:
    """
    根据ID获取点
    :param point_id: 点的唯一ID(整数)
    :return: 对应的DmDPoint实例

    example:
    ```python
    poly_data = DmPolyData()
    point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
    point = poly_data.get_point(point_id)
    ```
    """
    cpp_point = self._obj.GetPoint(point_id)
    return DmDPoint._from_obj(cpp_point)

get_poly_cell(cell_index)

获取指定索引的多边形单元格的点索引 :param cell_index: 单元格索引(整数) :return: 点索引列表(整数列表)

example:

poly_data = DmPolyData()
cell_index = 0
point_indexes = poly_data.get_poly_cell(cell_index)
Source code in dimine_python_sdk\lib\types\entity.py
298
299
300
301
302
303
304
305
306
307
308
309
310
311
def get_poly_cell(self, cell_index: int) -> list[int]:
    """
    获取指定索引的多边形单元格的点索引
    :param cell_index: 单元格索引(整数)
    :return: 点索引列表(整数列表)

    example:
    ```python
    poly_data = DmPolyData()
    cell_index = 0
    point_indexes = poly_data.get_poly_cell(cell_index)
    ```
    """
    return self._obj.GetPolyCell(cell_index)

insert_next_line_cell(point_indexes)

插入线段单元格 :param point_indexes: 点索引列表(整数列表)

example:

poly_data = DmPolyData()
poly_data.insert_next_line_cell([0, 1, 2])
Source code in dimine_python_sdk\lib\types\entity.py
210
211
212
213
214
215
216
217
218
219
220
221
def insert_next_line_cell(self, point_indexes: list[int]) -> None:
    """
    插入线段单元格
    :param point_indexes: 点索引列表(整数列表)

    example:
    ```python
    poly_data = DmPolyData()
    poly_data.insert_next_line_cell([0, 1, 2])
    ```
    """
    self._obj.InsertNextLineCell(point_indexes)

insert_next_poly_cell(point_indexes)

插入多边形单元格 :param point_indexes: 点索引列表(整数列表)

example:

poly_data = DmPolyData()
poly_data.insert_next_poly_cell([0, 1, 2])
Source code in dimine_python_sdk\lib\types\entity.py
223
224
225
226
227
228
229
230
231
232
233
234
def insert_next_poly_cell(self, point_indexes: list[int]) -> None:
    """
    插入多边形单元格
    :param point_indexes: 点索引列表(整数列表)

    example:
    ```python
    poly_data = DmPolyData()
    poly_data.insert_next_poly_cell([0, 1, 2])
    ```
    """
    self._obj.InsertNextPolyCell(point_indexes)

insert_next_vert_cell(point_indexes)

插入顶点单元格 :param point_indexes: 点索引列表(整数列表)

example:

poly_data = DmPolyData()
poly_data.insert_next_vert_cell([0, 1, 2])
Source code in dimine_python_sdk\lib\types\entity.py
197
198
199
200
201
202
203
204
205
206
207
208
def insert_next_vert_cell(self, point_indexes: list[int]) -> None:
    """
    插入顶点单元格
    :param point_indexes: 点索引列表(整数列表)

    example:
    ```python
    poly_data = DmPolyData()
    poly_data.insert_next_vert_cell([0, 1, 2])
    ```
    """
    self._obj.InsertNextVertCell(point_indexes)

insert_unique_point(point)

插入唯一的点(自动去重) :param point: 待插入的点(DmDPoint实例) :return: 点的唯一ID(整数)

example:

poly_data = DmPolyData()
point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
Source code in dimine_python_sdk\lib\types\entity.py
237
238
239
240
241
242
243
244
245
246
247
248
249
def insert_unique_point(self, point: DmDPoint) -> int:
    """
    插入唯一的点(自动去重)
    :param point: 待插入的点(DmDPoint实例)
    :return: 点的唯一ID(整数)

    example:
    ```python
    poly_data = DmPolyData()
    point_id = poly_data.insert_unique_point(DmDPoint(0.0, 0.0, 0.0))
    ```
    """
    return self._obj.InsertUniquePoint(point._obj)

set_dm_points(points)

设置关联的点集合 :param points: DmPoints实例

example:

poly_data = DmPolyData()
points = DmPoints()
poly_data.set_dm_points(points)
Source code in dimine_python_sdk\lib\types\entity.py
267
268
269
270
271
272
273
274
275
276
277
278
279
def set_dm_points(self, points: DmPoints) -> None:
    """
    设置关联的点集合
    :param points: DmPoints实例

    example:
    ```python
    poly_data = DmPolyData()
    points = DmPoints()
    poly_data.set_dm_points(points)
    ```
    """
    self._obj.SetDmPoints(points._obj)

!!! warning "模块边界调整" 以下类/函数已迁移到 dimine_python_sdk.lib.db,旧导入路径仍保留向后兼容,但会触发 DeprecationWarning

| 旧路径 | 新路径 |
|--------|--------|
| `lib.types.entity.DmDbDatabase` | `lib.db.database.DmDbDatabase` |
| `lib.types.entity.DmDbLayer` | `lib.db.database.DmDbLayer` |
| `lib.types.entity.DmDataTable` | `lib.db.datatable.DmDataTable` |
| `lib.types.entity.DmDataTableRecord` | `lib.db.datatable.DmDataTableRecord` |
| `lib.types.entity.data_database_conn` | `lib.db.database.data_database_conn` |
| `lib.types.entity.data_table_conn` | `lib.db.datatable.data_table_conn` |