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 | |
convert_to_line()
将实体转换为线对象 :return: 转换后的DmDbLine实例
Source code in dimine_python_sdk\lib\types\entity.py
446 447 448 449 450 451 452 | |
convert_to_point()
将实体转换为点对象 :return: 转换后的DmDbPoint实例
Source code in dimine_python_sdk\lib\types\entity.py
454 455 456 457 458 459 460 | |
convert_to_polyline()
将实体转换为多段线对象 :return: 转换后的DmDbPolyline实例
Source code in dimine_python_sdk\lib\types\entity.py
438 439 440 441 442 443 444 | |
convert_to_shell()
将实体转换为Shell对象 :return: 转换后的DmDbShell实例
Source code in dimine_python_sdk\lib\types\entity.py
430 431 432 433 434 435 436 | |
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 | |
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 | |
get_type()
获取实体类型编码 :return: 实体类型的整数编码
Source code in dimine_python_sdk\lib\types\entity.py
415 416 417 418 419 420 | |
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 | |
to_poly_data()
将实体转换为多边形数据 :return: 转换后的DmPolyData实例(需提前实现该类及_from_obj方法)
Source code in dimine_python_sdk\lib\types\entity.py
422 423 424 425 426 427 428 | |
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 | |
__init__()
构造函数,初始化Shell对象
Source code in dimine_python_sdk\lib\types\entity.py
71 72 73 | |
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 | |
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 | |
__init__()
构造工作平面
Source code in dimine_python_sdk\lib\types\entity.py
506 507 508 509 510 | |
set_normal(normal)
设置法向量
Source code in dimine_python_sdk\lib\types\entity.py
512 513 514 | |
set_origin(origin)
设置原点
Source code in dimine_python_sdk\lib\types\entity.py
516 517 518 | |
set_x_axis(x_axis)
设置X轴方向
Source code in dimine_python_sdk\lib\types\entity.py
520 521 522 | |
set_y_axis(y_axis)
设置Y轴方向
Source code in dimine_python_sdk\lib\types\entity.py
524 525 526 | |
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 | |
__init__()
构造函数:初始化多边形数据对象 :return: None
Source code in dimine_python_sdk\lib\types\entity.py
97 98 99 100 101 102 | |
__repr__()
字符串表示 :return: 多边形数据的标准字符串表示
Source code in dimine_python_sdk\lib\types\entity.py
329 330 331 332 333 334 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
!!! 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` |