osis-python 0.7.5__tar.gz → 0.7.7__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 (123) hide show
  1. {osis_python-0.7.5/src/osis_python.egg-info → osis_python-0.7.7}/PKG-INFO +1 -1
  2. {osis_python-0.7.5 → osis_python-0.7.7/src/osis_python.egg-info}/PKG-INFO +1 -1
  3. {osis_python-0.7.5 → osis_python-0.7.7}/src/osis_python.egg-info/SOURCES.txt +5 -1
  4. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/__init__.py +1 -1
  5. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/control/manager.py +20 -0
  6. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/__init__.py +1 -0
  7. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/apdl_sync.py +4 -1
  8. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/client.py +50 -0
  9. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/engine.py +25 -0
  10. osis_python-0.7.7/src/pyosis/core/sdk.py +76 -0
  11. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/solver.py +18 -2
  12. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/load/manager.py +17 -0
  13. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/material/manager.py +20 -0
  14. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/node/manager.py +20 -0
  15. osis_python-0.7.7/src/pyosis/result/__init__.py +12 -0
  16. osis_python-0.7.7/src/pyosis/result/headless.py +122 -0
  17. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/result/manager.py +66 -0
  18. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/manager.py +17 -0
  19. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/generator.py +53 -21
  20. osis_python-0.7.7/src/pyosis/transfer/introspect.py +149 -0
  21. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/out_to_python.py +49 -3
  22. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/routes.py +49 -5
  23. osis_python-0.7.7/tests/test_transfer_fixups.py +126 -0
  24. osis_python-0.7.5/src/pyosis/result/__init__.py +0 -4
  25. {osis_python-0.7.5 → osis_python-0.7.7}/LICENSE +0 -0
  26. {osis_python-0.7.5 → osis_python-0.7.7}/README.md +0 -0
  27. {osis_python-0.7.5 → osis_python-0.7.7}/pyproject.toml +0 -0
  28. {osis_python-0.7.5 → osis_python-0.7.7}/setup.cfg +0 -0
  29. {osis_python-0.7.5 → osis_python-0.7.7}/src/osis_python.egg-info/dependency_links.txt +0 -0
  30. {osis_python-0.7.5 → osis_python-0.7.7}/src/osis_python.egg-info/requires.txt +0 -0
  31. {osis_python-0.7.5 → osis_python-0.7.7}/src/osis_python.egg-info/top_level.txt +0 -0
  32. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/boundary/__init__.py +0 -0
  33. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/boundary/interface.py +0 -0
  34. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/boundary/manager.py +0 -0
  35. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/control/__init__.py +0 -0
  36. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/control/control.py +0 -0
  37. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/control/io.py +0 -0
  38. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/control/nonlinear.py +0 -0
  39. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/all_func.py +0 -0
  40. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/basic_manager.py +0 -0
  41. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/batch.py +0 -0
  42. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/command.py +0 -0
  43. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/exceptions.py +0 -0
  44. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/references.py +0 -0
  45. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/core/sync_apdl_cli.py +0 -0
  46. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/display/__init__.py +0 -0
  47. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/display/interface.py +0 -0
  48. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/display/manager.py +0 -0
  49. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/dynamic/__init__.py +0 -0
  50. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/dynamic/load_to_mass.py +0 -0
  51. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/dynamic/manager.py +0 -0
  52. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/dynamic/modal.py +0 -0
  53. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/dynamic/seismic.py +0 -0
  54. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/element/__init__.py +0 -0
  55. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/element/interface.py +0 -0
  56. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/element/manager.py +0 -0
  57. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/general/__init__.py +0 -0
  58. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/general/interface.py +0 -0
  59. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/geometry/__init__.py +0 -0
  60. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/geometry/interface.py +0 -0
  61. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/geometry/manager.py +0 -0
  62. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/live/__init__.py +0 -0
  63. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/live/analysis.py +0 -0
  64. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/live/grade.py +0 -0
  65. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/live/lane.py +0 -0
  66. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/live/manager.py +0 -0
  67. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/load/__init__.py +0 -0
  68. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/load/loadcase.py +0 -0
  69. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/load/static.py +0 -0
  70. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/load/tendon.py +0 -0
  71. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/material/__init__.py +0 -0
  72. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/material/interface.py +0 -0
  73. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/node/__init__.py +0 -0
  74. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/node/interface.py +0 -0
  75. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/post/__init__.py +0 -0
  76. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/post/combine.py +0 -0
  77. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/post/design_check.py +0 -0
  78. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/post/display.py +0 -0
  79. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/post/manager.py +0 -0
  80. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/project/__init__.py +0 -0
  81. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/project/interface.py +0 -0
  82. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/project/manager.py +0 -0
  83. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/__init__.py +0 -0
  84. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/component_thickness.py +0 -0
  85. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/coordinate.py +0 -0
  86. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/creep_shrink.py +0 -0
  87. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/damping.py +0 -0
  88. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/manager.py +0 -0
  89. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/property/pu_curve.py +0 -0
  90. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/quick_building/__init__.py +0 -0
  91. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/quick_building/interface.py +0 -0
  92. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/result/check.py +0 -0
  93. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/result/env.py +0 -0
  94. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/result/loadcase.py +0 -0
  95. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/result/result.py +0 -0
  96. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/__init__.py +0 -0
  97. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/common.py +0 -0
  98. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/composite.py +0 -0
  99. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/numeric.py +0 -0
  100. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/param.py +0 -0
  101. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/rebar.py +0 -0
  102. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/rib.py +0 -0
  103. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/section/steel.py +0 -0
  104. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/settlement/__init__.py +0 -0
  105. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/settlement/interface.py +0 -0
  106. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/settlement/manager.py +0 -0
  107. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stability/__init__.py +0 -0
  108. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stability/buckling.py +0 -0
  109. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stability/manager.py +0 -0
  110. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stage/__init__.py +0 -0
  111. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stage/define.py +0 -0
  112. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stage/manager.py +0 -0
  113. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/stage/overall.py +0 -0
  114. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/thickness/__init__.py +0 -0
  115. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/thickness/interface.py +0 -0
  116. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/thickness/manager.py +0 -0
  117. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/__init__.py +0 -0
  118. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/matrix.py +0 -0
  119. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/parser.py +0 -0
  120. {osis_python-0.7.5 → osis_python-0.7.7}/src/pyosis/transfer/split.py +0 -0
  121. {osis_python-0.7.5 → osis_python-0.7.7}/tests/test_batch.py +0 -0
  122. {osis_python-0.7.5 → osis_python-0.7.7}/tests/test_delete_occupied.py +0 -0
  123. {osis_python-0.7.5 → osis_python-0.7.7}/tests/test_project_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osis-python
