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,152 @@
|
|
|
1
|
+
# 数据类型说明
|
|
2
|
+
|
|
3
|
+
## 数采文件信息
|
|
4
|
+
|
|
5
|
+
### 类型定义
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
class FileInfo(BaseModel):
|
|
9
|
+
id: str = Field(description='文件id') #
|
|
10
|
+
name: str = Field(description='文件名') #
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 图层信息
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 类型定义
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
class LayerInfo(BaseModel):
|
|
20
|
+
id: str = Field(description='图层id') #
|
|
21
|
+
name: str = Field(description='图层名称') #
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 属性信息
|
|
25
|
+
单个属性的定义,比如:属性名称、数据类型
|
|
26
|
+
### 类型定义
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
class PropertyInfo(BaseModel):
|
|
30
|
+
name: str = Field(description='属性名称') #
|
|
31
|
+
type: Literal['long', 'string', 'int', 'short'] = Field(description='数据类型') #
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 属性信息和属性值
|
|
35
|
+
在属性定义的基础上增加属性值字段
|
|
36
|
+
|
|
37
|
+
### 类型定义
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
class PropertyValue(BaseModel):
|
|
41
|
+
value: str | int | float | None = Field(default=None, description='属性值') #
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 要素信息
|
|
45
|
+
要素定义,也是一组属性的定义,比如:巷道要素,包含属性如名称、长度、宽度、高度等
|
|
46
|
+
|
|
47
|
+
### 类型定义
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
class FeatureInfo(BaseModel):
|
|
51
|
+
name: str = Field(description='要素名称', validation_alias='feature_name') #
|
|
52
|
+
properties: List[PropertyInfo] = Field(default_factory=list, description='要素属性', validation_alias='feature_define') #
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 几何对象基础类
|
|
56
|
+
是所有几何对象类型的基类
|
|
57
|
+
|
|
58
|
+
### 类型定义
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
class BaseGeometry(BaseModel):
|
|
62
|
+
id: str = Field(default='', description='点id') #
|
|
63
|
+
color: List[int] = Field(default=[0, 0, 0], description='颜色') #
|
|
64
|
+
feature: str = Field(default='', description='所属要素名') #
|
|
65
|
+
layer: str = Field(default='', description='所在图层id') #
|
|
66
|
+
properties: List[PropertyValue] = Field(default_factory=list, description='点属性') #
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 点
|
|
70
|
+
表示一个点对象,只有一个坐标
|
|
71
|
+
|
|
72
|
+
### 类型定义
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
class Point(BaseGeometry):
|
|
76
|
+
type: Optional[Literal['point']] = Field(default='point', description='点类型') #
|
|
77
|
+
geometry: np.ndarray = Field(default=np.array([]), description='点坐标, shape=(3,)') #
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## 线
|
|
82
|
+
表示一条直线或者多段线
|
|
83
|
+
|
|
84
|
+
### 类型定义
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
class Line(BaseModel):
|
|
88
|
+
type: Optional[Literal['line']] = Field(default='line', description='线类型') #
|
|
89
|
+
geometry: np.ndarray = Field(default=np.array([]), description='线坐标, shape=(N,3)') #
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## 实体对象几何信息
|
|
94
|
+
|
|
95
|
+
使用三角网体表示一个实体对象, 每三个点构成一个三角形
|
|
96
|
+
|
|
97
|
+
### 类型定义
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
class TINGeometry(BaseType):
|
|
101
|
+
"""三角网模型定义,"""
|
|
102
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
103
|
+
faces: np.ndarray = Field(default=np.array([]), description="三角面片:每行是三个顶点的索引,三个顶点连接起来形成一个三角面。shape=(N,3)")
|
|
104
|
+
points: np.ndarray = Field(default=np.array([]), description="所有顶点坐标, shape=(N,3)")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## 实体对象
|
|
110
|
+
包含实体对象几何信息,参考EntityGeometry
|
|
111
|
+
|
|
112
|
+
### 类型定义
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
class Entity(BaseGeometry):
|
|
116
|
+
"""实体"""
|
|
117
|
+
type: Optional[Literal["entity"]] = Field(default="entity", description="体类型")
|
|
118
|
+
geometry: TINGeometry = Field(default=None, description="三角网模型对象(TIN)")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## GEOMETRY
|
|
122
|
+
GEOMETRY 是一个联合类型,可以是以下类型之一:
|
|
123
|
+
- Point
|
|
124
|
+
- Line
|
|
125
|
+
- Shell
|
|
126
|
+
|
|
127
|
+
### 类型定义
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
GEOMETRY = Union[Point, Line, Shell]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Shell
|
|
134
|
+
表示一个三维实体对象,使用三角网(TIN)表示实体几何信息,每个面由三个顶点构成三角形。
|
|
135
|
+
|
|
136
|
+
### 类型定义
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
class Shell(BaseGeometry):
|
|
140
|
+
"""实体"""
|
|
141
|
+
type: Optional[Literal["shell"]] = Field(default="shell", description="体类型")
|
|
142
|
+
geometry: TINGeometry = Field(default=None, description="三角网模型对象(TIN)")
|
|
143
|
+
|
|
144
|
+
class TINGeometry(BaseType):
|
|
145
|
+
"""三角网模型定义"""
|
|
146
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
147
|
+
faces: np.ndarray = Field(default=np.array([]), description="三角面片:每行是三个顶点的索引,每行构成一个三角形面。shape=(N,3)")
|
|
148
|
+
points: np.ndarray = Field(default=np.array([]), description="所有顶点坐标, shape=(N,3)")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# 要素管理
|
|
2
|
+
|
|
3
|
+
要素(Feature)是几何模型的属性集合定义。例如,巷道要素可能包含名称、长度、宽度、高度等属性。通过要素管理系统,可以创建、更新和删除要素定义。
|
|
4
|
+
|
|
5
|
+
## 1. 创建要素
|
|
6
|
+
|
|
7
|
+
为文件创建新的要素定义,包含要素名称和属性列表:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import asyncio
|
|
11
|
+
from dimine_python_sdk.conn import open_client
|
|
12
|
+
|
|
13
|
+
async def main():
|
|
14
|
+
async with open_client() as client:
|
|
15
|
+
# 获取文件列表
|
|
16
|
+
files = await client.get_files()
|
|
17
|
+
|
|
18
|
+
# 创建要素定义
|
|
19
|
+
await client.create_feature(
|
|
20
|
+
file_id=files[len(files)-1].id,
|
|
21
|
+
feature_name="巷道要素",
|
|
22
|
+
feature_define=[
|
|
23
|
+
{"name": "名称", "type": "string"},
|
|
24
|
+
{"name": "长度", "type": "double"},
|
|
25
|
+
{"name": "宽度", "type": "double"},
|
|
26
|
+
{"name": "高度", "type": "double"},
|
|
27
|
+
{"name": "材质", "type": "string"},
|
|
28
|
+
{"name": "掘进日期", "type": "string"}
|
|
29
|
+
]
|
|
30
|
+
)
|
|
31
|
+
print("要素创建成功")
|
|
32
|
+
|
|
33
|
+
if __name__ == '__main__':
|
|
34
|
+
asyncio.run(main())
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 2. 获取要素信息
|
|
38
|
+
|
|
39
|
+
获取文件中所有要素的定义信息:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import asyncio
|
|
43
|
+
from dimine_python_sdk.conn import open_client
|
|
44
|
+
from dimine_python_sdk.models.types import FeatureInfo, PropertyInfo
|
|
45
|
+
|
|
46
|
+
async def main():
|
|
47
|
+
async with open_client() as client:
|
|
48
|
+
# 获取文件列表
|
|
49
|
+
files = await client.get_files()
|
|
50
|
+
features = await client.get_features(files[0].id)
|
|
51
|
+
|
|
52
|
+
print(f"文件包含 {len(features)} 个要素:")
|
|
53
|
+
for feature in features:
|
|
54
|
+
print(f"\n要素名称: {feature.name}")
|
|
55
|
+
print("属性定义:")
|
|
56
|
+
for prop in feature.properties:
|
|
57
|
+
print(f" - {prop.name}: {prop.type}")
|
|
58
|
+
|
|
59
|
+
if __name__ == '__main__':
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 3. 更新要素
|
|
64
|
+
|
|
65
|
+
更新已存在的要素定义,可以添加、修改或删除属性:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import asyncio
|
|
69
|
+
from dimine_python_sdk.conn import open_client
|
|
70
|
+
|
|
71
|
+
async def main():
|
|
72
|
+
async with open_client() as client:
|
|
73
|
+
# 获取文件列表
|
|
74
|
+
files = await client.get_files()
|
|
75
|
+
|
|
76
|
+
# 更新要素定义
|
|
77
|
+
await client.update_feature(
|
|
78
|
+
file_id=files[len(files)-1].id,
|
|
79
|
+
feature_name="巷道要素",
|
|
80
|
+
feature_define=[
|
|
81
|
+
{"name": "名称", "type": "string"},
|
|
82
|
+
{"name": "长度", "type": "double"},
|
|
83
|
+
{"name": "宽度", "type": "double"},
|
|
84
|
+
{"name": "高度", "type": "double"},
|
|
85
|
+
{"name": "材质", "type": "string"},
|
|
86
|
+
{"name": "掘进日期", "type": "string"},
|
|
87
|
+
{"name": "支护类型", "type": "string"} # 新增属性
|
|
88
|
+
]
|
|
89
|
+
)
|
|
90
|
+
print("要素更新成功")
|
|
91
|
+
|
|
92
|
+
if __name__ == '__main__':
|
|
93
|
+
asyncio.run(main())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 4. 删除要素
|
|
97
|
+
|
|
98
|
+
删除文件中的指定要素:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import asyncio
|
|
102
|
+
from dimine_python_sdk.conn import open_client
|
|
103
|
+
|
|
104
|
+
async def main():
|
|
105
|
+
async with open_client() as client:
|
|
106
|
+
# 获取文件列表
|
|
107
|
+
files = await client.get_files()
|
|
108
|
+
|
|
109
|
+
# 删除要素
|
|
110
|
+
await client.delete_feature(
|
|
111
|
+
file=files[len(files)-1].id,
|
|
112
|
+
feature_name="巷道要素"
|
|
113
|
+
)
|
|
114
|
+
print("要素删除成功")
|
|
115
|
+
|
|
116
|
+
if __name__ == '__main__':
|
|
117
|
+
asyncio.run(main())
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 5. 要素与几何模型的关系
|
|
121
|
+
|
|
122
|
+
要素定义了几何模型可以拥有的属性。创建几何模型时,需要指定所属的要素:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
import asyncio
|
|
126
|
+
import numpy as np
|
|
127
|
+
from dimine_python_sdk.conn import open_client
|
|
128
|
+
from dimine_python_sdk.models.types import Point, PropertyValue
|
|
129
|
+
|
|
130
|
+
async def main():
|
|
131
|
+
async with open_client() as client:
|
|
132
|
+
# 获取文件、图层、要素信息
|
|
133
|
+
files = await client.get_files()
|
|
134
|
+
layers = await client.get_layers(file_id=files[0].id)
|
|
135
|
+
features = await client.get_features(files[0].id)
|
|
136
|
+
|
|
137
|
+
# 创建带属性的点模型
|
|
138
|
+
point = Point(
|
|
139
|
+
file=files[0].id,
|
|
140
|
+
layer=layers[0].id,
|
|
141
|
+
feature=features[0].name, # 关联到要素
|
|
142
|
+
geometry=np.array([100, 200, 300]),
|
|
143
|
+
properties=[
|
|
144
|
+
PropertyValue(name="名称", value="钻孔ZK-001", type="string"),
|
|
145
|
+
PropertyValue(name="高程", value="1250.5", type="float"),
|
|
146
|
+
PropertyValue(name="孔深", value="150.0", type="float")
|
|
147
|
+
]
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
await client.create_geometry([point])
|
|
151
|
+
print("带属性的点模型创建成功")
|
|
152
|
+
|
|
153
|
+
if __name__ == '__main__':
|
|
154
|
+
asyncio.run(main())
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 6. 属性类型说明
|
|
158
|
+
|
|
159
|
+
要素属性支持以下数据类型:
|
|
160
|
+
|
|
161
|
+
- **string**: 字符串类型
|
|
162
|
+
- **int**: 整数类型
|
|
163
|
+
- **long**: 长整数类型
|
|
164
|
+
- **short**: 短整数类型
|
|
165
|
+
- **double**: 浮点数类型
|
|
166
|
+
|
|
167
|
+
### 属性使用注意事项
|
|
168
|
+
|
|
169
|
+
1. **数据类型匹配**: 设置属性值时需要与定义的类型匹配
|
|
170
|
+
2. **属性名称唯一**: 在同一个要素中,属性名称不能重复
|
|
171
|
+
3. **字段命名**: 属性名称建议使用中文,便于在Dimine软件中显示
|
|
172
|
+
|
|
173
|
+
## 7. 完整示例:创建和管理要素
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
import asyncio
|
|
177
|
+
import numpy as np
|
|
178
|
+
from dimine_python_sdk.conn import open_client
|
|
179
|
+
from dimine_python_sdk.models.types import Point, Line, Shell, PropertyValue
|
|
180
|
+
|
|
181
|
+
async def main():
|
|
182
|
+
async with open_client() as client:
|
|
183
|
+
# 1. 获取文件信息
|
|
184
|
+
files = await client.get_files()
|
|
185
|
+
file_id = files[0].id
|
|
186
|
+
layers = await client.get_layers(file_id=file_id)
|
|
187
|
+
layer_id = layers[0].id
|
|
188
|
+
|
|
189
|
+
# 2. 创建多个要素
|
|
190
|
+
await client.create_feature(
|
|
191
|
+
file_id=file_id,
|
|
192
|
+
feature_name="勘探孔",
|
|
193
|
+
feature_define=[
|
|
194
|
+
{"name": "孔号", "type": "string"},
|
|
195
|
+
{"name": "孔深", "type": "double"},
|
|
196
|
+
{"name": "倾角", "type": "double"},
|
|
197
|
+
{"name": "方位角", "type": "double"},
|
|
198
|
+
{"name": "岩性", "type": "string"}
|
|
199
|
+
]
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
await client.create_feature(
|
|
203
|
+
file_id=file_id,
|
|
204
|
+
feature_name="测点",
|
|
205
|
+
feature_define=[
|
|
206
|
+
{"name": "点号", "type": "string"},
|
|
207
|
+
{"name": "高程", "type": "double"},
|
|
208
|
+
{"name": "X坐标", "type": "double"},
|
|
209
|
+
{"name": "Y坐标", "type": "double"},
|
|
210
|
+
{"name": "Z坐标", "type": "double"}
|
|
211
|
+
]
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
# 3. 获取要素信息
|
|
215
|
+
features = await client.get_features(file_id)
|
|
216
|
+
print(f"创建了 {len(features)} 个要素")
|
|
217
|
+
|
|
218
|
+
# 4. 创建与要素关联的几何模型
|
|
219
|
+
勘探孔要素 = None
|
|
220
|
+
测点要素 = None
|
|
221
|
+
|
|
222
|
+
for feature in features:
|
|
223
|
+
if feature.name == "勘探孔":
|
|
224
|
+
勘探孔要素 = feature
|
|
225
|
+
elif feature.name == "测点":
|
|
226
|
+
测点要素 = feature
|
|
227
|
+
|
|
228
|
+
# 创建勘探孔模型
|
|
229
|
+
if 勘探孔要素:
|
|
230
|
+
drill_hole = Line(
|
|
231
|
+
file=file_id,
|
|
232
|
+
layer=layer_id,
|
|
233
|
+
feature=勘探孔要素.name,
|
|
234
|
+
geometry=np.array([[0, 0, 0], [100, 50, -150]]),
|
|
235
|
+
color=[255, 0, 0],
|
|
236
|
+
properties=[
|
|
237
|
+
PropertyValue(name="孔号", value="ZK-001", type="string"),
|
|
238
|
+
PropertyValue(name="孔深", value="150.0", type="float"),
|
|
239
|
+
PropertyValue(name="倾角", value="56.3", type="float")
|
|
240
|
+
]
|
|
241
|
+
)
|
|
242
|
+
await client.create_geometry([drill_hole])
|
|
243
|
+
|
|
244
|
+
# 创建测点模型
|
|
245
|
+
if 测点要素:
|
|
246
|
+
survey_point = Point(
|
|
247
|
+
file=file_id,
|
|
248
|
+
layer=layer_id,
|
|
249
|
+
feature=测点要素.name,
|
|
250
|
+
geometry=np.array([50, 25, -75]),
|
|
251
|
+
color=[0, 255, 0],
|
|
252
|
+
properties=[
|
|
253
|
+
PropertyValue(name="点号", value="D-001", type="string"),
|
|
254
|
+
PropertyValue(name="高程", value="1225.0", type="float")
|
|
255
|
+
]
|
|
256
|
+
)
|
|
257
|
+
await client.create_geometry([survey_point])
|
|
258
|
+
|
|
259
|
+
print("要素和模型创建完成")
|
|
260
|
+
|
|
261
|
+
if __name__ == '__main__':
|
|
262
|
+
asyncio.run(main())
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## 8. 最佳实践
|
|
266
|
+
|
|
267
|
+
1. **要素规划**: 在创建模型前,先规划好需要的要素类型和属性
|
|
268
|
+
2. **命名规范**: 使用清晰的要素名称,如"巷道"、"钻孔"、"测点"等
|
|
269
|
+
3. **属性精简**: 只包含必要的属性,避免过度设计
|
|
270
|
+
4. **类型选择**: 根据数据特性选择合适的属性类型
|
|
271
|
+
5. **版本管理**: 如果需要修改要素定义,建议先删除后重建,避免数据不一致
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# IO操作
|
|
2
|
+
|
|
3
|
+
IO操作包括文件的导入、导出、文件类型转换
|
|
4
|
+
|
|
5
|
+
## 1. 文件打开
|
|
6
|
+
|
|
7
|
+
将外部文件打开到数采软件当前场景中:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import asyncio
|
|
11
|
+
from dimine_python_sdk.conn import open_client
|
|
12
|
+
|
|
13
|
+
async def main():
|
|
14
|
+
async with open_client() as client:
|
|
15
|
+
# 打开文件(支持多种格式:dmf、dmm、dtm、dwg等)
|
|
16
|
+
file_path = "D:/temp/test_export.dtm"
|
|
17
|
+
file_info = await client.open_file(file_path)
|
|
18
|
+
print(f"打开文件: {file_info.name}, ID: {file_info.id}")
|
|
19
|
+
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
asyncio.run(main())
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**支持的打开文件格式:**
|
|
25
|
+
- `.dtm` - Dimine地形模型文件
|
|
26
|
+
- `.dmf` - Dimine标准工程文件格式
|
|
27
|
+
- `.dmm` - Dimine模型文件格式
|
|
28
|
+
- `.dwg` / `.dxf` - AutoCAD文件格式
|
|
29
|
+
- 以及其他Dimine支持的格式
|
|
30
|
+
|
|
31
|
+
## 2. 文件导出
|
|
32
|
+
|
|
33
|
+
将数采软件场景中的文件导出为指定格式:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import asyncio
|
|
37
|
+
from dimine_python_sdk.conn import open_client
|
|
38
|
+
|
|
39
|
+
async def main():
|
|
40
|
+
async with open_client() as client:
|
|
41
|
+
# 获取文件列表
|
|
42
|
+
files = await client.get_files()
|
|
43
|
+
|
|
44
|
+
if len(files) > 0:
|
|
45
|
+
# 导出文件(根据文件扩展名自动识别格式)
|
|
46
|
+
await client.export_file(
|
|
47
|
+
file_id=files[0].id,
|
|
48
|
+
file_path="D:/temp/test_export.dwg"
|
|
49
|
+
)
|
|
50
|
+
print("文件导出成功")
|
|
51
|
+
|
|
52
|
+
if __name__ == '__main__':
|
|
53
|
+
asyncio.run(main())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**支持的导出文件格式:**
|
|
57
|
+
- `.dwg` / `.dxf` - AutoCAD格式
|
|
58
|
+
- `.dmf` - Dimine工程文件
|
|
59
|
+
- `.dmm` - Dimine模型文件
|
|
60
|
+
- `.dtm` - Dimine地形模型
|
|
61
|
+
- 以及其他Dimine支持的格式
|
|
62
|
+
|
|
63
|
+
**参数说明:**
|
|
64
|
+
- `file_id`: 文件ID或文件名称
|
|
65
|
+
- `file_path`: 导出目标路径
|
|
66
|
+
- `mkdir`: 是否自动创建目录(默认为True)
|
|
67
|
+
|
|
68
|
+
## 3. 文件关闭
|
|
69
|
+
|
|
70
|
+
关闭当前场景中的指定文件:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import asyncio
|
|
74
|
+
from dimine_python_sdk.conn import open_client
|
|
75
|
+
|
|
76
|
+
async def main():
|
|
77
|
+
async with open_client() as client:
|
|
78
|
+
# 获取文件列表
|
|
79
|
+
files = await client.get_files()
|
|
80
|
+
|
|
81
|
+
# 关闭文件
|
|
82
|
+
await client.close_file(file_id=files[0].id)
|
|
83
|
+
print("文件已关闭")
|
|
84
|
+
|
|
85
|
+
if __name__ == '__main__':
|
|
86
|
+
asyncio.run(main())
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 3. 文件关闭
|
|
90
|
+
|
|
91
|
+
关闭当前场景中的指定文件:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import asyncio
|
|
95
|
+
from dimine_python_sdk.conn import open_client
|
|
96
|
+
|
|
97
|
+
async def main():
|
|
98
|
+
async with open_client() as client:
|
|
99
|
+
# 获取文件列表
|
|
100
|
+
files = await client.get_files()
|
|
101
|
+
|
|
102
|
+
# 关闭文件
|
|
103
|
+
if len(files) > 0:
|
|
104
|
+
await client.close_file(files[0].id)
|
|
105
|
+
print("文件已关闭")
|
|
106
|
+
|
|
107
|
+
if __name__ == '__main__':
|
|
108
|
+
asyncio.run(main())
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 4. 文件操作完整示例
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import asyncio
|
|
115
|
+
from dimine_python_sdk.conn import open_client
|
|
116
|
+
|
|
117
|
+
async def main():
|
|
118
|
+
async with open_client() as client:
|
|
119
|
+
# 1. 打开文件
|
|
120
|
+
print("打开文件...")
|
|
121
|
+
file_path = "D:/temp/test.dtm"
|
|
122
|
+
file_info = await client.open_file(file_path)
|
|
123
|
+
print(f"已打开: {file_info.name}, ID: {file_info.id}")
|
|
124
|
+
|
|
125
|
+
# 2. 获取文件列表
|
|
126
|
+
files = await client.get_files()
|
|
127
|
+
print(f"\n当前文件数: {len(files)}")
|
|
128
|
+
|
|
129
|
+
# 3. 导出文件
|
|
130
|
+
if len(files) > 0:
|
|
131
|
+
print("导出文件...")
|
|
132
|
+
await client.export_file(
|
|
133
|
+
file_id=files[0].id,
|
|
134
|
+
file_path="D:/temp/test_export.dwg"
|
|
135
|
+
)
|
|
136
|
+
print("导出成功")
|
|
137
|
+
|
|
138
|
+
# 4. 关闭文件
|
|
139
|
+
if len(files) > 0:
|
|
140
|
+
print("关闭文件...")
|
|
141
|
+
await client.close_file(files[0].id)
|
|
142
|
+
|
|
143
|
+
if __name__ == '__main__':
|
|
144
|
+
asyncio.run(main())
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 支持的文件格式
|
|
148
|
+
|
|
149
|
+
Dimine软件支持多种文件格式的导入导出:
|
|
150
|
+
|
|
151
|
+
- **DMF**: Dimine标准工程文件格式
|
|
152
|
+
- **DMM**: Dimine模型文件格式
|
|
153
|
+
- **CAD**: AutoCAD文件格式(.dwg, .dxf等)
|
|
154
|
+
- **DMB**: Dimine块定义文件
|
|
155
|
+
- **DMD**: Dimine数据文件
|
|
156
|
+
- **DMO**: Dimine对象文件
|
|
157
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# dimine-python-sdk
|
|
2
|
+
|
|
3
|
+
## 1. 概述
|
|
4
|
+
**简介**:
|
|
5
|
+
|
|
6
|
+
本SDK提供Dimine数采Python接口,用于与Dimine数字采矿设计软件进行高效交互。开发者可通过编写 Python 脚本,实现对采矿模型、场景等核心资源的增删改查操作,以及获取场景信息、执行分析任务等,从而将采矿设计工作流自动化或集成到现有系统中。
|
|
7
|
+
|
|
8
|
+
**核心特性**:
|
|
9
|
+
|
|
10
|
+
- 模型管理:创建、读取、更新、删除采矿设计模型(如地质模型、采场模型、巷道模型等)。
|
|
11
|
+
- 场景交互:获取当前打开的工程场景信息,包括场景列表、场景内对象属性。
|
|
12
|
+
- 数据查询:支持按条件过滤模型、查询属性、空间关系检索。
|
|
13
|
+
- 实时同步:操作结果实时反映在软件界面中。
|
|
14
|
+
- 异步支持:提供异步调用接口,适用于批量处理或长时间任务。
|
|
15
|
+
|
|
16
|
+
**适用平台/语言**:Python 3.12 及以上版本;支持 Windows / Linux 操作系统;需安装数字采矿设计软件客户端。
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 2. 快速安装
|
|
20
|
+
```bash
|
|
21
|
+
pip install dimine-python-sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 3. 快速开始
|
|
25
|
+
|
|
26
|
+
获取数采当前打开的文件列表
|
|
27
|
+
```python
|
|
28
|
+
import asyncio
|
|
29
|
+
from dimine_python_sdk.conn import open_client
|
|
30
|
+
|
|
31
|
+
async def main():
|
|
32
|
+
async with open_client() as client:
|
|
33
|
+
files = await client.get_files()
|
|
34
|
+
print(files)
|
|
35
|
+
|
|
36
|
+
if __name__ == '__main__':
|
|
37
|
+
asyncio.run(main())
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# 快速开始
|
|
2
|
+
以下介绍如何使用sdk获取数采当前文件列表、图层信息、模型对象等信息
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## 1. 获取文件列表
|
|
6
|
+
```python
|
|
7
|
+
import asyncio
|
|
8
|
+
from dimine_python_sdk.conn import open_client
|
|
9
|
+
async def main():
|
|
10
|
+
async with open_client() as client:
|
|
11
|
+
files = await client.get_files()
|
|
12
|
+
print(files)
|
|
13
|
+
|
|
14
|
+
if __name__ == '__main__':
|
|
15
|
+
asyncio.run(main())
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 2. 获取图层信息
|
|
19
|
+
```python
|
|
20
|
+
import asyncio
|
|
21
|
+
from dimine_python_sdk.conn import open_client
|
|
22
|
+
async def main():
|
|
23
|
+
async with open_client() as client:
|
|
24
|
+
files = await client.get_layers(file_id="123")
|
|
25
|
+
print(files)
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
asyncio.run(main())
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 3. 获取模型对象
|
|
32
|
+
```python
|
|
33
|
+
import asyncio
|
|
34
|
+
from dimine_python_sdk.conn import open_client
|
|
35
|
+
async def main():
|
|
36
|
+
async with open_client() as client:
|
|
37
|
+
files = await client.get_files()
|
|
38
|
+
layers = await client.get_layers(file_id=files[len(files)-1].id)
|
|
39
|
+
geometries = await client.get_geometry(file_id=files[len(files)-1].id, layer_id=layers[0].id, ["point"])
|
|
40
|
+
print(geometries)
|
|
41
|
+
|
|
42
|
+
if __name__ == '__main__':
|
|
43
|
+
asyncio.run(main())
|
|
44
|
+
```
|
|
45
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# API 参考
|
|
2
|
+
|
|
3
|
+
* [logger](logger.md)
|
|
4
|
+
* [base_conn_client](conn\base_conn_client.md)
|
|
5
|
+
* [conn_client](conn\conn_client.md)
|
|
6
|
+
* [model_func](lib\algorithm\model_func.md)
|
|
7
|
+
* [file_conversion](lib\io\file_conversion.md)
|
|
8
|
+
* [models](lib\io\models.md)
|
|
9
|
+
* [project_plotting](lib\io\project_plotting.md)
|
|
10
|
+
* [block_data](lib\prospecting\block_data.md)
|
|
11
|
+
* [drill_db](lib\prospecting\drill_db.md)
|
|
12
|
+
* [models](lib\prospecting\models.md)
|
|
13
|
+
* [valuation](lib\prospecting\valuation.md)
|
|
14
|
+
* [entity](lib\types\entity.md)
|
|
15
|
+
* [line](lib\types\line.md)
|
|
16
|
+
* [point](lib\types\point.md)
|
|
17
|
+
* [conn](models\conn.md)
|
|
18
|
+
* [errors](models\errors.md)
|
|
19
|
+
* [types](models\types.md)
|