ansys-mechanical-core 0.11.9__py3-none-any.whl → 0.11.10__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.
@@ -50,6 +50,7 @@ from ansys.mechanical.core._version import __version__
50
50
  from ansys.mechanical.core.mechanical import (
51
51
  change_default_mechanical_path,
52
52
  close_all_local_instances,
53
+ connect_to_mechanical,
53
54
  get_mechanical_path,
54
55
  launch_mechanical,
55
56
  )
@@ -137,6 +137,13 @@ class App:
137
137
  if len(INSTANCES) > 0:
138
138
  raise Exception("Cannot have more than one embedded mechanical instance!")
139
139
  version = kwargs.get("version")
140
+ if version is not None:
141
+ try:
142
+ version = int(version)
143
+ except ValueError:
144
+ raise ValueError(
145
+ f"The version must be an integer or that can be converted to an integer."
146
+ )
140
147
  self._version = initializer.initialize(version)
141
148
  configuration = kwargs.get("config", _get_default_addin_configuration())
142
149
 
@@ -2242,3 +2242,86 @@ def launch_mechanical(
2242
2242
  raise exception
2243
2243
 
2244
2244
  return mechanical
2245
+
2246
+
2247
+ def connect_to_mechanical(
2248
+ ip=None,
2249
+ port=None,
2250
+ loglevel="ERROR",
2251
+ log_file=False,
2252
+ log_mechanical=None,
2253
+ connect_timeout=120,
2254
+ clear_on_connect=False,
2255
+ cleanup_on_exit=False,
2256
+ keep_connection_alive=True,
2257
+ ) -> Mechanical:
2258
+ """Connect to an existing Mechanical server instance.
2259
+
2260
+ Parameters
2261
+ ----------
2262
+ ip : str, optional
2263
+ IP address for connecting to an existing Mechanical instance. The
2264
+ IP address defaults to ``"127.0.0.1"``.
2265
+ port : int, optional
2266
+ Port to listen on for an existing Mechanical instance. The default is ``None``,
2267
+ in which case ``10000`` is used. You can override the
2268
+ default behavior of this parameter with the
2269
+ ``PYMECHANICAL_PORT=<VALID PORT>`` environment variable.
2270
+ loglevel : str, optional
2271
+ Level of messages to print to the console.
2272
+ Options are:
2273
+
2274
+ - ``"WARNING"``: Prints only Ansys warning messages.
2275
+ - ``"ERROR"``: Prints only Ansys error messages.
2276
+ - ``"INFO"``: Prints all Ansys messages.
2277
+
2278
+ The default is ``WARNING``.
2279
+ log_file : bool, optional
2280
+ Whether to copy the messages to a file named ``logs.log``, which is
2281
+ located where the Python script is executed. The default is ``False``.
2282
+ log_mechanical : str, optional
2283
+ Path to the output file on the local disk to write every script
2284
+ command to. The default is ``None``. However, you might set
2285
+ ``"log_mechanical='pymechanical_log.txt'"`` to write all commands that are
2286
+ sent to Mechanical via PyMechanical to this file. You can then use these
2287
+ commands to run a script within Mechanical without PyMechanical.
2288
+ connect_timeout : float, optional
2289
+ Maximum allowable time in seconds to connect to the Mechanical server.
2290
+ The default is ``120``.
2291
+ clear_on_connect : bool, optional
2292
+ Whether to clear the Mechanical instance when connecting. The default is ``False``.
2293
+ When ``True``, a fresh environment is provided when you connect to Mechanical.
2294
+ cleanup_on_exit : bool, optional
2295
+ Whether to exit Mechanical when Python exits. The default is ``False``.
2296
+ When ``False``, Mechanical is not exited when the garbage for this Mechanical
2297
+ instance is collected.
2298
+ keep_connection_alive : bool, optional
2299
+ Whether to keep the gRPC connection alive by running a background thread
2300
+ and making dummy calls for remote connections. The default is ``True``.
2301
+
2302
+ Returns
2303
+ -------
2304
+ ansys.mechanical.core.mechanical.Mechanical
2305
+ Instance of Mechanical.
2306
+
2307
+ Examples
2308
+ --------
2309
+ Connect to an existing Mechanical instance at IP address ``192.168.1.30`` on port
2310
+ ``50001``..
2311
+
2312
+
2313
+ >>> from ansys.mechanical.core import connect_to_mechanical
2314
+ >>> pymech = connect_to_mechanical(ip='192.168.1.30', port=50001)
2315
+ """
2316
+ return launch_mechanical(
2317
+ start_instance=False,
2318
+ loglevel=loglevel,
2319
+ log_file=log_file,
2320
+ log_mechanical=log_mechanical,
2321
+ start_timeout=connect_timeout,
2322
+ port=port,
2323
+ ip=ip,
2324
+ clear_on_connect=clear_on_connect,
2325
+ cleanup_on_exit=cleanup_on_exit,
2326
+ keep_connection_alive=keep_connection_alive,
2327
+ )
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: ansys-mechanical-core
3
- Version: 0.11.9
3
+ Version: 0.11.10
4
4
  Summary: A python wrapper for Ansys Mechanical
5
5
  Keywords: pymechanical,mechanical,ansys,pyansys
6
6
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -30,17 +30,17 @@ Requires-Dist: psutil==6.1.0
30
30
  Requires-Dist: tqdm>=4.45.0
31
31
  Requires-Dist: requests>=2,<3
32
32
  Requires-Dist: sphinx==8.1.3 ; extra == "doc"
33
- Requires-Dist: ansys-sphinx-theme[autoapi]==1.1.7 ; extra == "doc"
34
- Requires-Dist: grpcio==1.67.0 ; extra == "doc"
33
+ Requires-Dist: ansys-sphinx-theme[autoapi]==1.2.1 ; extra == "doc"
34
+ Requires-Dist: grpcio==1.68.0 ; extra == "doc"
35
35
  Requires-Dist: imageio-ffmpeg==0.5.1 ; extra == "doc"
36
36
  Requires-Dist: imageio==2.36.0 ; extra == "doc"
37
37
  Requires-Dist: jupyter_sphinx==0.5.3 ; extra == "doc"
38
38
  Requires-Dist: jupyterlab>=3.2.8 ; extra == "doc"
39
39
  Requires-Dist: matplotlib==3.9.2 ; extra == "doc"
40
- Requires-Dist: numpy==2.1.2 ; extra == "doc"
40
+ Requires-Dist: numpy==2.1.3 ; extra == "doc"
41
41
  Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
42
42
  Requires-Dist: pandas==2.2.3 ; extra == "doc"
43
- Requires-Dist: panel==1.5.3 ; extra == "doc"
43
+ Requires-Dist: panel==1.5.4 ; extra == "doc"
44
44
  Requires-Dist: plotly==5.24.1 ; extra == "doc"
45
45
  Requires-Dist: pypandoc==1.14 ; extra == "doc"
46
46
  Requires-Dist: pytest-sphinx==0.6.3 ; extra == "doc"
@@ -55,7 +55,7 @@ Requires-Dist: sphinx-notfound-page==1.0.4 ; extra == "doc"
55
55
  Requires-Dist: sphinxcontrib-websupport==2.0.0 ; extra == "doc"
56
56
  Requires-Dist: sphinxemoji==0.3.1 ; extra == "doc"
57
57
  Requires-Dist: pytest==8.3.3 ; extra == "tests"
58
- Requires-Dist: pytest-cov==5.0.0 ; extra == "tests"
58
+ Requires-Dist: pytest-cov==6.0.0 ; extra == "tests"
59
59
  Requires-Dist: pytest-print==1.0.2 ; extra == "tests"
60
60
  Requires-Dist: psutil==6.1.0 ; extra == "tests"
61
61
  Requires-Dist: ansys-tools-visualization-interface>=0.2.6 ; extra == "viz"
@@ -1,17 +1,17 @@
1
- ansys/mechanical/core/__init__.py,sha256=91oPPatmqRyry_kzusIq522MQNiBgN5Of54zDMIuJ58,2537
1
+ ansys/mechanical/core/__init__.py,sha256=3v4dIba0Ku10PyTVnkYux0XyTbByuXkvK3LRzlsrLBw,2564
2
2
  ansys/mechanical/core/_version.py,sha256=V2aPQlSX4bCe1N1hLIkQaed84WN4s9wl6Q7890ZihNU,1744
3
3
  ansys/mechanical/core/errors.py,sha256=oGaBH-QZxen3YV3IChAFv8bwW5rK_IXTYgDqbX5lp1E,4508
4
4
  ansys/mechanical/core/feature_flags.py,sha256=L88vHrI2lRjZPPUTW5sqcdloeK3Ouh8vt1VPfZLs5Wc,2032
5
5
  ansys/mechanical/core/ide_config.py,sha256=Sbzax5Pf7FK0XAMhzcsBJu_8CclABLKuebDCqlvHN_0,7334
6
6
  ansys/mechanical/core/launcher.py,sha256=dS3hN8RwiRh_c2RlXV5MVL7pgKZG5ZiNWreWQf3E800,6675
7
7
  ansys/mechanical/core/logging.py,sha256=wQ8QwKd2k0R6SkN7cv2nHAO7V5-BrElEOespDNMpSLo,24554
8
- ansys/mechanical/core/mechanical.py,sha256=tLvmQ8gaFIFbiDdKT300uX8U32g8qC731zB0GWpwIKQ,79972
8
+ ansys/mechanical/core/mechanical.py,sha256=b4v0bntCp505ugVbGglzPxj_KAvOHYLMwvYuXrVJYkw,83205
9
9
  ansys/mechanical/core/misc.py,sha256=edm2UnklbooYW_hQUgk4n_UFCtlSGAVYJmC2gag74vw,5370
10
10
  ansys/mechanical/core/pool.py,sha256=F-Ckbc5c0V8OvYLOxoV2oJ3E8QOmPG0hH9XA07h3eAU,26586
11
11
  ansys/mechanical/core/run.py,sha256=KgSL2XEyCxK7iq_XVDNEv6fx7SN56RA-ihNg2dLyuZc,9920
12
12
  ansys/mechanical/core/embedding/__init__.py,sha256=y0yp3dnBW2oj9Jh_L_qfZstAbpON974EMmpV9w3kT3g,1356
13
13
  ansys/mechanical/core/embedding/addins.py,sha256=2-de-sIOWjO5MCKdBHC2LFxTItr1DUztABIONTQhiWc,2167
14
- ansys/mechanical/core/embedding/app.py,sha256=WKMN_2UQHEo-fsE0yqtVCZwA4ItSq13NvRz22r7QS1g,18708
14
+ ansys/mechanical/core/embedding/app.py,sha256=q6DQC8xTpN8v9hfoHLIIkC6xU4Mkh6i6hnCldgGfDKM,18973
15
15
  ansys/mechanical/core/embedding/app_libraries.py,sha256=RiTO23AzjssAylIH2DaTa6mcJmxhfrlHW-yYvHpIkt0,2923
16
16
  ansys/mechanical/core/embedding/appdata.py,sha256=krcmcgHhraHIlORFr43QvUXlAiXg231g_2iOIxkW_aQ,4223
17
17
  ansys/mechanical/core/embedding/background.py,sha256=QxR5QE1Q2gdcVy6QTy-PYmTOyXAhgYV7wqLV2bxUV4I,3731
@@ -38,8 +38,8 @@ ansys/mechanical/core/embedding/viz/usd_converter.py,sha256=feDq2KrZhYL-RR1miECQ
38
38
  ansys/mechanical/core/embedding/viz/utils.py,sha256=FuGDh7a5mUqs2UZOaXZLD0vONdmDXl5JfDRilIVbjds,3660
39
39
  ansys/mechanical/core/examples/__init__.py,sha256=A1iS8nknTU1ylafHZpYC9LQJ0sY83x8m1cDXsgvFOBo,1267
40
40
  ansys/mechanical/core/examples/downloads.py,sha256=rYFsq8U3YpXi_DVx_Uu5sRFFUS85ks6rMJfcgyvBat0,4295
41
- ansys_mechanical_core-0.11.9.dist-info/entry_points.txt,sha256=tErx6bIM27HGgwyM6ryyTUTw30Ab2F9J3FFkX2TPkhI,130
42
- ansys_mechanical_core-0.11.9.dist-info/LICENSE,sha256=gBJ2GQ6oDJwAWxcxmjx_0uXc-N0P4sHhA7BXsdPTfco,1098
43
- ansys_mechanical_core-0.11.9.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
44
- ansys_mechanical_core-0.11.9.dist-info/METADATA,sha256=y7oWZjaJBccSx1Lx1mEMaIvJ6S6muD8OMmU29NIzn3o,9887
45
- ansys_mechanical_core-0.11.9.dist-info/RECORD,,
41
+ ansys_mechanical_core-0.11.10.dist-info/entry_points.txt,sha256=tErx6bIM27HGgwyM6ryyTUTw30Ab2F9J3FFkX2TPkhI,130
42
+ ansys_mechanical_core-0.11.10.dist-info/LICENSE,sha256=gBJ2GQ6oDJwAWxcxmjx_0uXc-N0P4sHhA7BXsdPTfco,1098
43
+ ansys_mechanical_core-0.11.10.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
44
+ ansys_mechanical_core-0.11.10.dist-info/METADATA,sha256=Y0fFZOs9WzxoRvYpxVtTDjS8sYw-TBGdju70uD3z_hs,9888
45
+ ansys_mechanical_core-0.11.10.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.9.0
2
+ Generator: flit 3.10.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any