3
- Version: 0.7.5
3
+ Version: 0.7.7
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.7.5
3
+ Version: 0.7.7
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
@@ -25,6 +25,7 @@ src/pyosis/core/command.py
25
25
  src/pyosis/core/engine.py
26
26
  src/pyosis/core/exceptions.py
27
27
  src/pyosis/core/references.py
28
+ src/pyosis/core/sdk.py
28
29
  src/pyosis/core/solver.py
29
30
  src/pyosis/core/sync_apdl_cli.py
30
31
  src/pyosis/display/__init__.py
@@ -79,6 +80,7 @@ src/pyosis/quick_building/interface.py
79
80
  src/pyosis/result/__init__.py
80
81
  src/pyosis/result/check.py
81
82
  src/pyosis/result/env.py
83
+ src/pyosis/result/headless.py
82
84
  src/pyosis/result/loadcase.py
83
85
  src/pyosis/result/manager.py
84
86
  src/pyosis/result/result.py
@@ -106,6 +108,7 @@ src/pyosis/thickness/interface.py
106
108
  src/pyosis/thickness/manager.py
107
109
  src/pyosis/transfer/__init__.py
108
110
  src/pyosis/transfer/generator.py
111
+ src/pyosis/transfer/introspect.py
109
112
  src/pyosis/transfer/matrix.py
110
113
  src/pyosis/transfer/out_to_python.py
111
114
  src/pyosis/transfer/parser.py
@@ -113,4 +116,5 @@ src/pyosis/transfer/routes.py
113
116
  src/pyosis/transfer/split.py
114
117
  tests/test_batch.py
115
118
  tests/test_delete_occupied.py
116
- tests/test_project_manager.py
119
+ tests/test_project_manager.py
120
+ tests/test_transfer_fixups.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.7.5"
10
+ __version__ = "0.7.7"
11
11
 
12
12
  from .core.engine import OSISEngine
