Navigation

  • index
  • modules |
  • next |
  • previous |
  • OpenVSP Python API documentation »
  • API Functions by Group »
  • Advanced Link Functions

Advanced Link Functions¶

The following functions are available for the Advanced Link tool.

GetAdvLinkNames()

Get an array of all advanced link names

GetLinkIndex(name)

Find the index of a specific advanced link.

GetAdvLinkName(index)

Delete an advanced link specified by index

SetAdvLinkName(index, name)

Set the name of an advanced link.

DelAdvLink(index)

Delete one advanced link, by index.

DelAllAdvLinks()

Delete all advanced links

AddAdvLink(name)

Add an advanced link

AddAdvLinkInput(index, parm_id, var_name)

Add an input variable to an advanced link

AddAdvLinkOutput(index, parm_id, var_name)

Add an output variable to an advanced link

DelAllAdvLinkInputs(index)

Delete an input variable from an advanced link

DelAllAdvLinkOutputs(index)

Delete all output variables from an advanced link

DelAdvLinkInput(index, var_name)

Remove one input variable from an advanced link.

DelAdvLinkOutput(index, var_name)

Delete an output variable from an advanced link

GetAdvLinkInputNames(index)

Get the name of all the inputs to a specified advanced link index

GetAdvLinkInputParms(index)

Get the Parm IDs of all the inputs to a specified advanced link index

GetAdvLinkOutputNames(index)

Get the Parm IDs of all the outputs to a specified advanced link index

GetAdvLinkOutputParms(index)

Get the Parm IDs of all the outputs to a specified advanced link index

ValidateAdvLinkParms(index)

Validate the input and output parameters for an advanced link

SetAdvLinkCode(index, code)

Get the code from an advanced link

GetAdvLinkCode(index)

Get the code from an advanced link

SearchReplaceAdvLinkCode(index, _from, to)

Search and replace strings in the advanced link code

BuildAdvLinkScript(index)

Build (ready for execution and perform syntax check) an advanced link.

WriteAdvLinkCodeFile(index, file_name)

Write the code of an advanced link out to a text file, the way the File Write button on the Advanced Link screen does.

ReorderAdvLinkInput(index, var_name, ...)

Move an input variable within an advanced link's input list, the way the move buttons beside the input browser do.

ReorderAdvLinkOutput(index, var_name, ...)

Move an output variable within an advanced link's output list, the way the move buttons beside the output browser do.

ReadAdvLinkCodeFile(index, file_name)

Read the code of an advanced link in from a text file, the way the File Read button on the Advanced Link screen does.

SortAdvLinkInputsVar(index)

Sort the input variables of an advanced link into alphabetical order by variable name.

SortAdvLinkInputsCGP(index)

Sort the input variables of an advanced link by the Parm they are attached to, ordering on container name, then group name, then Parm name.

SortAdvLinkOutputsVar(index)

Sort the output variables of an advanced link into alphabetical order by variable name.

SortAdvLinkOutputsCGP(index)

Sort the output variables of an advanced link by the Parm they drive, ordering on container name, then group name, then Parm name.

Details¶

openvsp.GetAdvLinkNames()[source]¶

Get an array of all advanced link names

#==== Set up an advanced link so there is something to find ====//
pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

link_array = GetAdvLinkNames()
assert len( link_array ) > 0, "GetAdvLinkNames returned nothing"

for n in range(len(link_array) ):

    print( link_array[n] )
Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of advanced link names

openvsp.GetLinkIndex(name)[source]¶

Find the index of a specific advanced link.

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:

[in] – name string Name for advanced link

Return type:

int

Returns:

int index for advanced link

openvsp.GetAdvLinkName(index)[source]¶

Delete an advanced link specified by index

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

num_before_del = len( GetAdvLinkNames() )
DelAdvLink( indx )
assert len( GetAdvLinkNames() ) < num_before_del, "DelAdvLink removed nothing"


link_array = GetAdvLinkNames()

# Should print nothing.
for n in range(len(link_array) ):

    print( link_array[n] )

assert len( link_array ) == 0, "links were left behind"

