AmesimKnowledge

Tutorial

Connecting components

API connecting components

In order to connect two components, you require the port numbers. To obtain the port numbers, right-click a component and select External variables:

Figure 11: External Variables

Here we can see the component port numbers. However, when you connect the ports using the script, you require the port indexes. The conversion to obtain the indexes is port index = port number -1.

Modify your script to perform the connection by adding the following lines:

Copy

# Do connections

# Connect "mass_friction1port" and "springdamper01"
AMEConnectTwoPorts('mass_friction1port', 0, 'springdamper01', 0)

# Connect "springdamper01" and "simple_crank"
AMEConnectTwoPorts('springdamper01', 1, 'simple_crank', 1)

# Connect "simple_crank" and "rconnector"
AMEConnectTwoPorts('simple_crank', 0, 'rconnector', 1)

# Connect "rconnector" and "simple_crank_2"
AMEConnectTwoPorts('rconnector', 0, 'simple_crank_2', 0)

# Connect "rconnector" and "rload01"
AMEConnectTwoPorts('rconnector', 2, 'rload01', 0)

# Connect "simple_crank_2" and "springdamper01_2"
AMEConnectTwoPorts('simple_crank_2', 1, 'springdamper01_2', 0)

# Connect "springdamper01_2" and "mass_friction1port_2"
AMEConnectTwoPorts('springdamper01_2', 1, 'mass_friction1port_2', 0)

Launch your script again, and then open the system in Simcenter Amesim:

Figure 12: Ports connected

The components are no longer in reverse video, they are connected.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Circuit_API/xid882120 · retrieved 2026-07-17