Avoid Spiderwebs with Direct References in Scripts

Categories:

Flownex Friday Tech Tips!

It’s officially Spooky Season! In between episodes of Squid Game and re-watching Hubie Halloween I thought I could make things a little less scary by demonstrating how to get rid of the spiderwebs in our projects (AKA Data Transfer Links). We use these often with scripts, which can be very powerful, but as our networks get more complex we may want to avoid the clutter/attracting spiders.

Quick Script vs Full Script

If we’re not scared of a little C# we may decide to start with a full script. I, personally, like to use a quick script so that I can use the table inputs to define my script inputs and results.

1 quick script

Calling a Specific Component

We will identify the component we want to read/write to by the unique Identifier. This can be found in the input properties for the component. In this example we’ll use a pipe component. By default this would typically be “Pipe – 0” or “Pipe” followed by some other integer. This field is editable so you can change it, but it must remain unique to that specific component.

2 component identifier

We can either specify the identifier as a string explicitly in the script:

//Referencing component "Pipe - 0"
IPS.Core.Component Pipe = Project.GetComponent("Pipe - 0");

Or we can have this as an text-type input to the script so that we can change the reference more easily. In this example we have a text variable “ComponentIdentifier”:

3 quick script input table
//Referencing component which is defined by input "ComponentIdentifier"
IPS.Core.Component Pipe = Project.GetComponent(ComponentIdentifier.ToString());

Note that we are using the ToString function to convert our text variable to a string.

Reading from Component

Now that we have our Pipe component referenced in the script we can read any of the results into our script via their display identifier using the following syntax:

//Reading from flow component
IPS.Properties.Double T_1 = Pipe.GetPropertyFromFullDisplayName("{Flow Element Results,Generic}Total temperature
") as IPS.Properties.Double;
Pipe_Temp.Value = T_1;

Note that we must use a internal variable. in this case “T_1”, to read the temperature before we assign that to the value of our script result “Pipe_Temp”.

A quick trick to determine the display name is to right-click on the result you’re interested in and select “Copy display identifiers to clipboard”.

4 display identifier shortcut

Writing to Component

The process of modifying a component input with values from the script is very similar. We can use the above trick on our Inputs for the component to find the display identifier for the pipe diameter in this example.

//Write to component
IPS.Properties.Double diameter = Pipe.GetPropertyFromFullDisplayName("{Geometry,Inlet}Diameter") as IPS.Properties.Double;
diameter.Value = Pipe_Diameter;

Summary

Here is how we’ve set up the quick script, as you can see it is really not that scary:

5 quick script final

And the snippet of code from the quick script:

//Identify Component
IPS.Core.Component Pipe = Project.GetComponent(ComponentIdentifier.ToString()); 

//Read from component
IPS.Properties.Double T_1 = Pipe.GetPropertyFromFullDisplayName("{Flow Element Results,Generic}Total temperature") as IPS.Properties.Double;
Pipe_Temp.Value = T_1;

//Write to component
IPS.Properties.Double diameter = Pipe.GetPropertyFromFullDisplayName("{Geometry,Inlet}Diameter") as IPS.Properties.Double;
diameter.Value = Pipe_Diameter;

Happy Friday and Happy Coding!

Get Your Ansys Products & Support from the Engineers who Contribute to this Blog.

Technical Expertise to Enable your Additive Manufacturing Success.

Share this post:

Upcoming Events

Feb 21
, 2025
Desert WAVE Underwater Robot Winners Panel
Feb 25
, 2025
Space Simulation Workshop
Mar 20
, 2025
Arizona Space Summit 2025
Apr 07
- Apr 10
, 2025
40th Space Symposium
Jun 09
- Jun 11
, 2025
TechConnect World 2025
Jun 16
- Jun 20
, 2025
Turbo Expo
Jun 25
, 2025
E-Mobility and Clean Energy Summit
Jul 11
, 2025
2025 Aerospace, Aviation, Defense and Manufacturing Conference

Search the PADT Site

Contact Us

Most of our customers receive their support over the phone or via email. Customers who are close by can also set up a face-to-face appointment with one of our engineers.

For most locations, simply contact us: