geometry
Native Layer v2 几何与数据库实体模块
对外暴露 numpy 数组、NativeTin、NativeEntity/NativeLayer 等 Python 类型, 内部持有 C++ 对象。
NativeDatabaseHandle
数据库不透明句柄,内部持有 C++ dmDbDatabase 对象
Source code in dimine_python_sdk\lib\native\geometry.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | |
add_property(name, ptype)
添加属性定义
Source code in dimine_python_sdk\lib\native\geometry.py
773 774 775 776 777 | |
close_polyline()
闭合多段线
Source code in dimine_python_sdk\lib\native\geometry.py
779 780 781 | |
create()
classmethod
创建只读数据库
Source code in dimine_python_sdk\lib\native\geometry.py
602 603 604 605 | |
create_local()
classmethod
创建可编辑本地数据库
Source code in dimine_python_sdk\lib\native\geometry.py
607 608 609 610 | |
features()
获取所有要素定义(含属性定义清单)
Source code in dimine_python_sdk\lib\native\geometry.py
681 682 683 684 685 686 687 688 689 690 691 692 693 | |
get_active_layer()
获取当前激活图层
Source code in dimine_python_sdk\lib\native\geometry.py
648 649 650 651 652 653 | |
get_feature(name)
按名称获取要素
Source code in dimine_python_sdk\lib\native\geometry.py
667 668 669 670 671 672 673 674 675 | |
get_layer(index)
通过索引获取图层
Source code in dimine_python_sdk\lib\native\geometry.py
634 635 636 637 638 639 640 641 | |
insert_feature(name)
插入新要素
Source code in dimine_python_sdk\lib\native\geometry.py
655 656 657 658 659 660 661 | |
insert_layer(name)
插入新图层
Source code in dimine_python_sdk\lib\native\geometry.py
643 644 645 646 | |
load(file_path)
加载 DMF 文件
Source code in dimine_python_sdk\lib\native\geometry.py
612 613 614 615 | |
save(file_path=None)
保存 DMF 文件
Source code in dimine_python_sdk\lib\native\geometry.py
617 618 619 620 621 622 623 624 | |
set_active_feature(name)
设置当前激活要素
Source code in dimine_python_sdk\lib\native\geometry.py
677 678 679 | |
set_color(rgb)
设置当前颜色
Source code in dimine_python_sdk\lib\native\geometry.py
783 784 785 786 | |
set_features(features)
注册所有要素及其属性定义。
以 features 作为属性定义清单,直接写入各要素的 CDataTable;
不再依赖实体反向推导,也不调用 add_property。
Source code in dimine_python_sdk\lib\native\geometry.py
695 696 697 698 699 700 701 702 703 704 705 | |
set_file_name(file_path)
设置文件路径
Source code in dimine_python_sdk\lib\native\geometry.py
626 627 628 | |
NativeEntityHandle
实体不透明句柄,内部持有 C++ dmDbEntity 对象。
警告:OpenNextEntity() 返回的实体对象通常是图层查询游标的临时引用。 当需要遍历图层中多个实体时,应使用 NativeLayerHandle.iter_entities(), 该函数会在进入下一次 OpenNextEntity() 之前把数据完整拷贝到 Python 对象。
Source code in dimine_python_sdk\lib\native\geometry.py
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 347 348 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 | |
att_record()
读取实体属性记录
返回 (所属要素名称, 属性列表)。
属性列的数据类型通过 NativeDataTableHandle.field_definitions()
调用 Get_Field_Type 获取,不再从首行记录推断;实体属性记录
(record)中存放的是对应字段的真实属性值。record 仅提供
asDouble/asString 两种读取接口,字符串类用 asString,其余数值型
统一用 asDouble。
Source code in dimine_python_sdk\lib\native\geometry.py
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 347 348 349 350 351 352 353 354 355 356 357 358 | |
geometry()
读取实体几何数据
Source code in dimine_python_sdk\lib\native\geometry.py
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 | |
set_properties(properties)
将 NativeProperty 列表写入 C++ 实体属性记录。
与 att_record 互为逆过程:先获取 self._cpp_obj.GetAttRecord(),
再对记录中的每个字段调用 Set_Value 写入真实属性值。
单条属性写入失败不会中断整体写入。
Source code in dimine_python_sdk\lib\native\geometry.py
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 | |
to_model()
转换为 NativeEntity 数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
NativeLayerHandle
图层不透明句柄,内部持有 C++ dmDbLayer 对象
Source code in dimine_python_sdk\lib\native\geometry.py
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 502 503 504 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 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
insert_entities(entities)
批量插入 NativeEntity,返回实体句柄列表
Source code in dimine_python_sdk\lib\native\geometry.py
578 579 580 581 582 | |
insert_native_entity(entity)
根据 NativeEntity 数据模型插入实体,并返回实体句柄
插入几何后会通过返回的 NativeEntityHandle 设置实体名称、颜色,
并以 att_record 的反向操作将属性值写入 C++ 属性记录。
Source code in dimine_python_sdk\lib\native\geometry.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
iter_entities()
迭代图层中所有实体,返回 NativeEntity
OpenNextEntity() 返回的实体对象通常是图层查询游标的临时引用, 一旦进入下一次 OpenNextEntity(),之前的引用即可能失效。 因此这里一次性把每个实体的数据拷贝到 Python 对象,并立即释放 底层 C++ 引用后再读取下一个实体。
Source code in dimine_python_sdk\lib\native\geometry.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
to_model()
转换为 NativeLayer 数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
584 585 586 | |
create_database()
创建 C++ dmDbDatabase 对象
Source code in dimine_python_sdk\lib\native\geometry.py
793 794 795 | |
create_layer()
创建 C++ dmDbLayer 对象
Source code in dimine_python_sdk\lib\native\geometry.py
803 804 805 | |
create_line(start, end, *, name='', feature_name='', color=None, properties=None)
创建线实体数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
create_local_database()
创建可编辑本地 C++ dmDbDatabase 对象
Source code in dimine_python_sdk\lib\native\geometry.py
798 799 800 | |
create_point(position, *, name='', feature_name='', color=None, properties=None)
创建点实体数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
create_polyline(points, *, name='', feature_name='', color=None, properties=None)
创建多段线实体数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
create_shell(tin, *, name='', feature_name='', color=None, properties=None)
创建 Shell 实体数据模型
Source code in dimine_python_sdk\lib\native\geometry.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
create_text(position, text, *, name='', feature_name='', color=None, properties=None)
创建文本实体数据模型(作为 NativeEntity)
Source code in dimine_python_sdk\lib\native\geometry.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
point_from_native(cpp_point)
将 C++ dmDPoint 转换为 (3,) numpy 数组
Source code in dimine_python_sdk\lib\native\geometry.py
82 83 84 85 86 | |
point_to_native(point)
将 (3,) numpy 数组转换为单个 C++ dmDPoint
Source code in dimine_python_sdk\lib\native\geometry.py
76 77 78 79 | |
points_from_native(cpp_points)
将 C++ dmDPoint 列表转换为 (N, 3) numpy 数组
Source code in dimine_python_sdk\lib\native\geometry.py
89 90 91 92 93 94 95 | |
points_to_native(points)
将 (N, 3) numpy 数组转换为 C++ dmDPoint 列表
Source code in dimine_python_sdk\lib\native\geometry.py
70 71 72 73 | |
tin_from_polydata(polydata)
C++ dmPolyData -> NativeTin
Source code in dimine_python_sdk\lib\native\geometry.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
tin_to_polydata(tin)
NativeTin -> C++ dmPolyData
Source code in dimine_python_sdk\lib\native\geometry.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |