osis-python 0.5.2__tar.gz → 0.5.4__tar.gz
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.
- {osis_python-0.5.2/src/osis_python.egg-info → osis_python-0.5.4}/PKG-INFO +1 -1
- {osis_python-0.5.2 → osis_python-0.5.4/src/osis_python.egg-info}/PKG-INFO +1 -1
- {osis_python-0.5.2 → osis_python-0.5.4}/src/osis_python.egg-info/SOURCES.txt +5 -1
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/__init__.py +1 -1
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/all_func.py +2 -1
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/apdl_sync.py +13 -22
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/engine.py +48 -9
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/sync_apdl_cli.py +3 -3
- osis_python-0.5.4/src/pyosis/display/__init__.py +8 -0
- osis_python-0.5.4/src/pyosis/display/interface.py +103 -0
- osis_python-0.5.4/src/pyosis/display/manager.py +115 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/element/manager.py +9 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/project/interface.py +12 -1
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/project/manager.py +30 -6
- osis_python-0.5.4/src/pyosis/transfer/out_to_python.py +415 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/parser.py +53 -53
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/routes.py +6 -0
- osis_python-0.5.4/tests/test_project_manager.py +135 -0
- osis_python-0.5.2/src/pyosis/transfer/out_to_python.py +0 -246
- {osis_python-0.5.2 → osis_python-0.5.4}/LICENSE +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/README.md +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/pyproject.toml +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/setup.cfg +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/osis_python.egg-info/dependency_links.txt +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/osis_python.egg-info/requires.txt +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/osis_python.egg-info/top_level.txt +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/boundary/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/boundary/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/boundary/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/control/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/control/control.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/control/io.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/control/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/control/nonlinear.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/basic_manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/build.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/client.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/command.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/exceptions.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/core/references.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/dynamic/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/dynamic/load_to_mass.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/dynamic/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/dynamic/modal.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/dynamic/seismic.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/element/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/element/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/general/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/general/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/geometry/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/geometry/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/geometry/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/live/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/live/analysis.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/live/grade.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/live/lane.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/live/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/load/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/load/loadcase.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/load/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/load/static.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/load/tendon.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/material/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/material/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/material/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/node/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/node/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/node/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/post/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/post/combine.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/post/design_check.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/post/display.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/post/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/project/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/component_thickness.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/coordinate.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/creep_shrink.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/damping.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/property/pu_curve.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/quick_building/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/quick_building/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/check.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/env.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/loadcase.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/result/result.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/common.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/composite.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/numeric.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/param.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/rebar.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/rib.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/section/steel.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/settlement/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/settlement/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/settlement/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stability/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stability/buckling.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stability/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stage/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stage/define.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stage/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/stage/overall.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/thickness/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/thickness/interface.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/thickness/manager.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/__init__.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/generator.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/matrix.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/src/pyosis/transfer/split.py +0 -0
- {osis_python-0.5.2 → osis_python-0.5.4}/tests/test_delete_occupied.py +0 -0
|
@@ -26,6 +26,9 @@ src/pyosis/core/engine.py
|
|
|
26
26
|
src/pyosis/core/exceptions.py
|
|
27
27
|
src/pyosis/core/references.py
|
|
28
28
|
src/pyosis/core/sync_apdl_cli.py
|
|
29
|
+
src/pyosis/display/__init__.py
|
|
30
|
+
src/pyosis/display/interface.py
|
|
31
|
+
src/pyosis/display/manager.py
|
|
29
32
|
src/pyosis/dynamic/__init__.py
|
|
30
33
|
src/pyosis/dynamic/load_to_mass.py
|
|
31
34
|
src/pyosis/dynamic/manager.py
|
|
@@ -107,4 +110,5 @@ src/pyosis/transfer/out_to_python.py
|
|
|
107
110
|
src/pyosis/transfer/parser.py
|
|
108
111
|
src/pyosis/transfer/routes.py
|
|
109
112
|
src/pyosis/transfer/split.py
|
|
110
|
-
tests/test_delete_occupied.py
|
|
113
|
+
tests/test_delete_occupied.py
|
|
114
|
+
tests/test_project_manager.py
|
|
@@ -7,7 +7,7 @@ A library for extending OSIS functionality.
|
|
|
7
7
|
A library that allows users to use CAE with great flexibility.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
__version__ = "0.5.
|
|
10
|
+
__version__ = "0.5.4"
|
|
11
11
|
__author__ = "CCCC Highway Consultant Co. Ltd." # 中交公路规划设计院 - 工程技术研究中心 - lzh - wjh - myf
|
|
12
12
|
|
|
13
13
|
from .core.engine import OSISEngine
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
4. 有变化 → parse → 写 prep → 存本次 hash
|
|
8
8
|
|
|
9
9
|
用法:
|
|
10
|
-
|
|
11
|
-
if
|
|
12
|
-
print(
|
|
10
|
+
changed = engine.sync_apdl()
|
|
11
|
+
if changed:
|
|
12
|
+
print("命令流已变化,已写 prep")
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
@@ -21,7 +21,6 @@ from dataclasses import dataclass
|
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
from typing import TYPE_CHECKING
|
|
23
23
|
|
|
24
|
-
from ..transfer import parse_text
|
|
25
24
|
from ..transfer.out_to_python import write_prep_outputs
|
|
26
25
|
|
|
27
26
|
if TYPE_CHECKING:
|
|
@@ -39,19 +38,9 @@ _TIME_LINE_PATTERN = re.compile(
|
|
|
39
38
|
)
|
|
40
39
|
|
|
41
40
|
|
|
42
|
-
@dataclass
|
|
43
|
-
class ApdlSyncResult:
|
|
44
|
-
"""APDL 同步结果。"""
|
|
45
|
-
|
|
46
|
-
changed: bool = False
|
|
47
|
-
|
|
48
|
-
def summary(self) -> str:
|
|
49
|
-
return "命令流已变化,已写 prep" if self.changed else "命令流未变化"
|
|
50
|
-
|
|
51
|
-
|
|
52
41
|
@dataclass
|
|
53
42
|
class ApdlSessionStore:
|
|
54
|
-
"""记录最近一次同步的 .out 路径与 hash
|
|
43
|
+
"""记录最近一次同步的 .out 路径与 hash(供调试/展示)。"""
|
|
55
44
|
|
|
56
45
|
last_path: str = ""
|
|
57
46
|
last_hash: str = ""
|
|
@@ -162,11 +151,14 @@ def perform_apdl_sync(
|
|
|
162
151
|
engine: "OSISEngine",
|
|
163
152
|
path: str | None = None,
|
|
164
153
|
*,
|
|
165
|
-
force_export: bool =
|
|
166
|
-
) ->
|
|
154
|
+
force_export: bool = False,
|
|
155
|
+
) -> bool | None:
|
|
167
156
|
"""执行 APDL 同步:export → 比 hash → 有变化则写 prep(不执行 prep)。
|
|
168
157
|
|
|
169
|
-
|
|
158
|
+
Returns:
|
|
159
|
+
True - 命令流已变化,已写 prep
|
|
160
|
+
False - 命令流未变化
|
|
161
|
+
None - 未获取到项目路径(无法同步)
|
|
170
162
|
"""
|
|
171
163
|
if _get_project_dir(engine) is None:
|
|
172
164
|
return None
|
|
@@ -186,12 +178,11 @@ def perform_apdl_sync(
|
|
|
186
178
|
session.update_file(str(out_path), file_hash)
|
|
187
179
|
|
|
188
180
|
if file_hash == last_hash:
|
|
189
|
-
return
|
|
181
|
+
return False
|
|
190
182
|
|
|
191
|
-
|
|
192
|
-
write_prep_outputs(parsed, prep_dir)
|
|
183
|
+
write_prep_outputs(out_path, prep_dir)
|
|
193
184
|
|
|
194
185
|
# 未执行 prep,OSIS 未变
|
|
195
186
|
_save_persisted_hash(state_path, out_path, file_hash)
|
|
196
187
|
|
|
197
|
-
return
|
|
188
|
+
return True
|
|
@@ -22,7 +22,7 @@ from __future__ import annotations
|
|
|
22
22
|
import os
|
|
23
23
|
from typing import Any
|
|
24
24
|
|
|
25
|
-
from .apdl_sync import
|
|
25
|
+
from .apdl_sync import ApdlSessionStore, perform_apdl_sync
|
|
26
26
|
from ..material.manager import MaterialManager, material_manager
|
|
27
27
|
from ..section.manager import SectionManager, section_manager
|
|
28
28
|
from ..node.manager import NodeManager, node_manager
|
|
@@ -41,6 +41,7 @@ from ..stability.manager import StabilityManager, stability_manager
|
|
|
41
41
|
from ..dynamic.manager import DynamicManager, dynamic_manager
|
|
42
42
|
from ..post.manager import PostManager, post_manager
|
|
43
43
|
from ..result.manager import ResultManager, result_manager
|
|
44
|
+
from ..display.manager import DisplayManager, display_manager
|
|
44
45
|
from ..general.interface import (
|
|
45
46
|
osis_matrix,
|
|
46
47
|
output_result_for_calc_book,
|
|
@@ -78,6 +79,7 @@ class OSISEngine:
|
|
|
78
79
|
- dynamic: 动力分析管理器(荷载转换质量、模态、反应谱)
|
|
79
80
|
- post: 后处理管理器(荷载组合、规范验算、结果显示)
|
|
80
81
|
- result: 结果导出管理器(工况结果、包络结果、验算结果)
|
|
82
|
+
- display: 显示管理器(边界 / 荷载 / 钢束显隐等)
|
|
81
83
|
|
|
82
84
|
通用操作可直接通过 engine 调用:
|
|
83
85
|
- run(), solve(), replot(), clear(), clc()
|
|
@@ -114,6 +116,9 @@ class OSISEngine:
|
|
|
114
116
|
### 后处理 ###
|
|
115
117
|
self._post = post_manager
|
|
116
118
|
self._result = result_manager
|
|
119
|
+
|
|
120
|
+
### 显示 ###
|
|
121
|
+
self._display = display_manager
|
|
117
122
|
|
|
118
123
|
# OSIS端口与网址
|
|
119
124
|
if port is None:
|
|
@@ -228,6 +233,22 @@ class OSISEngine:
|
|
|
228
233
|
"""结果导出管理器(工况结果、包络结果、验算结果)"""
|
|
229
234
|
return self._result
|
|
230
235
|
|
|
236
|
+
### 显示 ###
|
|
237
|
+
|
|
238
|
+
@property
|
|
239
|
+
def display(self) -> DisplayManager:
|
|
240
|
+
"""显示管理器(边界 / 荷载 / 钢束显隐等)"""
|
|
241
|
+
return self._display
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def start(self) -> None:
|
|
245
|
+
"""开启 OSIS 软件"""
|
|
246
|
+
...
|
|
247
|
+
|
|
248
|
+
def close(self) -> None:
|
|
249
|
+
"""关闭 OSIS 软件"""
|
|
250
|
+
...
|
|
251
|
+
|
|
231
252
|
# ──────────────────────────────────────────
|
|
232
253
|
# 通用操作(直接暴露 general 和 core 的函数)
|
|
233
254
|
# ──────────────────────────────────────────
|
|
@@ -297,9 +318,14 @@ class OSISEngine:
|
|
|
297
318
|
# 便捷方法(委托给 project manager)
|
|
298
319
|
# ──────────────────────────────────────────
|
|
299
320
|
|
|
300
|
-
def save_project(self) -> None:
|
|
301
|
-
"""
|
|
302
|
-
|
|
321
|
+
def save_project(self, filepath: str = "") -> None:
|
|
322
|
+
"""保存项目
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
filepath: 工程文件路径。为空时使用当前项目路径;
|
|
326
|
+
非空时使用传入路径。
|
|
327
|
+
"""
|
|
328
|
+
self._project.save(filepath)
|
|
303
329
|
|
|
304
330
|
def new_project(self, type: int = 1, filepath: str = "") -> None:
|
|
305
331
|
"""新建项目
|
|
@@ -387,8 +413,21 @@ class OSISEngine:
|
|
|
387
413
|
return f"OSISEngine(project_path={self.project.get_directory()})"
|
|
388
414
|
|
|
389
415
|
def sync_apdl(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
416
|
+
self,
|
|
417
|
+
path: str | None = None,
|
|
418
|
+
*,
|
|
419
|
+
force_export: bool = False,
|
|
420
|
+
) -> bool | None:
|
|
421
|
+
"""通过 APDL 导出从 OSIS 同步数据。OSIS 界面操作后调用。
|
|
422
|
+
|
|
423
|
+
Args:
|
|
424
|
+
path: 自定义 .out 文件路径,None 用项目下默认 _pyosis_sync.out。
|
|
425
|
+
force_export: False(默认)若 .out 已存在则直接复用,仅当 hash 与上次不一致才写 prep;
|
|
426
|
+
True 时总是重新执行 export_apdl。
|
|
427
|
+
|
|
428
|
+
Returns:
|
|
429
|
+
True - 命令流已变化,已写 prep
|
|
430
|
+
False - 命令流未变化
|
|
431
|
+
None - 未获取到项目路径
|
|
432
|
+
"""
|
|
433
|
+
return perform_apdl_sync(self, path, force_export=force_export)
|
|
@@ -20,16 +20,16 @@ from .engine import OSISEngine
|
|
|
20
20
|
def main() -> int:
|
|
21
21
|
engine = OSISEngine()
|
|
22
22
|
try:
|
|
23
|
-
|
|
23
|
+
changed = perform_apdl_sync(engine)
|
|
24
24
|
except Exception as exc:
|
|
25
25
|
print(f"sync_apdl 失败: {exc}", file=sys.stderr)
|
|
26
26
|
return 1
|
|
27
27
|
|
|
28
|
-
if
|
|
28
|
+
if changed is None:
|
|
29
29
|
print("跳过:未获取到项目路径")
|
|
30
30
|
return 0
|
|
31
31
|
|
|
32
|
-
print(
|
|
32
|
+
print("命令流已变化,已写 prep" if changed else "命令流未变化")
|
|
33
33
|
return 0
|
|
34
34
|
|
|
35
35
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""显示控制命令接口
|
|
2
|
+
|
|
3
|
+
控制边界、荷载、钢束显隐,以及视图方向、显示开关等。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Literal, Sequence, Union
|
|
7
|
+
|
|
8
|
+
from ..core import REGISTRY
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@REGISTRY.register("DispCtrl")
|
|
12
|
+
def osis_disp_ctrl(
|
|
13
|
+
eObject: Literal["bc", "boundary", "lg", "load", "td", "tendon"],
|
|
14
|
+
eType: str,
|
|
15
|
+
ids: Union[str, int, Sequence[Union[str, int]]],
|
|
16
|
+
bShow: Literal[0, 1] = 1,
|
|
17
|
+
):
|
|
18
|
+
"""控制边界 / 荷载 / 钢束的显示与隐藏。
|
|
19
|
+
|
|
20
|
+
格式: ``dispctrl,<Object>,<Type>,<Number/Name...>,<0|1>``
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
eObject (str): 对象类型
|
|
24
|
+
* ``bc`` / ``boundary`` = 边界
|
|
25
|
+
* ``lg`` / ``load`` = 荷载
|
|
26
|
+
* ``td`` / ``tendon`` = 钢束
|
|
27
|
+
eType (str): 子类型
|
|
28
|
+
* 边界: ``all``, ``general``, ``mstslv``, ``release``, ``elstcspt``,
|
|
29
|
+
``generalelstcspt``, ``rigid``, ``secfactor``
|
|
30
|
+
* 荷载: ``all``, ``gravity``, ``nforce``, ``line``, ``pointforce``,
|
|
31
|
+
``pointmoment``, ``displacement``, ``initial``, ``utemp``, ``gtemp``,
|
|
32
|
+
``pst``, ``cforce``, ``elementsurface``
|
|
33
|
+
* 钢束: 通常为 ``all``
|
|
34
|
+
ids: 编号或名称
|
|
35
|
+
* ``all`` = 全部
|
|
36
|
+
* 单个编号 / 名称,或多个组成的序列(如 ``[1, 2, "3to10"]``、``["T1", "T2"]``)
|
|
37
|
+
bShow (int): ``0`` = 隐藏,``1`` = 显示
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
tuple (bool, str): 是否成功,失败原因
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
>>> # 显示全部边界
|
|
44
|
+
>>> osis_disp_ctrl("bc", "all", "all", 1)
|
|
45
|
+
>>> # 显示一般边界 1、2、3to10
|
|
46
|
+
>>> osis_disp_ctrl("bc", "general", [1, 2, "3to10"], 1)
|
|
47
|
+
>>> # 显示全部节点力荷载
|
|
48
|
+
>>> osis_disp_ctrl("lg", "nforce", "all", 1)
|
|
49
|
+
>>> # 显示名为 DeadLoad 的荷载
|
|
50
|
+
>>> osis_disp_ctrl("lg", "all", "DeadLoad", 1)
|
|
51
|
+
>>> # 隐藏钢束 1、2、3to10
|
|
52
|
+
>>> osis_disp_ctrl("td", "all", [1, 2, "3to10"], 0)
|
|
53
|
+
>>> # 显示钢束 T1、T2
|
|
54
|
+
>>> osis_disp_ctrl("td", "all", ["T1", "T2"], 1)
|
|
55
|
+
"""
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@REGISTRY.register("/control")
|
|
60
|
+
def osis_control(
|
|
61
|
+
eAction: str,
|
|
62
|
+
eArg: str | None = None,
|
|
63
|
+
):
|
|
64
|
+
"""视图 / 界面控制命令。
|
|
65
|
+
|
|
66
|
+
格式: ``/control,<Action>[,<Arg>]``
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
eAction (str): 子命令
|
|
70
|
+
* ``view`` = 切换视图方向(配合 eArg)
|
|
71
|
+
* 其他如 ``quickCreateModel`` 等
|
|
72
|
+
eArg (str | None): 子命令参数
|
|
73
|
+
* 当 eAction 为 ``view`` 时: ``standard`` / ``top`` / ``right`` / ``front``
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
tuple (bool, str): 是否成功,失败原因
|
|
77
|
+
|
|
78
|
+
Examples:
|
|
79
|
+
>>> osis_control("view", "standard")
|
|
80
|
+
>>> osis_control("view", "top")
|
|
81
|
+
>>> osis_control("view", "right")
|
|
82
|
+
>>> osis_control("view", "front")
|
|
83
|
+
"""
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@REGISTRY.register("Plsm")
|
|
88
|
+
def osis_plsm(bFlag: Literal[0, 1] = 1):
|
|
89
|
+
"""显示开关(Plsm)。
|
|
90
|
+
|
|
91
|
+
格式: ``plsm,<0|1>``
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
bFlag (int): ``0`` = 关,``1`` = 开
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
tuple (bool, str): 是否成功,失败原因
|
|
98
|
+
|
|
99
|
+
Examples:
|
|
100
|
+
>>> osis_plsm(1)
|
|
101
|
+
>>> osis_plsm(0)
|
|
102
|
+
"""
|
|
103
|
+
pass
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""显示管理器 - 控制显隐、视图方向与显示开关
|
|
2
|
+
|
|
3
|
+
设计理念:
|
|
4
|
+
- 隐藏底层命令接口细节,提供原生 Python 风格 API
|
|
5
|
+
- 无状态设计,操作直接提交到 OSIS
|
|
6
|
+
|
|
7
|
+
用法:
|
|
8
|
+
>>> from pyosis.display import display_manager
|
|
9
|
+
>>> display_manager.disp_ctrl("bc", "all", "all", 1)
|
|
10
|
+
>>> display_manager.set_view("top")
|
|
11
|
+
>>> display_manager.set_plsm(1)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Literal, Sequence, Union
|
|
17
|
+
|
|
18
|
+
from .interface import osis_control, osis_disp_ctrl, osis_plsm
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DisplayManager:
|
|
22
|
+
"""显示管理器
|
|
23
|
+
|
|
24
|
+
控制边界 / 荷载 / 钢束显隐、视图方向与显示开关。
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def disp_ctrl(
|
|
28
|
+
self,
|
|
29
|
+
obj: Literal["bc", "boundary", "lg", "load", "td", "tendon"],
|
|
30
|
+
type: str,
|
|
31
|
+
ids: Union[str, int, Sequence[Union[str, int]]],
|
|
32
|
+
show: Literal[0, 1] = 1,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""控制边界 / 荷载 / 钢束的显示与隐藏。
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
obj: 对象类型
|
|
38
|
+
* ``bc`` / ``boundary`` = 边界
|
|
39
|
+
* ``lg`` / ``load`` = 荷载
|
|
40
|
+
* ``td`` / ``tendon`` = 钢束
|
|
41
|
+
type: 子类型(``all`` 或具体类型,见 ``osis_disp_ctrl`` 文档)
|
|
42
|
+
ids: 编号或名称(``all`` / 单个 / 序列)
|
|
43
|
+
show: ``0`` = 隐藏,``1`` = 显示
|
|
44
|
+
|
|
45
|
+
Raises:
|
|
46
|
+
RuntimeError: 操作失败时抛出异常
|
|
47
|
+
|
|
48
|
+
Examples:
|
|
49
|
+
>>> display_manager.disp_ctrl("bc", "all", "all", 1)
|
|
50
|
+
>>> display_manager.disp_ctrl("bc", "general", [1, 2, "3to10"], 1)
|
|
51
|
+
>>> display_manager.disp_ctrl("lg", "nforce", "all", 1)
|
|
52
|
+
>>> display_manager.disp_ctrl("td", "all", ["T1", "T2"], 1)
|
|
53
|
+
"""
|
|
54
|
+
ok, err = osis_disp_ctrl(obj, type, ids, show)
|
|
55
|
+
if not ok:
|
|
56
|
+
raise RuntimeError(f"显示控制失败: {err}")
|
|
57
|
+
|
|
58
|
+
def control(self, action: str, arg: str | None = None) -> None:
|
|
59
|
+
"""视图 / 界面控制(对应 ``/control,...``)。
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
action: 子命令,如 ``view``、``quickCreateModel``
|
|
63
|
+
arg: 子命令参数;``view`` 时为 ``standard`` / ``top`` / ``right`` / ``front``
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
RuntimeError: 操作失败时抛出异常
|
|
67
|
+
"""
|
|
68
|
+
ok, err = osis_control(action, arg)
|
|
69
|
+
if not ok:
|
|
70
|
+
raise RuntimeError(f"界面控制失败: {err}")
|
|
71
|
+
|
|
72
|
+
def set_view(
|
|
73
|
+
self,
|
|
74
|
+
view: Literal["standard", "top", "right", "front"] = "standard",
|
|
75
|
+
) -> None:
|
|
76
|
+
"""切换视图方向。
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
view: ``standard`` / ``top`` / ``right`` / ``front``
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
RuntimeError: 操作失败时抛出异常
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
>>> display_manager.set_view("top")
|
|
86
|
+
>>> display_manager.set_view("front")
|
|
87
|
+
"""
|
|
88
|
+
self.control("view", view)
|
|
89
|
+
|
|
90
|
+
def set_plsm(self, enabled: Literal[0, 1] = 1) -> None:
|
|
91
|
+
"""显示开关(Plsm)。
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
enabled: ``0`` = 关,``1`` = 开
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
RuntimeError: 操作失败时抛出异常
|
|
98
|
+
|
|
99
|
+
Examples:
|
|
100
|
+
>>> display_manager.set_plsm(1)
|
|
101
|
+
>>> display_manager.set_plsm(0)
|
|
102
|
+
"""
|
|
103
|
+
ok, err = osis_plsm(enabled)
|
|
104
|
+
if not ok:
|
|
105
|
+
raise RuntimeError(f"设置 Plsm 失败: {err}")
|
|
106
|
+
|
|
107
|
+
def __repr__(self) -> str:
|
|
108
|
+
return "DisplayManager()"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# ═════════════════════════════════════════════
|
|
112
|
+
# 全局单例
|
|
113
|
+
# ═════════════════════════════════════════════
|
|
114
|
+
|
|
115
|
+
display_manager = DisplayManager()
|
|
@@ -298,6 +298,15 @@ class ElementGroupManager:
|
|
|
298
298
|
Args:
|
|
299
299
|
name: 单元组名称
|
|
300
300
|
op: 操作
|
|
301
|
+
* c = 创建
|
|
302
|
+
* a = 添加
|
|
303
|
+
* s = 替换
|
|
304
|
+
* r = 移除
|
|
305
|
+
* aa = 添加全部
|
|
306
|
+
* ra = 移除全部
|
|
307
|
+
* m = 修改组名
|
|
308
|
+
* d = 删除
|
|
309
|
+
*param (str | int): 待操作的编号,支持的格式:*,*to*;*by*,仅用于替换。例子:2,3,5,8to10,2by3,5by6,8by10 重合的编号自动忽略
|
|
301
310
|
|
|
302
311
|
Returns:
|
|
303
312
|
ElementGroup: 创建的单元组对象
|
|
@@ -43,7 +43,8 @@ def save_project(filePath) -> Tuple[bool, str]:
|
|
|
43
43
|
保存项目
|
|
44
44
|
|
|
45
45
|
Args:
|
|
46
|
-
|
|
46
|
+
filePath: 工程文件路径。为空时由上层补全为当前工程路径;
|
|
47
|
+
非空时使用该路径。
|
|
47
48
|
|
|
48
49
|
Returns:
|
|
49
50
|
Tuple[bool, str]
|
|
@@ -62,3 +63,13 @@ def save_project_as(filePath) -> Tuple[bool, str]:
|
|
|
62
63
|
Tuple[bool, str]
|
|
63
64
|
"""
|
|
64
65
|
pass
|
|
66
|
+
|
|
67
|
+
@REGISTRY.register("/Close")
|
|
68
|
+
def close_osis() -> Tuple[bool, str]:
|
|
69
|
+
"""
|
|
70
|
+
关闭 OSIS 项目
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Tuple[bool, str]
|
|
74
|
+
"""
|
|
75
|
+
pass
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
用法:
|
|
4
4
|
>>> from pyosis.project import project_manager
|
|
5
|
-
>>> project_manager.create(type=1, filepath="D:/Models/bridge.
|
|
6
|
-
>>> project_manager.open("D:/Models/bridge.
|
|
5
|
+
>>> project_manager.create(type=1, filepath="D:/Models/bridge.sis")
|
|
6
|
+
>>> project_manager.open("D:/Models/bridge.sis")
|
|
7
7
|
>>> project_manager.save()
|
|
8
|
-
>>> project_manager.
|
|
8
|
+
>>> project_manager.save("D:/Models/bridge.sis")
|
|
9
|
+
>>> project_manager.save_as("D:/Models/bridge_v2.sis")
|
|
10
|
+
>>> project_manager.close()
|
|
9
11
|
>>> project_manager.get_directory()
|
|
10
12
|
"""
|
|
11
13
|
|
|
@@ -16,6 +18,7 @@ from .interface import (
|
|
|
16
18
|
open_project,
|
|
17
19
|
save_project,
|
|
18
20
|
save_project_as,
|
|
21
|
+
close_osis,
|
|
19
22
|
get_project_directory,
|
|
20
23
|
)
|
|
21
24
|
|
|
@@ -53,13 +56,19 @@ class ProjectManager:
|
|
|
53
56
|
if not ok:
|
|
54
57
|
raise RuntimeError(f"打开项目失败: {err}")
|
|
55
58
|
|
|
56
|
-
def save(self) -> None:
|
|
57
|
-
"""
|
|
59
|
+
def save(self, filepath: str = "") -> None:
|
|
60
|
+
"""保存项目
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
filepath: 工程文件路径。为空时使用当前项目路径;
|
|
64
|
+
非空时使用传入路径。
|
|
58
65
|
|
|
59
66
|
Raises:
|
|
60
67
|
RuntimeError: 保存失败时抛出异常
|
|
61
68
|
"""
|
|
62
|
-
|
|
69
|
+
if not filepath:
|
|
70
|
+
filepath = self._current_project_file()
|
|
71
|
+
ok, err = save_project(filepath)
|
|
63
72
|
if not ok:
|
|
64
73
|
raise RuntimeError(f"保存项目失败: {err}")
|
|
65
74
|
|
|
@@ -76,6 +85,16 @@ class ProjectManager:
|
|
|
76
85
|
if not ok:
|
|
77
86
|
raise RuntimeError(f"另存为失败: {err}")
|
|
78
87
|
|
|
88
|
+
def close(self) -> None:
|
|
89
|
+
"""关闭 OSIS 项目
|
|
90
|
+
|
|
91
|
+
Raises:
|
|
92
|
+
RuntimeError: 关闭失败时抛出异常
|
|
93
|
+
"""
|
|
94
|
+
ok, err = close_osis()
|
|
95
|
+
if not ok:
|
|
96
|
+
raise RuntimeError(f"关闭软件失败: {err}")
|
|
97
|
+
|
|
79
98
|
def get_directory(self) -> str:
|
|
80
99
|
"""获取当前项目目录
|
|
81
100
|
|
|
@@ -90,6 +109,11 @@ class ProjectManager:
|
|
|
90
109
|
except Exception as e:
|
|
91
110
|
raise RuntimeError(f"获取项目目录失败: {e}")
|
|
92
111
|
|
|
112
|
+
def _current_project_file(self) -> str:
|
|
113
|
+
"""由当前项目目录推导工程文件路径(目录同名 .sis)。"""
|
|
114
|
+
directory = self.get_directory().rstrip("\\/")
|
|
115
|
+
return f"{directory}.sis"
|
|
116
|
+
|
|
93
117
|
def __repr__(self) -> str:
|
|
94
118
|
return "ProjectManager()"
|
|
95
119
|
|