# With the link gone, the Pod is no longer driven.
x_before = GetParmVal( x_pos )

SetParmValUpdate( length, 7.0 )

Update()

assert abs( GetParmVal( x_pos ) - x_before ) < 1e-9, "a deleted advanced link is still driving its output"
Parameters:

[in] – index int Index for advanced link

Get the name of an advanced link.

AddAdvLink( "ExampleLink" )

indx = GetLinkIndex( "ExampleLink" )

assert GetAdvLinkName( indx ) == "ExampleLink", "GetAdvLinkName did not report the name the link was created with"

# The single name and the list of names agree.
link_array = GetAdvLinkNames()

assert len( link_array ) == 1, "GetAdvLinkName disagrees with GetAdvLinkNames"
assert link_array[0] == GetAdvLinkName( indx ), "GetAdvLinkName disagrees with GetAdvLinkNames"

# An index past the end has to be rejected.  The error queue is reached
# through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

GetAdvLinkName( 100 )

assert err_mgr.GetNumTotalErrors() > 0, "GetAdvLinkName accepted an index past the end"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: AddAdvLink, GetAdvLinkNames, SetAdvLinkName :param [in]: index int Advanced link index :rtype: string :return: string Advanced link name

openvsp.SetAdvLinkName(index, name)[source]¶

Set the name of an advanced link.

AddAdvLink( "ExampleLink" )

indx = GetLinkIndex( "ExampleLink" )

SetAdvLinkName( indx, "RenamedLink" )

assert GetAdvLinkName( indx ) == "RenamedLink", "SetAdvLinkName did not take"

# The link is now found under its new name and not its old one.
assert GetLinkIndex( "RenamedLink" ) == indx, "the renamed link cannot be found under its new name"
assert GetLinkIndex( "ExampleLink" ) < 0, "the renamed link is still found under its old name"

# Looking up the old name raised an error on purpose, so take it back off
# the queue.
err_mgr = ErrorMgrSingleton.getInstance()

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: AddAdvLink, GetAdvLinkName, GetLinkIndex :param [in]: index int Advanced link index :param [in]: name string Advanced link name

openvsp.DelAdvLink(index)[source]¶

Delete one advanced link, by index.

AddAdvLink( "TestLink" )

DelAdvLink( 0 )

assert len( GetAdvLinkNames() ) == 0, "DelAdvLink did not delete the link"

See also: AddAdvLink, GetAdvLinkNames :param [in]: index int Index of the advanced link to delete

openvsp.DelAllAdvLinks()[source]¶

Delete all advanced links

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

DelAllAdvLinks()

link_array = GetAdvLinkNames()

# Should print nothing.
for n in range( len(link_array) ):

    print( link_array[n] )

assert len( link_array ) == 0, "links were left behind"

# With the link gone, the Pod is no longer driven.
x_before = GetParmVal( x_pos )

SetParmValUpdate( length, 7.0 )

Update()

assert abs( GetParmVal( x_pos ) - x_before ) < 1e-9, "a deleted advanced link is still driving its output"
openvsp.AddAdvLink(name)[source]¶

Add an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:

[in] – name string Name for advanced link

openvsp.AddAdvLinkInput(index, parm_id, var_name)[source]¶

Add an input variable to an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Advanced link index

  • [in] – parm_id string Parameter ID for advanced link input variable

  • [in] – var_name string Name for advanced link input variable

openvsp.AddAdvLinkOutput(index, parm_id, var_name)[source]¶

Add an output variable to an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Advanced link index

  • [in] – parm_id string Parameter ID for advanced link output variable

  • [in] – var_name string Name for advanced link output variable

openvsp.DelAllAdvLinkInputs(index)[source]¶

