osis-python 0.5.2__tar.gz → 0.5.3__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.
Files changed (116) hide show
  1. {osis_python-0.5.2/src/osis_python.egg-info → osis_python-0.5.3}/PKG-INFO +1 -1
  2. {osis_python-0.5.2 → osis_python-0.5.3/src/osis_python.egg-info}/PKG-INFO +1 -1
  3. {osis_python-0.5.2 → osis_python-0.5.3}/src/osis_python.egg-info/SOURCES.txt +5 -1
  4. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/__init__.py +1 -1
  5. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/all_func.py +2 -1
  6. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/engine.py +24 -3
  7. osis_python-0.5.3/src/pyosis/display/__init__.py +8 -0
  8. osis_python-0.5.3/src/pyosis/display/interface.py +103 -0
  9. osis_python-0.5.3/src/pyosis/display/manager.py +115 -0
  10. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/project/interface.py +12 -1
  11. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/project/manager.py +30 -6
  12. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/routes.py +6 -0
  13. osis_python-0.5.3/tests/test_project_manager.py +135 -0
  14. {osis_python-0.5.2 → osis_python-0.5.3}/LICENSE +0 -0
  15. {osis_python-0.5.2 → osis_python-0.5.3}/README.md +0 -0
  16. {osis_python-0.5.2 → osis_python-0.5.3}/pyproject.toml +0 -0
  17. {osis_python-0.5.2 → osis_python-0.5.3}/setup.cfg +0 -0
  18. {osis_python-0.5.2 → osis_python-0.5.3}/src/osis_python.egg-info/dependency_links.txt +0 -0
  19. {osis_python-0.5.2 → osis_python-0.5.3}/src/osis_python.egg-info/requires.txt +0 -0
  20. {osis_python-0.5.2 → osis_python-0.5.3}/src/osis_python.egg-info/top_level.txt +0 -0
  21. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/boundary/__init__.py +0 -0
  22. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/boundary/interface.py +0 -0
  23. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/boundary/manager.py +0 -0
  24. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/control/__init__.py +0 -0
  25. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/control/control.py +0 -0
  26. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/control/io.py +0 -0
  27. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/control/manager.py +0 -0
  28. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/control/nonlinear.py +0 -0
  29. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/__init__.py +0 -0
  30. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/apdl_sync.py +0 -0
  31. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/basic_manager.py +0 -0
  32. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/build.py +0 -0
  33. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/client.py +0 -0
  34. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/command.py +0 -0
  35. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/exceptions.py +0 -0
  36. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/references.py +0 -0
  37. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/core/sync_apdl_cli.py +0 -0
  38. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/dynamic/__init__.py +0 -0
  39. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/dynamic/load_to_mass.py +0 -0
  40. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/dynamic/manager.py +0 -0
  41. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/dynamic/modal.py +0 -0
  42. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/dynamic/seismic.py +0 -0
  43. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/element/__init__.py +0 -0
  44. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/element/interface.py +0 -0
  45. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/element/manager.py +0 -0
  46. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/general/__init__.py +0 -0
  47. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/general/interface.py +0 -0
  48. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/geometry/__init__.py +0 -0
  49. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/geometry/interface.py +0 -0
  50. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/geometry/manager.py +0 -0
  51. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/live/__init__.py +0 -0
  52. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/live/analysis.py +0 -0
  53. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/live/grade.py +0 -0
  54. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/live/lane.py +0 -0
  55. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/live/manager.py +0 -0
  56. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/load/__init__.py +0 -0
  57. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/load/loadcase.py +0 -0
  58. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/load/manager.py +0 -0
  59. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/load/static.py +0 -0
  60. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/load/tendon.py +0 -0
  61. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/material/__init__.py +0 -0
  62. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/material/interface.py +0 -0
  63. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/material/manager.py +0 -0
  64. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/node/__init__.py +0 -0
  65. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/node/interface.py +0 -0
  66. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/node/manager.py +0 -0
  67. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/post/__init__.py +0 -0
  68. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/post/combine.py +0 -0
  69. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/post/design_check.py +0 -0
  70. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/post/display.py +0 -0
  71. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/post/manager.py +0 -0
  72. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/project/__init__.py +0 -0
  73. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/__init__.py +0 -0
  74. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/component_thickness.py +0 -0
  75. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/coordinate.py +0 -0
  76. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/creep_shrink.py +0 -0
  77. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/damping.py +0 -0
  78. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/manager.py +0 -0
  79. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/property/pu_curve.py +0 -0
  80. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/quick_building/__init__.py +0 -0
  81. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/quick_building/interface.py +0 -0
  82. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/__init__.py +0 -0
  83. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/check.py +0 -0
  84. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/env.py +0 -0
  85. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/loadcase.py +0 -0
  86. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/manager.py +0 -0
  87. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/result/result.py +0 -0
  88. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/__init__.py +0 -0
  89. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/common.py +0 -0
  90. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/composite.py +0 -0
  91. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/manager.py +0 -0
  92. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/numeric.py +0 -0
  93. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/param.py +0 -0
  94. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/rebar.py +0 -0
  95. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/rib.py +0 -0
  96. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/section/steel.py +0 -0
  97. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/settlement/__init__.py +0 -0
  98. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/settlement/interface.py +0 -0
  99. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/settlement/manager.py +0 -0
  100. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stability/__init__.py +0 -0
  101. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stability/buckling.py +0 -0
  102. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stability/manager.py +0 -0
  103. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stage/__init__.py +0 -0
  104. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stage/define.py +0 -0
  105. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stage/manager.py +0 -0
  106. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/stage/overall.py +0 -0
  107. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/thickness/__init__.py +0 -0
  108. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/thickness/interface.py +0 -0
  109. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/thickness/manager.py +0 -0
  110. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/__init__.py +0 -0
  111. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/generator.py +0 -0
  112. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/matrix.py +0 -0
  113. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/out_to_python.py +0 -0
  114. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/parser.py +0 -0
  115. {osis_python-0.5.2 → osis_python-0.5.3}/src/pyosis/transfer/split.py +0 -0
  116. {osis_python-0.5.2 → osis_python-0.5.3}/tests/test_delete_occupied.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osis-python
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: A Python client library for Osis APDL
5
5
  Author-email: "CCCC Highway Consultant Co. Ltd." <support@osisbim.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osis-python
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: A Python client library for Osis APDL
5
5
  Author-email: "CCCC Highway Consultant Co. Ltd." <support@osisbim.com>