13
13
  from .core.batch import batch, flush, batch_state, BatchError
@@ -18,6 +18,7 @@ from __future__ import annotations
18
18
  from typing import Literal
19
19
 
20
20
  from ..core import osis_run
21
+ from ..core.client import osis_client
21
22
  from .control import (
22
23
  osis_acel,
23
24
  osis_calc_tendon,
@@ -373,6 +374,25 @@ class ControlManager:
373
374
  if not ok:
374
375
  raise RuntimeError(f"设置模态分析参数失败: {err}")
375
376
 
377
+ # ── 查询 ────────────────────────────────────
378
+
379
+ def summary(self) -> list[dict]:
380
+ '''获取分析控制摘要(走 GetAnalysisControlSummary 端点)
381
+
382
+ 汇总当前模型将要执行的分析类型(特征值分析、施工阶段分析等),
383
+ 每项含 name/type/summary/count。
384
+
385
+ Returns:
386
+ list[dict]: 分析控制摘要列表,未定义分析时为空列表
387
+
388
+ Raises:
389
+ RuntimeError: 查询失败时抛出异常
390
+ '''
391
+ resp = osis_client("GetAnalysisControlSummary", {})
392
+ if not resp.get("success"):
393
+ raise RuntimeError(f"{resp.get('error')}")
394
+ return list(resp.get("data") or [])
395
+
376
396
  def __repr__(self) -> str:
377
397
  return "ControlManager()"
378
398
 
@@ -14,3 +14,4 @@ from .batch import batch, flush, batch_state, BatchError
14
14
  from .basic_manager import BasicManager, LazyRef
15
15
  from .exceptions import DependencyError
16
16
  from .references import get_references, raise_if_occupied
17
+ from .sdk import health, sdk_version, list_commands, instance_info
@@ -51,8 +51,11 @@ class ApdlSessionStore:
51
51
 
52
52
 
53
53
  # 读取 .out 文件内容
54
+ # 实测 5.1(2026-10 构建)export_apdl 导出为 UTF-8(无 BOM);UTF-8 中文可能
55
+ # 恰好是合法 GBK,GBK 优先会静默乱码,所以 UTF-8 在前。旧版若导出 GBK,
56
+ # 按 UTF-8 解码通常直接抛错并回落到 GBK,不会误判。
54
57
  def _read_out_text(path: Path) -> str:
55
- for encoding in ("gbk", "utf-8", "gb2312", "gb18030", "latin-1"):
58
+ for encoding in ("utf-8-sig", "utf-8", "gbk", "gb18030", "latin-1"):
56
59
  try:
57
60
  return path.read_text(encoding=encoding)
58
61
  except UnicodeDecodeError:
@@ -102,4 +102,54 @@ def osis_client(
102
102
 
103
103
  except requests.RequestException as e:
104
104
  return {"success": False, "error": f"调用失败: {str(e)}"}
105
+
106
+
107
+ def osis_get(
108
+ path: str,
109
+ base_url=None,
110
+ timeout: float | None = None,
111
+ ) -> dict:
112
+ """
113
+ 通用 OSIS GET 客户端(复用连接池)
114
+
115
+ 用于只绑定 GET 的端点(如 /instance);/health、/sdk/* 同时支持
116
+ GET/POST,查询类调用统一走本函数。
117
+
118
+ Args:
119
+ path: 端点路径(如 "instance",无需前导斜杠)
120
+ Returns:
121
+ 成功时返回端点 JSON;失败时返回 {"success": False, "error": ...}
122
+ """
123
+ from .batch import batch_state, flush as _flush
124
+ if batch_state.active and batch_state.buffer and not batch_state.flushing:
125
+ _flush()
126
+
127
+ base_url = base_url or os.environ.get("OSIS_URL", f"{DEFAULT_URL}:{DEFAULT_PORT}")
128
+ url = f"{base_url}/{path.lstrip('/')}"
129
+
130
+ try:
131
+ response = session.get(
132
+ url,
133
+ timeout=timeout if timeout is not None else DEFAULT_TIMEOUT,
134
+ )
135
+
136
+ data = None
137
+ if response.content:
138
+ try:
139
+ data = response.json()
140
+ except ValueError:
141
+ pass
142
+
143
+ if response.status_code == 404:
144
+ return {"success": False, "error": f"接口不存在: {path}"}
145
+
146
+ if response.ok: # 200-299
147
+ if data is not None:
148
+ return data
149
+ return {"success": False, "error": f"接口返回空数据: {path}"}
150
+
151
+ return {"success": False, "error": f"HTTP {response.status_code}: {response.text[:200]}"}
152
+
153
+ except requests.RequestException as e:
154
+ return {"success": False, "error": f"调用失败: {str(e)}"}
105
155
 
@@ -52,6 +52,7 @@ from ..general.interface import (
52
52
  )
53
53
  from .command import osis_run
54
54
  from .client import set_osis_port, set_osis_url
55
+ from .sdk import sdk_version, list_commands, instance_info, health as _sdk_health
55
56
 
56
57
 
57
58
  class OSISEngine:
@@ -329,6 +330,30 @@ class OSISEngine:
329
330
  """输出计算书所需结果"""
330
331
  return output_result_for_calc_book()
331
332
 
333
+ # ──────────────────────────────────────────
334
+ # 服务端元信息(/sdk/*、/instance)
335
+ # ──────────────────────────────────────────
336
+
337
+ def sdk_version(self) -> dict:
338
+ """查询 SDK/OSIS 版本与 ABI
339
+
340
+ Returns:
341
+ {"success": True, "sdk": 版本串, "osis": 版本串, "abi": ABI, "port": 端口}
342
+ """
343
+ return sdk_version()
344
+
345
+ def list_commands(self) -> list[str]:
346
+ """查询运行时可用命令名(GUI 书册命令不列出)"""
347
+ return list_commands()
348
+
349
+ def instance_info(self) -> dict:
350
+ """查询 OSIS 实例信息(pid/port/project/version/state)"""
351
+ return instance_info()
352
+
353
+ def is_alive(self) -> bool:
354
+ """存活探测(POST /health,不碰工程状态)"""
355
+ return _sdk_health()
356
+
332
357
  # ──────────────────────────────────────────
333
358
  # 便捷方法(委托给 project manager)
334
359
  # ──────────────────────────────────────────
@@ -0,0 +1,76 @@
1
+ """SDK 元信息与服务端实例查询
2
+
3
+ 对应 PySolver 端点 /health、/sdk/version、/sdk/commands、GET /instance。
4
+ 这些端点同时支持 GET/POST(/instance 仅 GET),不依赖工程状态。
5
+
6
+ 用法:
7
+ from pyosis.core.sdk import sdk_version, list_commands, instance_info
8
+ sdk_version() # {"success": True, "sdk": "5.1.x", "osis": ..., "abi": ..., "port": ...}
9
+ list_commands() # 运行时可用的命令名列表
10
+ instance_info() # {"pid": ..., "port": ..., "project": ..., "version": ..., "state": ...}
11
+ """
12
+ from __future__ import annotations
13
+
14
+ from .client import osis_client, osis_get
15
+
16
+
17
+ def health(base_url=None) -> bool:
18
+ """存活探测(POST /health)。
19
+
20
+ 只证明 HTTP server 在跑,不碰工程/command 状态。
21
+
22
+ Returns:
23
+ bool: server 存活返回 True
24
+ """
25
+ resp = osis_client("health", {}, base_url=base_url)
26
+ return bool(resp.get("success"))
27
+
28
+
29
+ def sdk_version(base_url=None) -> dict:
30
+ """查询 SDK/OSIS 版本与 ABI(POST/GET /sdk/version)。
31
+
32
+ Returns:
33
+ {"success": True, "sdk": 版本串, "osis": 版本串, "abi": ABI, "port": 端口}
34
+
35
+ Raises:
36
+ RuntimeError: 查询失败时抛出
37
+ """
38
+ resp = osis_client("sdk/version", {}, base_url=base_url)
39
+ if not resp.get("success"):
40
+ raise RuntimeError(f"查询 SDK 版本失败: {resp.get('error')}")
41
+ return resp
42
+
43
+
44
+ def list_commands(base_url=None) -> list[str]:
45
+ """查询运行时可用命令名(POST/GET /sdk/commands)。
46
+
47
+ 返回当前工程命令流可识别的命令名(GUI 书册命令不列出)。
48
+
49
+ Returns:
50
+ list[str]: 命令名列表
51
+
52
+ Raises:
53
+ RuntimeError: 查询失败时抛出
54
+ """
55
+ resp = osis_client("sdk/commands", {}, base_url=base_url)
56
+ if not resp.get("success"):
57
+ raise RuntimeError(f"查询命令列表失败: {resp.get('error')}")
58
+ return list(resp.get("commands") or [])
59
+
60
+
61
+ def instance_info(base_url=None) -> dict:
62
+ """查询 OSIS 实例信息(GET /instance)。
63
+
64
+ broker 登记实例时用它确认端口实际归属。
65
+
66
+ Returns:
67
+ {"pid": 进程号, "port": HTTP 端口, "project": 工程路径,
68
+ "version": 版本, "state": 实例状态}
69
+
70
+ Raises:
71
+ RuntimeError: 查询失败时抛出
72
+ """
73
+ resp = osis_get("instance", base_url=base_url)
74
+ if not isinstance(resp, dict) or resp.get("error"):
75
+ raise RuntimeError(f"查询实例信息失败: {resp.get('error', resp)}")
76
+ return resp
@@ -22,7 +22,8 @@ class OSISSolver:
22
22
 
23
23
  Args:
24
24
  osis_install_path: OSIS 安装根目录,根目录下需有 PySolver.dll。
25
- port: HTTP server 端口;<0 用 PySolver 默认 18080。端口被占会失败。
25
+ port: HTTP server 端口;<=0 由系统随机分配(bind :0),实际端口
26
+ 回写 self.port;默认 18080。指定端口被占会失败。
26
27
  host: 监听地址,默认 127.0.0.1。
27
28
 
28
29
  Raises:
@@ -83,7 +84,18 @@ class OSISSolver:
83
84
  self._add_dll_search_dir(os.path.dirname(path))
84
85
 
85
86
  try:
86
- lib = ctypes.CDLL(path)
87
+ # Debug 构建的依赖(如 HPDI.OSIS.IO 的 DebugWnd)会在 DLL 静态初始化里
88
+ # AllocConsole + freopen 劫持 stdio——python 宿主的输出被抢走、
89
+ # 解释器退出码变 120。加载前 dup 一份标准流,加载完立刻恢复。
90
+ saved_out = os.dup(1)
91
+ saved_err = os.dup(2)
92
+ try:
93
+ lib = ctypes.CDLL(path)
94
+ finally:
95
+ os.dup2(saved_out, 1)
96
+ os.dup2(saved_err, 2)
97
+ os.close(saved_out)
98
+ os.close(saved_err)
87
99
  except OSError as e:
88
100
  raise RuntimeError(f"OSISSolver: 加载 {path} 失败: {e}")
89
101
 
@@ -102,6 +114,10 @@ class OSISSolver:
102
114
 
103
115
  self._lib = lib
104
116
  self._started = True
117
+ # port<=0(随机分配)时 AutoBootstrap 返回系统分配的实际端口,回写,
118
+ # self.url / engine 连接才指向正确地址
119
+ if actual_port > 0:
120
+ self._port = actual_port
105
121
  self._wait_ready()
106
122
  return self
107
123
 
@@ -1873,6 +1873,23 @@ class TendonManager:
1873
1873
  "shapes": self.shape.count()
1874
1874
  }
1875
1875
 
1876
+ def prestress_loads(self) -> list[dict]:
1877
+ """获取所有预应力荷载(走 GetAllPrestressedLoadInfo 端点)
1878
+
1879
+ 遍历所有荷载工况下的预应力荷载(钢束张拉信息)。
1880
+
1881
+ Returns:
1882
+ list[dict]: 每条含 name/tensionMethod/tensionMethodName/
1883
+ tensionForce/tensionForceName/beg/end/relatedLoadCase/loadCase
1884
+
1885
+ Raises:
1886
+ RuntimeError: 查询失败时抛出异常
1887
+ """
1888
+ resp = osis_client("GetAllPrestressedLoadInfo", {})
1889
+ if not resp.get("success"):
1890
+ raise RuntimeError(f"{resp.get('error')}")
1891
+ return [d for d in resp.get("data") or [] if isinstance(d, dict) and d]
1892
+
1876
1893
  def clear(self) -> None:
1877
1894
  """清空所有钢束形状和钢束特性(先清空形状,再清空特性)"""
1878
1895
  self.shape.clear()
@@ -121,6 +121,26 @@ class MaterialManager(BasicManager):
121
121
 
122
122
  return materials
123
123
 
124
+ def all_prestressed(self) -> list[Material]:
125
+ """获取所有预应力材料(走 GetAllPrestressedMaterialInfo 端点)
126
+
127
+ 与 all() 的区别:只返回材料类型为预应力(PRESTRESSED)的材料,
128
+ 服务端按类型过滤,不需要客户端再筛。
129
+
130
+ Returns:
131
+ list[Material]: 预应力材料列表
132
+
133
+ Raises:
134
+ RuntimeError: 查询失败时抛出异常
135
+ """
136
+ resp = osis_client("GetAllPrestressedMaterialInfo", {})
137
+ if not resp.get("success"):
138
+ raise RuntimeError(f"{resp.get('error')}")
139
+ return [
140
+ Material._from_dict(d) for d in resp.get("data", [])
141
+ if isinstance(d, dict) and "no" in d
142
+ ]
143
+
124
144
  def get_dependencies(self, no: int) -> dict[str, list]:
125
145
  """查询材料被谁引用"""
126
146
  return get_references("Material", no=no)
@@ -111,6 +111,26 @@ class NodeManager(BasicManager):
111
111
  raise RuntimeError(f"{resp['error']}")
112
112
  nodes = [Node._from_dict(d) for d in resp.get("data", []) if "no" in d]
113
113
  return nodes
114
+
115
+ def coordinates(self) -> dict[int, tuple[float, float, float]]:
116
+ """获取所有节点坐标(走 GetCoordinate 端点)
117
+
118
+ 比 all() 更轻量——只要坐标不要分组等附加信息时用这个。
119
+
120
+ Returns:
121
+ dict: {节点编号: (x, y, z)}
122
+
123
+ Raises:
124
+ RuntimeError: 查询失败时抛出异常
125
+ """
126
+ resp = osis_client("GetCoordinate", {})
127
+ if not resp.get("success"):
128
+ raise RuntimeError(f"{resp.get('error')}")
129
+ return {
130
+ d["id"]: (d.get("x", 0.0), d.get("y", 0.0), d.get("z", 0.0))
131
+ for d in resp.get("data") or []
132
+ if isinstance(d, dict) and "id" in d
133
+ }
114
134
 
115
135
  # ── 增删改 ────────────────────────────────
116
136
 
@@ -0,0 +1,12 @@
1
+ from .loadcase import *
2
+ from .check import *
3
+ from .env import *
4
+ from .manager import ResultManager, result_manager
5
+ from .headless import (
6
+ get_node_displacement,
7
+ get_element_force,
8
+ get_support_reaction,
9
+ node_displacement_df,
10
+ element_force_df,
11
+ support_reaction_df,
12
+ )
@@ -0,0 +1,122 @@
1
+ """求解后结果的无头查询
2
+
3
+ 对应 PySolver 端点(v0.2 新增,优先从结果文件读,文件失败回落内存):
4
+ - /GetAllNodeDisplacement、/GetNodeDisplacementByNames 节点位移
5
+ - /GetAllElementForce、/GetElementForceByNames 单元内力
6
+ - /GetAllSupportReaction、/GetSupportReactionByNames 支座反力
7
+
8
+ 与 loadcase/env 走 OSIS_Run 命令流 + txt 导出的路径不同,这组端点
9
+ 直接读求解器结果,无需 GUI 参与,适合无头批量提取。
10
+
11
+ 返回结构(每个工况一个对象):
12
+ {"loadCase": 工况名, "source": "file"|"memory",
13
+ "nodes": [...] / "elements": [...]}
14
+ """
15
+ from __future__ import annotations
16
+
17
+ from ..core.client import osis_client
18
+
19
+ try:
20
+ import pandas as pd
21
+ _HAS_PANDAS = True
22
+ except ImportError:
23
+ _HAS_PANDAS = False
24
+
25
+
26
+ def _query_all(endpoint: str) -> list[dict]:
27
+ resp = osis_client(endpoint, {})
28
+ if not resp.get("success"):
29
+ raise RuntimeError(f"{resp.get('error', endpoint + ' 失败')}")
30
+ return [d for d in resp.get("data") or [] if isinstance(d, dict) and d]
31
+
32
+
33
+ def _query_by_names(endpoint: str, names: str | list[str]) -> list[dict]:
34
+ if isinstance(names, str):
35
+ names = [names]
36
+ resp = osis_client(endpoint, {"name": [str(n) for n in names]})
37
+ if not resp.get("success"):
38
+ raise RuntimeError(f"{resp.get('error', endpoint + ' 失败')}")
39
+ # C++ 端查不到的工况返回空对象,过滤掉
40
+ return [d for d in resp.get("data") or [] if isinstance(d, dict) and d]
41
+
42
+
43
+ # ═════════════════════════════════════════════
44
+ # 原始 dict 查询
45
+ # ═════════════════════════════════════════════
46
+
47
+ def get_node_displacement(name: str | list[str] | None = None) -> list[dict]:
48
+ """查询求解后节点位移
49
+
50
+ Args:
51
+ name: 工况名(str 或 list[str]);None 时返回全部工况
52
+
53
+ Returns:
54
+ list[dict]: 每个工况 {"loadCase", "source", "nodes": [{no, ux..rz, rw}]}
55
+ """
56
+ if name is None:
57
+ return _query_all("GetAllNodeDisplacement")
58
+ return _query_by_names("GetNodeDisplacementByNames", name)
59
+
60
+
61
+ def get_element_force(name: str | list[str] | None = None) -> list[dict]:
62
+ """查询求解后单元内力
63
+
64
+ Args:
65
+ name: 工况名(str 或 list[str]);None 时返回全部工况
66
+
67
+ Returns:
68
+ list[dict]: 每个工况 {"loadCase", "source",
69
+ "elements": [{ele, node, fx..mz, mw}]}
70
+ """
71
+ if name is None:
72
+ return _query_all("GetAllElementForce")
73
+ return _query_by_names("GetElementForceByNames", name)
74
+
75
+
76
+ def get_support_reaction(name: str | list[str] | None = None) -> list[dict]:
77
+ """查询求解后支座反力
78
+
79
+ Args:
80
+ name: 工况名(str 或 list[str]);None 时返回全部工况
81
+
82
+ Returns:
83
+ list[dict]: 每个工况 {"loadCase", "source",
84
+ "nodes": [{no, sys, fx..mz, mw}]}
85
+ """
86
+ if name is None:
87
+ return _query_all("GetAllSupportReaction")
88
+ return _query_by_names("GetSupportReactionByNames", name)
89
+
90
+
91
+ # ═════════════════════════════════════════════
92
+ # DataFrame 展平
93
+ # ═════════════════════════════════════════════
94
+
95
+ def _flatten(cases: list[dict], rows_key: str) -> "pd.DataFrame":
96
+ """把 [{loadCase, source, rows_key: [...]}, ...] 展平成单表。
97
+
98
+ 行内附带 loadCase/source 两列,便于多工况合并分析。
99
+ """
100
+ if not _HAS_PANDAS:
101
+ raise ImportError("结果导出功能依赖 pandas,请先安装:pip install pandas")
102
+ rows = []
103
+ for case in cases:
104
+ meta = {"loadCase": case.get("loadCase"), "source": case.get("source")}
105
+ for r in case.get(rows_key) or []:
106
+ rows.append({**meta, **r})
107
+ return pd.DataFrame(rows)
108
+
109
+
110
+ def node_displacement_df(name: str | list[str] | None = None) -> "pd.DataFrame":
111
+ """节点位移 DataFrame(列: loadCase, source, no, ux, uy, uz, rx, ry, rz, rw)"""
112
+ return _flatten(get_node_displacement(name), "nodes")
113
+
114
+
115
+ def element_force_df(name: str | list[str] | None = None) -> "pd.DataFrame":
116
+ """单元内力 DataFrame(列: loadCase, source, ele, node, fx, fy, fz, mx, my, mz, mw)"""
117
+ return _flatten(get_element_force(name), "elements")
118
+
119
+
120
+ def support_reaction_df(name: str | list[str] | None = None) -> "pd.DataFrame":
121
+ """支座反力 DataFrame(列: loadCase, source, no, sys, fx, fy, fz, mx, my, mz, mw)"""
122
+ return _flatten(get_support_reaction(name), "nodes")
@@ -28,6 +28,11 @@ except ImportError:
28
28
  from .loadcase import osis_loadcase_result
29
29
  from .env import osis_env_result
30
30
  from .check import osis_check_result
31
+ from .headless import (
32
+ node_displacement_df,
33
+ element_force_df,
34
+ support_reaction_df,
35
+ )
31
36
 
32
37
 
33
38
  class ResultManager:
@@ -197,6 +202,67 @@ class ResultManager:
197
202
  )
