TAGGED: scripting, spaceclaim
-
-
August 27, 2019 at 11:46 am
thilliard
SubscriberOk so what I am trying to get is all the P values (jigz.txt file) change for every job and I pull the values from an excel worksheet now I need to pass those into my script. How is this done? trying not to have to hard code them each time Thanks
🛈 This post originally contained file attachments which have been removed in compliance with the updated Ansys Learning Forum Terms & Conditions -
August 27, 2019 at 2:14 pm
Naresh Patre
Ansys EmployeeHello frogdude01
You can read the text file and store all the data from the text file for using it in your script. There is a built-in example showing how to read a csv file in the snippets section which you can refer. See below snapshot. This snippet can be accessed in Insert Snippet - Reading from Files - Reading From a CSV File. You can use similar logic to read txt file and use the data from the txt file in your script.
-
August 28, 2019 at 8:02 am
thilliard
SubscriberI tried that I don't know how to pull the information so that in my script P1 will equal 7.125 that is in the text file. I'm a total newbie at this stuff
-
August 28, 2019 at 10:18 am
Naresh Patre
Ansys EmployeeHello frogdude01
You will have to make use of basic python functionalities like split, dictionary and so on. Please refer below sample code:
f = open("E:\support\forum\JIGZ.txt", "r")
my_dict = {}
for x in f:
temp = x.split("=,") # split each line by =,
my_dict[temp[0]] = temp[1]# Sketch Line UPPER S DIA 'P5')
start = Point2D.Create(MM(-1*float(my_dict['p1'])*25.4), MM(float(my_dict['p5'])*25.4))
end = Point2D.Create(MM((-1*float(my_dict['p2'])*25.4)-R1), MM(float(my_dict['p5'])*25.4))
result = SketchLine.Create(start, end)
# EndBlock -
August 28, 2019 at 1:41 pm
thilliard
SubscriberThank you will be doing some Python tutorials to be better scripted :)
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Can’t see license on online account
- loss of user settings
- Copy user settings to new release
- help online
- Unexpected graphics error
- Electric Heating – Ansys AIM
- Dwg export error
- Natural frequencies limited to first 6 modes
- Discovery AIM Mesh Error
- ANSYSLI Exited or could not read server port ANSYSLI_FNE_PORT
-
3744
-
2573
-
1809
-
1236
-
594
© 2023 Copyright ANSYS, Inc. All rights reserved.