Delete an input variable from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )
y_pos = GetParm( pod, "Y_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )
AddAdvLinkInput( indx, y_pos, "y" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

num_before_del = len( GetAdvLinkInputNames( indx ) )
DelAdvLinkInput( indx, "y" )
assert len( GetAdvLinkInputNames( indx ) ) < num_before_del, "DelAdvLinkInput removed nothing"


BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Advanced link index

  • [in] – var_name string Name for advanced link input variable to delete

Delete all input variables from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )
y_pos = GetParm( pod, "Y_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkInput( indx, y_pos, "y" )
AddAdvLinkOutput( indx, x_pos, "x" )

assert len( GetAdvLinkInputNames( indx ) ) == 2, "the inputs were not both added"

DelAllAdvLinkInputs( indx )

# Every input goes; the outputs are left alone.
assert len( GetAdvLinkInputNames( indx ) ) == 0, "DelAllAdvLinkInputs left inputs behind"
assert len( GetAdvLinkOutputNames( indx ) ) == 1, "DelAllAdvLinkInputs removed an output"

See also: AddAdvLinkInput, DelAdvLinkInput, DelAllAdvLinkOutputs :param [in]: index int Advanced link index

openvsp.DelAllAdvLinkOutputs(index)[source]¶

Delete all output variables from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )
y_pos = GetParm( pod, "Y_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )
AddAdvLinkOutput( indx, y_pos, "y" )

assert len( GetAdvLinkOutputNames( indx ) ) == 2, "the outputs were not both added"

DelAllAdvLinkOutputs( indx )

# Every output goes; the inputs are left alone.
assert len( GetAdvLinkOutputNames( indx ) ) == 0, "DelAllAdvLinkOutputs left outputs behind"
assert len( GetAdvLinkInputNames( indx ) ) == 1, "DelAllAdvLinkOutputs removed an input"

See also: AddAdvLinkOutput, DelAdvLinkOutput, DelAllAdvLinkInputs :param [in]: index int Advanced link index

openvsp.DelAdvLinkInput(index, var_name)[source]¶

Remove one input variable from an advanced link.

pid = AddGeom( "POD" )

Update()

AddAdvLink( "TestLink" )

len_parm = GetParm( pid, "Length", "Design" )

AddAdvLinkInput( 0, len_parm, "Len" )

DelAdvLinkInput( 0, "Len" )

assert len( GetAdvLinkInputNames( 0 ) ) == 0, "DelAdvLinkInput did not remove the input"

See also: AddAdvLinkInput, GetAdvLinkInputNames :param [in]: index int Advanced link index :param [in]: var_name string Name of the input variable to remove

openvsp.DelAdvLinkOutput(index, var_name)[source]¶

Delete an output variable from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )
y_pos = GetParm( pod, "Y_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )
AddAdvLinkOutput( indx, y_pos, "y" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

num_before_del = len( GetAdvLinkOutputNames( indx ) )
DelAdvLinkOutput( indx, "y" )
assert len( GetAdvLinkOutputNames( indx ) ) < num_before_del, "DelAdvLinkOutput removed nothing"


BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Advanced link index

  • [in] – var_name string Name for advanced link output variable to delete

openvsp.GetAdvLinkInputNames(index)[source]¶

Get the name of all the inputs to a specified advanced link index

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

name_array = GetAdvLinkInputNames( indx )
assert len( name_array ) > 0, "GetAdvLinkInputNames returned nothing"

for n in range(len(name_array) ):

    print( name_array[n] )
Parameters:

[in] – index int Advanced link index

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of advanced link input names

openvsp.GetAdvLinkInputParms(index)[source]¶

Get the Parm IDs of all the inputs to a specified advanced link index

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

parm_array = GetAdvLinkInputParms( indx )
assert len( parm_array ) > 0, "GetAdvLinkInputParms returned nothing"

for n in range( len(parm_array) ):

    print( parm_array[n] )
Parameters:

[in] – index int Advanced link index

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of advanced link input Parm IDs

openvsp.GetAdvLinkOutputNames(index)[source]¶

Get the Parm IDs of all the outputs to a specified advanced link index

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

name_array = GetAdvLinkOutputNames( indx )
assert len( name_array ) > 0, "GetAdvLinkOutputNames returned nothing"

for n in range( len(name_array) ):

    print( name_array[n] )
Parameters:

[in] – index int Advanced link index

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of advanced link output names

openvsp.GetAdvLinkOutputParms(index)[source]¶

Get the Parm IDs of all the outputs to a specified advanced link index

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

parm_array = GetAdvLinkOutputParms( indx )
assert len( parm_array ) > 0, "GetAdvLinkOutputParms returned nothing"

for n in range( len(parm_array) ):

    print( parm_array[n] )
Parameters:

[in] – index int Advanced link index

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of advanced link output Parm IDs

openvsp.ValidateAdvLinkParms(index)[source]¶

Validate the input and output parameters for an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

valid = ValidateAdvLinkParms( indx )

# The link built above is well formed, so this has to come back true.
assert valid, "ValidateAdvLinkParms did not report success"

if  valid :
    print( "Advanced link Parms are valid." )
else:
    print( "Advanced link Parms are not valid." )
Parameters:

[in] – index int Index for advanced link

Return type:

boolean

Returns:

bool Flag indicating whether parms are valid

openvsp.SetAdvLinkCode(index, code)[source]¶

Get the code from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output: x is 10 minus the Pod's
# length, so changing the length has to move the Pod.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 4.0 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Index for advanced link

  • [in] – code string Code for advanced link

openvsp.GetAdvLinkCode(index)[source]¶

Get the code from an advanced link

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

BuildAdvLinkScript( indx )

code = GetAdvLinkCode( indx )
assert len( code ) > 0, "GetAdvLinkCode returned nothing"

print( code )
Parameters:

[in] – index int Index for advanced link

Return type:

string

Returns:

string String containing advanced link code

openvsp.SearchReplaceAdvLinkCode(index, _from, to)[source]¶

Search and replace strings in the advanced link code

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )
SearchReplaceAdvLinkCode( indx, "10.0", "12.3" )

code = GetAdvLinkCode( indx )

print( code )

assert "12.3" in code and "10.0" not in code, "SearchReplaceAdvLinkCode did not replace"

BuildAdvLinkScript( indx )

# The link was named, so it has to be findable by that name and by that
# index, and it has to actually drive its output.  The replacement rewrote
# the code, so x is now 12.3 minus the Pod's length.
assert indx >= 0, "the advanced link was not registered under its name"
assert len( GetAdvLinkNames() ) == 1, "the advanced link was not registered under its name"
assert GetAdvLinkNames()[0] == "ExampleLink", "the advanced link was not registered under its name"

SetParmValUpdate( length, 6.0 )

Update()

assert abs( GetParmVal( x_pos ) - 6.3 ) < 1e-6, "the advanced link did not drive its output"
Parameters:
  • [in] – index int Index for advanced link

  • [in] – from string Search token

  • [in] – to string Replace token

openvsp.BuildAdvLinkScript(index)[source]¶

Build (ready for execution and perform syntax check) an advanced link.

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

success = BuildAdvLinkScript( indx )

# The link built above is well formed, so this has to come back true.
assert success, "BuildAdvLinkScript did not report success"

if  success :
    print( "Advanced link build successful." )
else:
    print( "Advanced link build not successful." )
Parameters:

[in] – index int Index for advanced link

Return type:

boolean

Returns:

bool Flag indicating whether advanced link build was successful

openvsp.WriteAdvLinkCodeFile(index, file_name)[source]¶

Write the code of an advanced link out to a text file, the way the File Write button on the Advanced Link screen does. Only the code is written; the input and output variable lists are not, so a file written here can be read back into any link that declares the same variables.

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )

WriteAdvLinkCodeFile( indx, "ExampleLink.vspscript" )

# Overwrite the code, then bring the saved version back.
SetAdvLinkCode( indx, "x = 0.0;" )

ReadAdvLinkCodeFile( indx, "ExampleLink.vspscript" )

assert GetAdvLinkCode( indx ) == "x = 10.0 - len;", "the code did not survive the round trip"

See also: ReadAdvLinkCodeFile, GetAdvLinkCode :param [in]: index int Index for advanced link :param [in]: file_name string Name of the file to write

openvsp.ReorderAdvLinkInput(index, var_name, reorder_type)[source]¶

Move an input variable within an advanced link’s input list, the way the move buttons beside the input browser do. The order is presentation only; it does not affect what the link computes.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkInput( indx, FindParm( pod, "Length", "Design" ), "len" )
AddAdvLinkInput( indx, FindParm( pod, "FineRatio", "Design" ), "fine" )

ReorderAdvLinkInput( indx, "fine", REORDER_MOVE_UP )

names = GetAdvLinkInputNames( indx )

assert names[0] == "fine", "ReorderAdvLinkInput did not move the variable"
assert names[1] == "len", "ReorderAdvLinkInput did not move the variable"

See also: SortAdvLinkInputsVar, ReorderAdvLinkOutput :param [in]: index int Index for advanced link :param [in]: var_name string Input variable name :param [in]: reorder_type int Reorder type enum (see REORDER_TYPE)

openvsp.ReorderAdvLinkOutput(index, var_name, reorder_type)[source]¶

Move an output variable within an advanced link’s output list, the way the move buttons beside the output browser do. The order is presentation only; it does not affect what the link computes.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkOutput( indx, FindParm( pod, "X_Rel_Location", "XForm" ), "x" )
AddAdvLinkOutput( indx, FindParm( pod, "Y_Rel_Location", "XForm" ), "y" )

ReorderAdvLinkOutput( indx, "x", REORDER_MOVE_BOTTOM )

names = GetAdvLinkOutputNames( indx )

assert names[0] == "y", "ReorderAdvLinkOutput did not move the variable"
assert names[1] == "x", "ReorderAdvLinkOutput did not move the variable"

See also: SortAdvLinkOutputsVar, ReorderAdvLinkInput :param [in]: index int Index for advanced link :param [in]: var_name string Output variable name :param [in]: reorder_type int Reorder type enum (see REORDER_TYPE)

openvsp.ReadAdvLinkCodeFile(index, file_name)[source]¶

Read the code of an advanced link in from a text file, the way the File Read button on the Advanced Link screen does. The link is rebuilt from the new code, so any variable the file refers to must already have been declared as an input or an output.

pod = AddGeom( "POD", "" )
length = FindParm( pod, "Length", "Design" )
x_pos = GetParm( pod, "X_Rel_Location", "XForm" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )
AddAdvLinkInput( indx, length, "len" )
AddAdvLinkOutput( indx, x_pos, "x" )

SetAdvLinkCode( indx, "x = 10.0 - len;" )
WriteAdvLinkCodeFile( indx, "ExampleLink.vspscript" )

# A second link can pick up the same code, so long as it declares len and x.
AddAdvLink( "SecondLink" )
indx2 = GetLinkIndex( "SecondLink" )
AddAdvLinkInput( indx2, length, "len" )
AddAdvLinkOutput( indx2, GetParm( pod, "Y_Rel_Location", "XForm" ), "x" )

ReadAdvLinkCodeFile( indx2, "ExampleLink.vspscript" )

assert GetAdvLinkCode( indx2 ) == GetAdvLinkCode( indx ), "ReadAdvLinkCodeFile did not load the code"

See also: WriteAdvLinkCodeFile, SetAdvLinkCode :param [in]: index int Index for advanced link :param [in]: file_name string Name of the file to read

openvsp.SortAdvLinkInputsVar(index)[source]¶

Sort the input variables of an advanced link into alphabetical order by variable name. Inputs are otherwise kept in the order they were added, which is rarely the order that reads well once a link has grown.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkInput( indx, FindParm( pod, "Length", "Design" ), "zlen" )
AddAdvLinkInput( indx, FindParm( pod, "FineRatio", "Design" ), "afine" )

SortAdvLinkInputsVar( indx )

names = GetAdvLinkInputNames( indx )

assert names[0] == "afine", "SortAdvLinkInputsVar did not sort by name"
assert names[1] == "zlen", "SortAdvLinkInputsVar did not sort by name"

See also: SortAdvLinkInputsCGP, SortAdvLinkOutputsVar :param [in]: index int Index for advanced link

openvsp.SortAdvLinkInputsCGP(index)[source]¶

Sort the input variables of an advanced link by the Parm they are attached to, ordering on container name, then group name, then Parm name. This gathers the inputs that come from the same Geom together, which is usually how a link is read.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkInput( indx, FindParm( pod, "Length", "Design" ), "a" )
AddAdvLinkInput( indx, FindParm( pod, "FineRatio", "Design" ), "b" )

SortAdvLinkInputsCGP( indx )

names = GetAdvLinkInputNames( indx )

# FineRatio sorts ahead of Length, so the variables come back swapped.
assert names[0] == "b", "SortAdvLinkInputsCGP did not sort by Parm"
assert names[1] == "a", "SortAdvLinkInputsCGP did not sort by Parm"

See also: SortAdvLinkInputsVar, SortAdvLinkOutputsCGP :param [in]: index int Index for advanced link

openvsp.SortAdvLinkOutputsVar(index)[source]¶

Sort the output variables of an advanced link into alphabetical order by variable name.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkOutput( indx, FindParm( pod, "X_Rel_Location", "XForm" ), "zx" )
AddAdvLinkOutput( indx, FindParm( pod, "Y_Rel_Location", "XForm" ), "ay" )

SortAdvLinkOutputsVar( indx )

names = GetAdvLinkOutputNames( indx )

assert names[0] == "ay", "SortAdvLinkOutputsVar did not sort by name"
assert names[1] == "zx", "SortAdvLinkOutputsVar did not sort by name"

See also: SortAdvLinkOutputsCGP, SortAdvLinkInputsVar :param [in]: index int Index for advanced link

openvsp.SortAdvLinkOutputsCGP(index)[source]¶

Sort the output variables of an advanced link by the Parm they drive, ordering on container name, then group name, then Parm name.

pod = AddGeom( "POD", "" )

AddAdvLink( "ExampleLink" )
indx = GetLinkIndex( "ExampleLink" )

AddAdvLinkOutput( indx, FindParm( pod, "Y_Rel_Location", "XForm" ), "a" )
AddAdvLinkOutput( indx, FindParm( pod, "X_Rel_Location", "XForm" ), "b" )

SortAdvLinkOutputsCGP( indx )

names = GetAdvLinkOutputNames( indx )

# X_Rel_Location sorts ahead of Y_Rel_Location, so the variables come back swapped.
assert names[0] == "b", "SortAdvLinkOutputsCGP did not sort by Parm"
assert names[1] == "a", "SortAdvLinkOutputsCGP did not sort by Parm"

See also: SortAdvLinkOutputsVar, SortAdvLinkInputsCGP :param [in]: index int Index for advanced link

Table of Contents

  • Advanced Link Functions
    • Details
      • GetAdvLinkNames()
      • GetLinkIndex()
      • GetAdvLinkName()
      • SetAdvLinkName()
      • DelAdvLink()
      • DelAllAdvLinks()
      • AddAdvLink()
      • AddAdvLinkInput()
      • AddAdvLinkOutput()
      • DelAllAdvLinkInputs()
      • DelAllAdvLinkOutputs()
      • DelAdvLinkInput()
      • DelAdvLinkOutput()
      • GetAdvLinkInputNames()
      • GetAdvLinkInputParms()
      • GetAdvLinkOutputNames()
      • GetAdvLinkOutputParms()
      • ValidateAdvLinkParms()
      • SetAdvLinkCode()
      • GetAdvLinkCode()
      • SearchReplaceAdvLinkCode()
      • BuildAdvLinkScript()
      • WriteAdvLinkCodeFile()
      • ReorderAdvLinkInput()
      • ReorderAdvLinkOutput()
      • ReadAdvLinkCodeFile()
      • SortAdvLinkInputsVar()
      • SortAdvLinkInputsCGP()
      • SortAdvLinkOutputsVar()
      • SortAdvLinkOutputsCGP()

Previous topic

API Functions by Group

Next topic

Analysis Manager Functions

This Page

  • Show Source

Quick search

Navigation

  • index
  • modules |
  • next |
  • previous |
  • OpenVSP Python API documentation »
  • API Functions by Group »
  • Advanced Link Functions
© Copyright NASA Open Source Agreement (NOSA) version 1.3. Created using Sphinx 9.1.0.