198
203
  return df
199
204
 
205
+ # ═══════════════════════════════════════════
206
+ # 求解后无头查询(直接读求解器结果,不经 GUI 导出)
207
+ # ═══════════════════════════════════════════
208
+
209
+ def node_displacement(self, name: str | list[str] | None = None) -> pd.DataFrame:
210
+ """查询求解后节点位移
211
+
212
+ 走 /GetAllNodeDisplacement、/GetNodeDisplacementByNames 端点,
213
+ 优先从结果文件读,文件失败回落内存。
214
+
215
+ Args:
216
+ name: 工况名(str 或 list[str]);None 时返回全部工况
217
+
218
+ Returns:
219
+ 结果 DataFrame(列: loadCase, source, no, ux, uy, uz, rx, ry, rz, rw)
220
+
221
+ Raises:
222
+ ImportError: 未安装 pandas 时抛出
223
+ RuntimeError: 查询失败时抛出异常
224
+ """
225
+ self._ensure_pandas()
226
+ return node_displacement_df(name)
227
+
228
+ def element_force(self, name: str | list[str] | None = None) -> pd.DataFrame:
229
+ """查询求解后单元内力
230
+
231
+ 走 /GetAllElementForce、/GetElementForceByNames 端点,
232
+ 优先从结果文件读,文件失败回落内存。
233
+
234
+ Args:
235
+ name: 工况名(str 或 list[str]);None 时返回全部工况
236
+
237
+ Returns:
238
+ 结果 DataFrame(列: loadCase, source, ele, node, fx, fy, fz, mx, my, mz, mw)
239
+
240
+ Raises:
241
+ ImportError: 未安装 pandas 时抛出
242
+ RuntimeError: 查询失败时抛出异常
243
+ """
244
+ self._ensure_pandas()
245
+ return element_force_df(name)
246
+
247
+ def support_reaction(self, name: str | list[str] | None = None) -> pd.DataFrame:
248
+ """查询求解后支座反力
249
+
250
+ 走 /GetAllSupportReaction、/GetSupportReactionByNames 端点,
251
+ 优先从结果文件读,文件失败回落内存。
252
+
253
+ Args:
254
+ name: 工况名(str 或 list[str]);None 时返回全部工况
255
+
256
+ Returns:
257
+ 结果 DataFrame(列: loadCase, source, no, sys, fx, fy, fz, mx, my, mz, mw)
258
+
259
+ Raises:
260
+ ImportError: 未安装 pandas 时抛出
261
+ RuntimeError: 查询失败时抛出异常
262
+ """
263
+ self._ensure_pandas()
264
+ return support_reaction_df(name)
265
+
200
266
  # ═══════════════════════════════════════════