6
6
  License-Expression: MIT
@@ -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.2"
10
+ __version__ = "0.5.3"
11
11
  __author__ = "CCCC Highway Consultant Co. Ltd." # 中交公路规划设计院 - 工程技术研究中心 - lzh - wjh - myf
12
12
 
13
13
  from .core.engine import OSISEngine
@@ -19,4 +19,5 @@ from ..settlement import *
19
19
  from ..stability import *
20
20
 
21
21
  from ..post import *
22
- from ..result import *
22
+ from ..result import *
23
+ from ..display import *
@@ -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,13 @@ 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
+
231
243
  # ──────────────────────────────────────────
232
244
  # 通用操作(直接暴露 general 和 core 的函数)
233
245
  # ──────────────────────────────────────────
@@ -297,9 +309,14 @@ class OSISEngine:
297
309
  # 便捷方法(委托给 project manager)
298
310
  # ──────────────────────────────────────────
299
311
 
300
- def save_project(self) -> None:
301
- """保存当前项目"""
302
- self._project.save()
312
+ def save_project(self, filepath: str = "") -> None:
313
+ """保存项目
314
+
315
+ Args:
316
+ filepath: 工程文件路径。为空时使用当前项目路径;
317
+ 非空时使用传入路径。
318
+ """
319
+ self._project.save(filepath)
303
320
 
304
321
  def new_project(self, type: int = 1, filepath: str = "") -> None:
305
322
  """新建项目
@@ -318,6 +335,10 @@ class OSISEngine:
318
335
  """
319
336
  self._project.open(filepath)
320
337
 
338
+ def close(self) -> None:
339
+ """关闭 OSIS 软件"""
340
+ self._project.close()
341
+
321
342
  # ──────────────────────────────────────────
322
343
  # 便捷方法(委托给 control manager)
323
344
  # ──────────────────────────────────────────
@@ -0,0 +1,8 @@
1
+ """
2
+ pyosis.display
3
+
4
+ 显示控制(显隐、视图方向、显示开关等)
5
+ """
6
+
7
+ from .interface import *
8
+ from .manager import DisplayManager, display_manager
@@ -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()
@@ -43,7 +43,8 @@ def save_project(filePath) -> Tuple[bool, str]:
43
43
  保存项目
44
44
 
45
45
  Args:
46
- filepath: 为空或者当前工程文件路径
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.osis")
6
- >>> project_manager.open("D:/Models/bridge.osis")
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.save_as("D:/Models/bridge_v2.osis")
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
- ok, err = save_project("")
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
 
