dimine-python-sdk 0.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dimine_python_sdk/__init__.py +13 -0
- dimine_python_sdk/conn/__init__.py +5 -0
- dimine_python_sdk/conn/base_conn_client.py +167 -0
- dimine_python_sdk/conn/conn_client.py +382 -0
- dimine_python_sdk/docs/guides/data_edit.md +306 -0
- dimine_python_sdk/docs/guides/data_get.md +266 -0
- dimine_python_sdk/docs/guides/data_types.md +152 -0
- dimine_python_sdk/docs/guides/features.md +271 -0
- dimine_python_sdk/docs/guides/io.md +157 -0
- dimine_python_sdk/docs/index.md +41 -0
- dimine_python_sdk/docs/quickstart.md +45 -0
- dimine_python_sdk/docs/reference/SUMMARY.md +19 -0
- dimine_python_sdk/docs/reference/conn/base_conn_client.md +3 -0
- dimine_python_sdk/docs/reference/conn/conn_client.md +3 -0
- dimine_python_sdk/docs/reference/lib/algorithm/model_func.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/file_conversion.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/models.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/project_plotting.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/block_data.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/drill_db.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/models.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/valuation.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/entity.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/line.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/point.md +3 -0
- dimine_python_sdk/docs/reference/logger.md +3 -0
- dimine_python_sdk/docs/reference/models/conn.md +3 -0
- dimine_python_sdk/docs/reference/models/errors.md +3 -0
- dimine_python_sdk/docs/reference/models/types.md +3 -0
- dimine_python_sdk/docs/summary.md +6 -0
- dimine_python_sdk/lib/__init__.py +20 -0
- dimine_python_sdk/lib/algorithm/__init__.py +1 -0
- dimine_python_sdk/lib/algorithm/model_func.py +219 -0
- dimine_python_sdk/lib/exploitation/__init__.py +0 -0
- dimine_python_sdk/lib/io/__init__.py +2 -0
- dimine_python_sdk/lib/io/file_conversion.py +143 -0
- dimine_python_sdk/lib/io/models.py +180 -0
- dimine_python_sdk/lib/io/project_plotting.py +40 -0
- dimine_python_sdk/lib/prospecting/__init__.py +3 -0
- dimine_python_sdk/lib/prospecting/block_data.py +289 -0
- dimine_python_sdk/lib/prospecting/drill_db.py +333 -0
- dimine_python_sdk/lib/prospecting/models.py +276 -0
- dimine_python_sdk/lib/prospecting/valuation.py +113 -0
- dimine_python_sdk/lib/types/__init__.py +4 -0
- dimine_python_sdk/lib/types/entity.py +957 -0
- dimine_python_sdk/lib/types/line.py +188 -0
- dimine_python_sdk/lib/types/point.py +695 -0
- dimine_python_sdk/logger.py +7 -0
- dimine_python_sdk/models/__init__.py +3 -0
- dimine_python_sdk/models/conn.py +53 -0
- dimine_python_sdk/models/errors.py +4 -0
- dimine_python_sdk/models/types.py +131 -0
- dimine_python_sdk/site/404.html +671 -0
- dimine_python_sdk/site/assets/_mkdocstrings.css +237 -0
- dimine_python_sdk/site/assets/images/favicon.png +0 -0
- dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js +16 -0
- dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js.map +7 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/tinyseg.js +206 -0
- dimine_python_sdk/site/assets/javascripts/lunr/wordcut.js +6708 -0
- dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js +42 -0
- dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js.map +7 -0
- dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css +1 -0
- dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css.map +1 -0
- dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css +1 -0
- dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css.map +1 -0
- dimine_python_sdk/site/guides/data_edit.html +1251 -0
- dimine_python_sdk/site/guides/data_get.html +1206 -0
- dimine_python_sdk/site/guides/data_types.html +1529 -0
- dimine_python_sdk/site/guides/features.html +1217 -0
- dimine_python_sdk/site/guides/io.html +1025 -0
- dimine_python_sdk/site/index.html +849 -0
- dimine_python_sdk/site/objects.inv +0 -0
- dimine_python_sdk/site/quickstart.html +859 -0
- dimine_python_sdk/site/reference/SUMMARY.html +729 -0
- dimine_python_sdk/site/reference/conn/base_conn_client.html +1295 -0
- dimine_python_sdk/site/reference/conn/conn_client.html +3551 -0
- dimine_python_sdk/site/reference/lib/algorithm/model_func.html +2162 -0
- dimine_python_sdk/site/reference/lib/io/file_conversion.html +1725 -0
- dimine_python_sdk/site/reference/lib/io/models.html +1625 -0
- dimine_python_sdk/site/reference/lib/io/project_plotting.html +984 -0
- dimine_python_sdk/site/reference/lib/prospecting/block_data.html +2455 -0
- dimine_python_sdk/site/reference/lib/prospecting/drill_db.html +2836 -0
- dimine_python_sdk/site/reference/lib/prospecting/models.html +2309 -0
- dimine_python_sdk/site/reference/lib/prospecting/valuation.html +1373 -0
- dimine_python_sdk/site/reference/lib/types/entity.html +6728 -0
- dimine_python_sdk/site/reference/lib/types/line.html +1985 -0
- dimine_python_sdk/site/reference/lib/types/point.html +3672 -0
- dimine_python_sdk/site/reference/logger.html +751 -0
- dimine_python_sdk/site/reference/models/conn.html +751 -0
- dimine_python_sdk/site/reference/models/errors.html +802 -0
- dimine_python_sdk/site/reference/models/types.html +1679 -0
- dimine_python_sdk/site/search/search_index.json +1 -0
- dimine_python_sdk/site/sitemap.xml +107 -0
- dimine_python_sdk/site/sitemap.xml.gz +0 -0
- dimine_python_sdk/site/summary.html +697 -0
- dimine_python_sdk-0.1.8.dist-info/METADATA +15 -0
- dimine_python_sdk-0.1.8.dist-info/RECORD +135 -0
- dimine_python_sdk-0.1.8.dist-info/WHEEL +5 -0
- dimine_python_sdk-0.1.8.dist-info/top_level.txt +2 -0
- tests/conn_test.py +250 -0
- tests/test_base_type.py +143 -0
- tests/ws_client.py +60 -0
- tests/ws_server.py +271 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# 数据修改
|
|
2
|
+
主要用于修改数采软件场景内的模型对象、属性、图层、文件等数据,
|
|
3
|
+
支持修改范围包括:创建、更新、删除模型对象、属性、图层、文件等
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## 1. 数采文件关闭
|
|
7
|
+
将数采软件场景下的某个打开的文件关闭
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import asyncio
|
|
11
|
+
from dimine_python_sdk.conn import open_client
|
|
12
|
+
async def main():
|
|
13
|
+
async with open_client() as client:
|
|
14
|
+
# 获取文件列表
|
|
15
|
+
files = await client.get_files()
|
|
16
|
+
# 关闭文件
|
|
17
|
+
await files[0].close()
|
|
18
|
+
|
|
19
|
+
if __name__ == '__main__':
|
|
20
|
+
asyncio.run(main())
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 2. 数采文件打开
|
|
24
|
+
将控制数采软件打开某个文件到当前场景下
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import asyncio
|
|
28
|
+
from dimine_python_sdk.conn import open_client
|
|
29
|
+
async def main():
|
|
30
|
+
async with open_client() as client:
|
|
31
|
+
file_path = "D:/test.dmf" # 支持打开多种类型文件:dmf、dmm、cad、dmb、dmd、dmo
|
|
32
|
+
file = await client.open_file(file_path)
|
|
33
|
+
print(file.name)
|
|
34
|
+
print(file.id)
|
|
35
|
+
|
|
36
|
+
if __name__ == '__main__':
|
|
37
|
+
asyncio.run(main())
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 3. 创建或更新模型
|
|
41
|
+
通过`update_or_create_geometry`方法批量创建或更新模型,如果模型已存在则更新,不存在则创建。
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import asyncio
|
|
45
|
+
import numpy as np
|
|
46
|
+
from dimine_python_sdk.conn import open_client
|
|
47
|
+
from dimine_python_sdk.models.types import Point, Line, Shell, TINGeometry
|
|
48
|
+
|
|
49
|
+
async def main():
|
|
50
|
+
async with open_client() as client:
|
|
51
|
+
# 获取当前文件的图层和要素
|
|
52
|
+
files = await client.get_files()
|
|
53
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
54
|
+
features = await client.get_features(files[len(files)-1].id)
|
|
55
|
+
|
|
56
|
+
# 准备模型数据 - 包含点、线、实体
|
|
57
|
+
geometries = [
|
|
58
|
+
# 创建点
|
|
59
|
+
Point(
|
|
60
|
+
file=files[0].id,
|
|
61
|
+
layer=layers[0].id,
|
|
62
|
+
feature=features[0].name,
|
|
63
|
+
geometry=np.array([11, 32, 44]),
|
|
64
|
+
color=[255, 0, 0] # 红色
|
|
65
|
+
),
|
|
66
|
+
# 创建线(多段线)
|
|
67
|
+
Line(
|
|
68
|
+
file=files[0].id,
|
|
69
|
+
layer=layers[0].id,
|
|
70
|
+
feature=features[0].name,
|
|
71
|
+
geometry=np.array([[11, 12, 13], [14, 25, 26]]),
|
|
72
|
+
color=[0, 255, 0] # 绿色
|
|
73
|
+
),
|
|
74
|
+
# 创建实体(三角网)
|
|
75
|
+
Shell(
|
|
76
|
+
file=files[0].id,
|
|
77
|
+
layer=layers[0].id,
|
|
78
|
+
feature=features[0].name,
|
|
79
|
+
geometry=TINGeometry(
|
|
80
|
+
points=np.array([[11, 12, 13], [14, 25, 26], [27, 28, 29]]),
|
|
81
|
+
faces=np.array([[0, 1, 2]]) # 三个点构成一个三角形面
|
|
82
|
+
),
|
|
83
|
+
color=[0, 0, 255] # 蓝色
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
# 批量创建或更新模型
|
|
88
|
+
await client.update_or_create_geometry(geometries)
|
|
89
|
+
|
|
90
|
+
if __name__ == '__main__':
|
|
91
|
+
asyncio.run(main())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 4. 创建模型(单独)
|
|
95
|
+
如果只需要创建新模型,使用`create_geometry`方法:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import asyncio
|
|
99
|
+
import numpy as np
|
|
100
|
+
from dimine_python_sdk.conn import open_client
|
|
101
|
+
from dimine_python_sdk.models.types import Point, Line, Shell, TINGeometry
|
|
102
|
+
|
|
103
|
+
async def main():
|
|
104
|
+
async with open_client() as client:
|
|
105
|
+
# 获取当前文件、图层、要素信息
|
|
106
|
+
files = await client.get_files()
|
|
107
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
108
|
+
features = await client.get_features(files[0].id)
|
|
109
|
+
|
|
110
|
+
# 创建点模型
|
|
111
|
+
point = Point(
|
|
112
|
+
file=files[0].id,
|
|
113
|
+
layer=layers[0].id,
|
|
114
|
+
feature=features[0].name,
|
|
115
|
+
geometry=np.array([0, 0, 0])
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
await client.create_geometry([point])
|
|
119
|
+
|
|
120
|
+
if __name__ == '__main__':
|
|
121
|
+
asyncio.run(main())
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 5. 更新模型(单独)
|
|
125
|
+
如果只需要更新已存在的模型,使用`update_geometry`方法:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import asyncio
|
|
129
|
+
from dimine_python_sdk.conn import open_client
|
|
130
|
+
from dimine_python_sdk.models.types import Point
|
|
131
|
+
|
|
132
|
+
async def main():
|
|
133
|
+
async with open_client() as client:
|
|
134
|
+
# 首先获取模型列表找到要更新的模型
|
|
135
|
+
files = await client.get_files()
|
|
136
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
137
|
+
geometries = await client.get_geometry(file_id=files[0].id, layer_id=layers[0].id)
|
|
138
|
+
|
|
139
|
+
# 找到第一个点模型
|
|
140
|
+
point_to_update = None
|
|
141
|
+
for geom in geometries:
|
|
142
|
+
if geom.type == "point":
|
|
143
|
+
point_to_update = geom
|
|
144
|
+
break
|
|
145
|
+
|
|
146
|
+
if point_to_update:
|
|
147
|
+
# 更新点坐标和颜色
|
|
148
|
+
point_to_update.geometry = np.array([100, 200, 300])
|
|
149
|
+
point_to_update.color = [255, 255, 0] # 黄色
|
|
150
|
+
|
|
151
|
+
await client.update_geometry([point_to_update])
|
|
152
|
+
|
|
153
|
+
if __name__ == '__main__':
|
|
154
|
+
asyncio.run(main())
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 6. 创建图层
|
|
158
|
+
|
|
159
|
+
创建新的图层:
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
import asyncio
|
|
163
|
+
from dimine_python_sdk.conn import open_client
|
|
164
|
+
|
|
165
|
+
async def main():
|
|
166
|
+
async with open_client() as client:
|
|
167
|
+
files = await client.get_files()
|
|
168
|
+
# 创建新图层
|
|
169
|
+
layer = await client.create_layer(
|
|
170
|
+
file_id=files[len(files)-1].id,
|
|
171
|
+
name="test_layer"
|
|
172
|
+
)
|
|
173
|
+
print(f"创建图层: {layer.name}, ID: {layer.id}")
|
|
174
|
+
|
|
175
|
+
if __name__ == '__main__':
|
|
176
|
+
asyncio.run(main())
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 7. 删除图层
|
|
180
|
+
|
|
181
|
+
删除指定图层:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
import asyncio
|
|
185
|
+
from dimine_python_sdk.conn import open_client
|
|
186
|
+
|
|
187
|
+
async def main():
|
|
188
|
+
async with open_client() as client:
|
|
189
|
+
files = await client.get_files()
|
|
190
|
+
# 创建测试图层
|
|
191
|
+
new_layer = await client.create_layer(
|
|
192
|
+
file_id=files[len(files)-1].id,
|
|
193
|
+
name="test_layer_to_delete"
|
|
194
|
+
)
|
|
195
|
+
# 删除图层
|
|
196
|
+
await client.delete_layer(
|
|
197
|
+
file_id=files[len(files)-1].id,
|
|
198
|
+
layer_name=new_layer.name
|
|
199
|
+
)
|
|
200
|
+
print("图层删除成功")
|
|
201
|
+
|
|
202
|
+
if __name__ == '__main__':
|
|
203
|
+
asyncio.run(main())
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 8. 更新模型
|
|
207
|
+
|
|
208
|
+
更新已存在的模型属性、颜色或几何信息:
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
import asyncio
|
|
212
|
+
from dimine_python_sdk.conn import open_client
|
|
213
|
+
|
|
214
|
+
async def main():
|
|
215
|
+
async with open_client() as client:
|
|
216
|
+
files = await client.get_files()
|
|
217
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
218
|
+
features = await client.get_features(files[len(files)-1].id)
|
|
219
|
+
geometries = await client.get_geometry(
|
|
220
|
+
file_id=files[len(files)-1].id,
|
|
221
|
+
layer_id=layers[0].id
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
if len(geometries) > 0:
|
|
225
|
+
# 更新几何颜色
|
|
226
|
+
geometries[0].color = [255, 0, 0] # 红色
|
|
227
|
+
# 更新几何坐标(如果需要)
|
|
228
|
+
# geometries[0].geometry = np.array([new_x, new_y, new_z])
|
|
229
|
+
|
|
230
|
+
await client.update_geometry([geometries[0]])
|
|
231
|
+
print(f"几何更新成功: {geometries[0].id}")
|
|
232
|
+
|
|
233
|
+
if __name__ == '__main__':
|
|
234
|
+
asyncio.run(main())
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## 9. 删除模型
|
|
238
|
+
|
|
239
|
+
删除指定的几何对象:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
import asyncio
|
|
243
|
+
import numpy as np
|
|
244
|
+
from dimine_python_sdk.conn import open_client
|
|
245
|
+
from dimine_python_sdk.models.types import Point
|
|
246
|
+
|
|
247
|
+
async def main():
|
|
248
|
+
async with open_client() as client:
|
|
249
|
+
files = await client.get_files()
|
|
250
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
251
|
+
features = await client.get_features(files[len(files)-1].id)
|
|
252
|
+
|
|
253
|
+
# 先创建几何
|
|
254
|
+
new_point = Point(
|
|
255
|
+
file=files[0].id,
|
|
256
|
+
layer=layers[0].id,
|
|
257
|
+
feature=features[0].name,
|
|
258
|
+
geometry=np.array([100, 200, 300])
|
|
259
|
+
)
|
|
260
|
+
await client.create_geometry([new_point])
|
|
261
|
+
print(f"创建点几何: {new_point.id}")
|
|
262
|
+
|
|
263
|
+
# 删除几何
|
|
264
|
+
delete_items = [{"id": new_point.id, "file": files[0].id}]
|
|
265
|
+
await client.delete_geometry(delete_items)
|
|
266
|
+
print("几何删除成功")
|
|
267
|
+
|
|
268
|
+
if __name__ == '__main__':
|
|
269
|
+
asyncio.run(main())
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## 10. 模型属性管理
|
|
273
|
+
可以为模型添加自定义属性:
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
import asyncio
|
|
277
|
+
import numpy as np
|
|
278
|
+
from dimine_python_sdk.conn import open_client
|
|
279
|
+
from dimine_python_sdk.models.types import Point
|
|
280
|
+
from dimine_python_sdk.models.types import PropertyValue
|
|
281
|
+
|
|
282
|
+
async def main():
|
|
283
|
+
async with open_client() as client:
|
|
284
|
+
files = await client.get_files()
|
|
285
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
286
|
+
features = await client.get_features(files[0].id)
|
|
287
|
+
|
|
288
|
+
# 创建带属性的点
|
|
289
|
+
point = Point(
|
|
290
|
+
file=files[0].id,
|
|
291
|
+
layer=layers[0].id,
|
|
292
|
+
feature=features[0].name,
|
|
293
|
+
geometry=np.array([50, 50, 50]),
|
|
294
|
+
properties=[
|
|
295
|
+
PropertyValue(name="类型", value="勘探点", type="string"),
|
|
296
|
+
PropertyValue(name="高程", value="1250.5", type="float"),
|
|
297
|
+
PropertyValue(name="标识号", value="KP-001", type="string")
|
|
298
|
+
]
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
await client.create_geometry([point])
|
|
302
|
+
|
|
303
|
+
if __name__ == '__main__':
|
|
304
|
+
asyncio.run(main())
|
|
305
|
+
```
|
|
306
|
+
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# 数据获取
|
|
2
|
+
|
|
3
|
+
主要用于从数采软件场景内获取模型对象、属性、图层、文件等信息
|
|
4
|
+
|
|
5
|
+
## 1. 获取文件列表
|
|
6
|
+
获取数采软件场景下的已经打开的文件列表,包含文件id、文件名
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
import asyncio
|
|
10
|
+
from dimine_python_sdk.conn import open_client
|
|
11
|
+
async def main():
|
|
12
|
+
async with open_client() as client:
|
|
13
|
+
# 获取文件列表
|
|
14
|
+
files = await client.get_files()
|
|
15
|
+
for file in files:
|
|
16
|
+
print(file.name)
|
|
17
|
+
print(file.id)
|
|
18
|
+
|
|
19
|
+
if __name__ == '__main__':
|
|
20
|
+
asyncio.run(main())
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 2. 获取图层信息
|
|
24
|
+
获取文件下的图层信息,包含图层id、图层名称、图层类型
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import asyncio
|
|
28
|
+
from dimine_python_sdk.conn import open_client
|
|
29
|
+
async def main():
|
|
30
|
+
async with open_client() as client:
|
|
31
|
+
# 获取文件列表
|
|
32
|
+
files = await client.get_files()
|
|
33
|
+
# 获取最后一个文件下的图层
|
|
34
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
35
|
+
for layer in layers:
|
|
36
|
+
print(layer.id)
|
|
37
|
+
print(layer.name)
|
|
38
|
+
print(layer.layer_type)
|
|
39
|
+
|
|
40
|
+
if __name__ == '__main__':
|
|
41
|
+
asyncio.run(main())
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 3. 获取特定图层的模型
|
|
45
|
+
|
|
46
|
+
通过指定图层ID来获取特定图层下的模型:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
from dimine_python_sdk.conn import open_client
|
|
51
|
+
async def main():
|
|
52
|
+
async with open_client() as client:
|
|
53
|
+
# 获取文件列表
|
|
54
|
+
files = await client.get_files()
|
|
55
|
+
# 获取文件的所有图层
|
|
56
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
57
|
+
|
|
58
|
+
# 获取第一个图层的所有模型
|
|
59
|
+
if len(layers) > 0:
|
|
60
|
+
geometries = await client.get_geometry(
|
|
61
|
+
file_id=files[0].id,
|
|
62
|
+
layer_id=layers[0].id,
|
|
63
|
+
entity_types=["point", "line", "shell"]
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
print(f"图层 '{layers[0].name}' 包含 {len(geometries)} 个模型")
|
|
67
|
+
for geometry in geometries:
|
|
68
|
+
print(f" - {geometry.type}: {geometry.geometry}")
|
|
69
|
+
|
|
70
|
+
if __name__ == '__main__':
|
|
71
|
+
asyncio.run(main())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## 3. 获取模型对象
|
|
77
|
+
|
|
78
|
+
获取模型对象,包含模型对象id、模型对象类型、模型对象颜色、所属要素、所属图层、属性数组、模型对象几何信息
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import asyncio
|
|
82
|
+
from dimine_python_sdk.conn import open_client
|
|
83
|
+
async def main():
|
|
84
|
+
async with open_client() as client:
|
|
85
|
+
# 获取文件列表
|
|
86
|
+
files = await client.get_files()
|
|
87
|
+
# 获取最后一个文件下的图层
|
|
88
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
89
|
+
# 获取最后图层下的模型对象数组
|
|
90
|
+
geometries = await client.get_geometry(file_id=files[len(files)-1].id, layer_id=layers[0].id, ["point"])
|
|
91
|
+
for geometry in geometries:
|
|
92
|
+
print(geometry.id) # 模型对象id
|
|
93
|
+
print(geometry.type) # 模型对象类型
|
|
94
|
+
print(geometry.color) # 展示颜色
|
|
95
|
+
print(geometry.feature) # 所属要素
|
|
96
|
+
print(geometry.layer) # 所属图层
|
|
97
|
+
print(geometry.properties) # 属性数组
|
|
98
|
+
print(geometry.geometry) # 模型对象几何信息:点: np.ndarray(3,), 线: np.ndarray(N,3), 实体: TINGeometry
|
|
99
|
+
|
|
100
|
+
if __name__ == '__main__':
|
|
101
|
+
asyncio.run(main())
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 4. 获取特定类型的模型
|
|
105
|
+
|
|
106
|
+
可以通过`entity_types`参数过滤获取特定类型的模型:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
import asyncio
|
|
110
|
+
from dimine_python_sdk.conn import open_client
|
|
111
|
+
async def main():
|
|
112
|
+
async with open_client() as client:
|
|
113
|
+
# 获取文件列表
|
|
114
|
+
files = await client.get_files()
|
|
115
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
116
|
+
|
|
117
|
+
# 获取文件下所有图层中的所有类型的模型
|
|
118
|
+
geometries = await client.get_geometry(file_id=files[0].id, layer_id=layers[0].id, entity_types=["point", "line"])
|
|
119
|
+
|
|
120
|
+
for geometry in geometries:
|
|
121
|
+
print(f"类型: {geometry.type}, 坐标: {geometry.geometry}")
|
|
122
|
+
|
|
123
|
+
if __name__ == '__main__':
|
|
124
|
+
asyncio.run(main())
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 5. 获取特定要素的模型
|
|
128
|
+
|
|
129
|
+
可以通过`features`参数过滤获取特定要素关联的模型:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import asyncio
|
|
133
|
+
from dimine_python_sdk.conn import open_client
|
|
134
|
+
async def main():
|
|
135
|
+
async with open_client() as client:
|
|
136
|
+
# 获取文件列表
|
|
137
|
+
files = await client.get_files()
|
|
138
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
139
|
+
features = await client.get_features(files[0].id)
|
|
140
|
+
|
|
141
|
+
# 获取特定要素的模型
|
|
142
|
+
geometries = await client.get_geometry(
|
|
143
|
+
file_id=files[0].id,
|
|
144
|
+
layer_id=layers[0].id,
|
|
145
|
+
entity_types=["point", "line", "shell"],
|
|
146
|
+
features=[features[0].name] # 只获取第一个要素的模型
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
for geometry in geometries:
|
|
150
|
+
print(f"要素: {geometry.feature}, 类型: {geometry.type}")
|
|
151
|
+
|
|
152
|
+
if __name__ == '__main__':
|
|
153
|
+
asyncio.run(main())
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 5. 获取要素信息
|
|
157
|
+
|
|
158
|
+
获取文件中的要素定义,包括要素名称和属性定义:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import asyncio
|
|
162
|
+
from dimine_python_sdk.conn import open_client
|
|
163
|
+
from dimine_python_sdk.models.types import FeatureInfo, PropertyInfo
|
|
164
|
+
|
|
165
|
+
async def main():
|
|
166
|
+
async with open_client() as client:
|
|
167
|
+
# 获取文件列表
|
|
168
|
+
files = await client.get_files()
|
|
169
|
+
features = await client.get_features(files[0].id)
|
|
170
|
+
|
|
171
|
+
for feature in features:
|
|
172
|
+
print(f"要素名称: {feature.name}")
|
|
173
|
+
print("属性定义:")
|
|
174
|
+
for prop in feature.properties:
|
|
175
|
+
print(f" - {prop.name}: {prop.type}")
|
|
176
|
+
|
|
177
|
+
if __name__ == '__main__':
|
|
178
|
+
asyncio.run(main())
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 6. 获取特定类型的模型
|
|
182
|
+
|
|
183
|
+
可以通过`entity_types`参数过滤获取特定类型的模型:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
import asyncio
|
|
187
|
+
from dimine_python_sdk.conn import open_client
|
|
188
|
+
async def main():
|
|
189
|
+
async with open_client() as client:
|
|
190
|
+
# 获取文件列表
|
|
191
|
+
files = await client.get_files()
|
|
192
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
193
|
+
|
|
194
|
+
# 获取文件下所有图层中的所有类型的模型
|
|
195
|
+
geometries = await client.get_geometry(file_id=files[0].id, layer_id=layers[0].id, entity_types=["point", "line"])
|
|
196
|
+
|
|
197
|
+
for geometry in geometries:
|
|
198
|
+
print(f"类型: {geometry.type}, 坐标: {geometry.geometry}")
|
|
199
|
+
|
|
200
|
+
if __name__ == '__main__':
|
|
201
|
+
asyncio.run(main())
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 7. 获取特定要素的模型
|
|
205
|
+
|
|
206
|
+
可以通过`features`参数过滤获取特定要素关联的模型:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
import asyncio
|
|
210
|
+
from dimine_python_sdk.conn import open_client
|
|
211
|
+
async def main():
|
|
212
|
+
async with open_client() as client:
|
|
213
|
+
# 获取文件列表
|
|
214
|
+
files = await client.get_files()
|
|
215
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
216
|
+
features = await client.get_features(files[0].id)
|
|
217
|
+
|
|
218
|
+
# 获取特定要素的模型
|
|
219
|
+
geometries = await client.get_geometry(
|
|
220
|
+
file_id=files[0].id,
|
|
221
|
+
layer_id=layers[0].id,
|
|
222
|
+
entity_types=["point", "line", "shell"],
|
|
223
|
+
features=[features[0].name] # 只获取第一个要素的模型
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
for geometry in geometries:
|
|
227
|
+
print(f"要素: {geometry.feature}, 类型: {geometry.type}")
|
|
228
|
+
|
|
229
|
+
if __name__ == '__main__':
|
|
230
|
+
asyncio.run(main())
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 8. 获取实体(Shell)模型信息
|
|
234
|
+
|
|
235
|
+
实体模型使用三角网(TIN)表示,包含顶点和面片信息:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
import asyncio
|
|
239
|
+
from dimine_python_sdk.conn import open_client
|
|
240
|
+
from dimine_python_sdk.models.types import Shell
|
|
241
|
+
|
|
242
|
+
async def main():
|
|
243
|
+
async with open_client() as client:
|
|
244
|
+
# 获取文件列表
|
|
245
|
+
files = await client.get_files()
|
|
246
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
247
|
+
|
|
248
|
+
# 获取所有实体模型
|
|
249
|
+
geometries = await client.get_geometry(
|
|
250
|
+
file_id=files[0].id,
|
|
251
|
+
layer_id=layers[0].id,
|
|
252
|
+
entity_types=["shell"]
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
for geometry in geometries:
|
|
256
|
+
if isinstance(geometry, Shell):
|
|
257
|
+
print(f"实体ID: {geometry.id}")
|
|
258
|
+
print(f"顶点数: {geometry.geometry.points.shape[0]}")
|
|
259
|
+
print(f"面片数: {geometry.geometry.faces.shape[0]}")
|
|
260
|
+
print(f"顶点坐标: {geometry.geometry.points}")
|
|
261
|
+
print(f"面片索引: {geometry.geometry.faces}")
|
|
262
|
+
print(f"颜色: {geometry.color}")
|
|
263
|
+
|
|
264
|
+
if __name__ == '__main__':
|
|
265
|
+
asyncio.run(main())
|
|
266
|
+
```
|