-
-
February 26, 2023 at 8:56 pm
m.vp2209
SubscriberHi
I am writting a code which saves my temperature solutions directly as a text file after the solution is calculated. For the name of the .txt file I would like to also include the name of my system. In my project I have many systems and I want to just get the name (Display Text) of the system that is currently in use, without having to know its index in the project.
My current code to get the Display name of the project and which runs in Mechanical looks like:
import wbjnWB_cmds="""system1 = GetAllSystems()[1]my_name = system1.DisplayTextreturnValue(my_name)"""system_name=wbjn.ExecuteCommand(ExtAPI,WB_cmds)then I use the system_name to create a filepath where the txt file of the solution should be stored.Unfortunately, this is not what I want because I would have to know the GetAllSystems index of every system and change it manually.
I have also though about using GetSystem(Name="Static1"), but I run into the same problem that I would have to know the name of the system to start with, rather than retrieving it from WB.Do you have any better approaches?
-
March 2, 2023 at 6:02 pm
Aniket
Forum ModeratorIf you are using a workbench-level script and SendCommand API to Mechanical as mentioned on the other thread, you can take this DisplayText directly to Mechanical, to export the files. Will that work?
-Aniket
-
January 10, 2024 at 4:37 pm
IKER GOMEZ
SubscriberA way of finding the system Name from Mechanical could be based on the WorkingDirectory:
On Mechanical:WBcmd = “\n” + “SYSFolder=” + “‘” + ExtAPI.DataModel.Project.Model.Analyses[0].WorkingDir.Split(“\\”)[-3] + “‘”
WBcmd =WBcmd + “””
for system in GetAllSystems():
if ACT.GetEntityProperty(system.GetComponent(“Model”),’DirectoryName’) == SYSFolder:
returnValue(system.Name)
“””
system_name=wbjn.ExecuteCommand(ExtAPI,WBcmd)
-
- The topic ‘Active mechanical system name in ACT scrippting’ is closed to new replies.
-
3387
-
1052
-
1050
-
886
-
857
© 2025 Copyright ANSYS, Inc. All rights reserved.