@@ -173,6 +173,12 @@ ROUTES = {
173
173
  "/Open": "engine.open_project",
174
174
  "/Save": "engine.save_project",
175
175
  "/SaveAs": "engine.project.save_as",
176
+ "/Close": "engine.close",
177
+
178
+ # ─── DISPLAY ───
179
+ "DispCtrl": "engine.display.disp_ctrl",
180
+ "/control": "engine.display.control",
181
+ "Plsm": "engine.display.set_plsm",
176
182
 
177
183
  # ─── GENERAL ───
178
184
  "Clear": "engine.clear",
@@ -0,0 +1,135 @@
1
+ """
2
+ 测试 ProjectManager(create / open / save / save_as / get_directory)
3
+
4
+ 前置条件: OSIS 已打开。
5
+
6
+ 使用方式:
7
+ python tests/test_project_manager.py
8
+
9
+ 说明:
10
+ create / open / save_as 传入完整 .sis 路径;
11
+ create 只创建项目目录,不会生成 .sis 文件;
12
+ save / save_as 后才会在磁盘上生成 .sis 工程文件;
13
+ close 关闭 OSIS 软件(测试最后一步,执行后需重新打开 OSIS)。
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import os
19
+ import time
20
+
21
+ from pyosis.core.engine import OSISEngine
22
+
23
+
24
+ def _expect_eq(actual, expected, label: str) -> None:
25
+ if actual != expected:
26
+ raise ValueError(f"{label} 不符: 期望 {expected!r}, 实际 {actual!r}")
27
+
28
+
29
+ def _expect_true(cond: bool, msg: str) -> None:
30
+ if not cond:
31
+ raise ValueError(msg)
32
+
33
+
34
+ def _norm_path(path: str) -> str:
35
+ """规范化路径,去掉末尾分隔符便于比较。"""
36
+ return os.path.normcase(os.path.normpath(path.rstrip("\\/")))
37
+
38
+
39
+ def _expected_project_dir(filepath: str) -> str:
40
+ """由 .sis 完整路径推导项目目录(去掉扩展名)。"""
41
+ return os.path.splitext(filepath)[0]
42
+
43
+
44
+ def _sibling_names(filepath: str) -> list[str]:
45
+ parent = os.path.dirname(filepath) or "."
46
+ if not os.path.isdir(parent):
47
+ return []
48
+ return sorted(os.listdir(parent))
49
+
50
+
51
+ def _wait_isfile(filepath: str, timeout: float = 3.0, interval: float = 0.2) -> bool:
52
+ """等待文件出现(兼顾落盘延迟)。"""
53
+ deadline = time.time() + timeout
54
+ while time.time() < deadline:
55
+ if os.path.isfile(filepath):
56
+ return True
57
+ time.sleep(interval)
58
+ return os.path.isfile(filepath)
59
+
60
+
61
+ def _expect_sis_file(filepath: str, label: str) -> None:
62
+ """断言工程文件为 .sis,失败时打印同级目录内容。"""
63
+ _expect_true(filepath.lower().endswith(".sis"), f"{label} 路径应为 .sis: {filepath}")
64
+ if _wait_isfile(filepath):
65
+ return
66
+ siblings = _sibling_names(filepath)
67
+ raise ValueError(
68
+ f"{label} 后应存在文件: {filepath}\n"
69
+ f" 同级目录内容: {siblings}"
70
+ )
71
+
72
+
73
+ def test_project(engine: OSISEngine, filepath: str) -> None:
74
+ """依次验证 create / get_directory / save / save_as / open。
75
+
76
+ Args:
77
+ filepath: 项目文件完整路径,例如 "D:\Temp\demo.sis"
78
+ """
79
+ project = engine.project
80
+ expected_dir = _expected_project_dir(filepath)
81
+ path2 = os.path.splitext(filepath)[0] + "_v2.sis"
82
+
83
+ # ── create:只建目录,不生成 .sis ──
84
+ project.create(type=101, filepath=filepath)
85
+ print(f" create -> {filepath}")
86
+ _expect_true(
87
+ not os.path.isfile(filepath),
88
+ f"create 后不应生成 .sis 文件: {filepath}",
89
+ )
90
+
91
+ # ── get_directory ──
92
+ directory = project.get_directory()
93
+ print(f" get_directory -> {directory}")
94
+ _expect_true(isinstance(directory, str) and len(directory) > 0, "get_directory 应返回非空路径")
95
+ _expect_eq(_norm_path(directory), _norm_path(expected_dir), "项目目录")
96
+ _expect_true(os.path.isdir(expected_dir), f"项目目录应存在: {expected_dir}")
97
+
98
+ # ── save:路径为空时使用当前项目路径,此时才生成 .sis ──
99
+ project.save()
100
+ print(" save() -> 当前项目路径")
101
+ _expect_sis_file(filepath, "save")
102
+
103
+ # ── save:显式传入路径 ──
104
+ project.save(filepath)
105
+ print(f" save({filepath})")
106
+ _expect_sis_file(filepath, "save(显式路径)")
107
+
108
+ # ── save_as ──
109
+ project.save_as(path2)
110
+ print(f" save_as -> {path2}")
111
+ _expect_sis_file(path2, "save_as")
112
+
113
+ # ── open ──
114
+ project.open(path2)
115
+ print(f" open -> {path2}")
116
+ directory2 = project.get_directory()
117
+ print(f" get_directory -> {directory2}")
118
+ _expect_eq(
119
+ _norm_path(directory2),
120
+ _norm_path(_expected_project_dir(path2)),
121
+ "另存为后打开的项目目录",
122
+ )
123
+
124
+ # ── close:关闭软件 ──
125
+ project.close()
126
+ print(" close ok(OSIS 已退出)")
127
+
128
+
129
+ if __name__ == "__main__":
130
+ engine = OSISEngine()
131
+ filepath = r"D:\Temp\demo5555555.sis"
132
+ print(f"项目文件: {filepath}")
133
+ print("开始测试 ProjectManager ...")
134
+ test_project(engine, filepath)
135
+ print("全部通过")
File without changes
File without changes
File without changes
File without changes