201
267
  # 验算结果全量导出
202
268
  # ═══════════════════════════════════════════
@@ -1135,6 +1135,23 @@ class SectionManager(BasicManager):
1135
1135
  sections = [Section._from_dict(d) for d in data if isinstance(d, dict) and "no" in d]
1136
1136
  return sections
1137
1137
 
1138
+ def all_longitudinal_rebar(self) -> list[Rebar]:
1139
+ """获取所有截面的纵向钢筋信息(走 GetAllLongitudinalRebarInfo 端点)
1140
+
1141
+ 按截面内部映射顺序返回,与 all() 相比数据更轻量——
1142
+ 只有钢筋标志位与纵筋明细,不含截面几何/属性。
1143
+
1144
+ Returns:
1145
+ list[Rebar]: 各截面的钢筋信息列表
1146
+
1147
+ Raises:
1148
+ RuntimeError: 查询失败时抛出异常
1149
+ """
1150
+ resp = osis_client("GetAllLongitudinalRebarInfo", {})
1151
+ if not resp.get("success"):
1152
+ raise RuntimeError(f"{resp.get('error')}")
1153
+ return [Rebar._from_dict(d) for d in resp.get("data", []) if isinstance(d, dict) and d]
1154
+
1138
1155
  def _next_no(self) -> int:
1139
1156
  """分配新截面编号"""
1140
1157
  sections = self._load()