Parm Container Functions

All Parms in OpenVSP are stored in Parm Containers. The functions in this group can be used to work with Parm Containers through the API.

FindContainers()

Get an array of all Parm Container IDs

FindContainersWithName(name)

Get an array of Parm Container IDs for Containers with the specified name

FindContainer(name, index)

Get the ID of a Parm Container with specified name at input index

SetContainerName(parm_container_id, name)

Get the name of the specified Parm Container

GetContainerName(parm_container_id)

Get the name of a Parm container.

FindContainerGroupNames(parm_container_id)

Get an array of Parm group names included in the specified Container

FindContainerParmIDs(parm_container_id)

Get an array of Parm IDs included in the specified Container

GetVehicleID()

Get the ID of the Vehicle Parm Container

GetNumUserParms()

Get the number of user parameters

GetNumPredefinedUserParms()

Get the number of pre-defined user parameters

GetAllUserParms()

Get the vector of id's for all user parameters

GetUserParmContainer()

Get the user parm container ID

AddUserParm(type, name, group)

Function to add a new user Parm of input type, name, and group

DeleteUserParm(id)

Get the user parm container ID

DeleteAllUserParm()

Delete all user created Parms.

Details

openvsp.FindContainers()[source]

Get an array of all Parm Container IDs

ctr_arr = FindContainers()
assert len( ctr_arr ) > 0, "FindContainers found nothing"

print( "---> API Parm Container IDs: " )

for i in range(int( len(ctr_arr) )):

    message = "\t" + ctr_arr[i] + "\n"

    print( message )
Return type:

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

Returns:

vector<string> Array of Parm Container IDs

openvsp.FindContainersWithName(name)[source]

Get an array of Parm Container IDs for Containers with the specified name

ctr_arr = FindContainersWithName( "UserParms" )
assert len( ctr_arr ) > 0, "FindContainersWithName found nothing"

if  len(ctr_arr) > 0 : print( ( "UserParms Parm Container ID: " + ctr_arr[0] ) )
Parameters:

[in] – name string Parm Container name

Return type:

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

Returns:

vector<string> Array of Parm Container IDs

openvsp.FindContainer(name, index)[source]

Get the ID of a Parm Container with specified name at input index

#===== Get Vehicle Parm Container ID ====//
veh_id = FindContainer( "Vehicle", 0 )
assert len( veh_id ) > 0, "FindContainer found nothing"

See also: FindContainersWithName :param [in]: name string Parm Container name :param [in]: index int Parm Container index :rtype: string :return: string Parm Container ID

openvsp.SetContainerName(parm_container_id, name)[source]

Get the name of the specified Parm Container

veh_id = FindContainer( "Vehicle", 0 )

if  GetContainerName( veh_id) != "Vehicle":
    print( "---> Error: API GetContainerName" )
    assert False, "---> Error: API GetContainerName"
Parameters:

[in] – parm_container_id string Parm Container ID

Return type:

void

Returns:

string Parm Container name

Set the name of the specified Parm Container. This is the general counterpart to GetContainerName and works on any container reached by ID. Containers that derive their name from what they hold, such as an unsteady group, will overwrite it on their next update.

#==== Add Pod Geometry ====//
pid = AddGeom( "POD" )

SetContainerName( pid, "ExampleContainerName" )

assert GetContainerName( pid ) == "ExampleContainerName", "SetContainerName did not take"

# A Geom's container name is its Geom name, so the two agree.
assert GetGeomName( pid ) == "ExampleContainerName", "SetContainerName disagrees with GetGeomName"

# A container that does not exist has to be rejected.  The error queue is
# reached through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

SetContainerName( "NOSUCHCONTAINER", "ExampleContainerName" )

assert err_mgr.GetNumTotalErrors() > 0, "SetContainerName accepted a bad container ID"

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

See also: GetContainerName, FindContainer :param [in]: parm_container_id string Parm Container ID :param [in]: name string Parm Container name

openvsp.GetContainerName(parm_container_id)[source]

Get the name of a Parm container.

pid = AddGeom( "POD" )

SetGeomName( pid, "TestPod" )

Update()

assert GetContainerName( pid ) == "TestPod", "GetContainerName did not report the name"

See also: FindContainers, GetGeomName :param [in]: parm_container_id string Parm container ID :rtype: string :return: string Parm container name

openvsp.FindContainerGroupNames(parm_container_id)[source]

Get an array of Parm group names included in the specified Container

user_ctr = FindContainer( "UserParms", 0 )

grp_arr = FindContainerGroupNames( user_ctr )
assert len( grp_arr ) > 0, "FindContainerGroupNames found nothing"

print( "---> UserParms Container Group IDs: " )
for i in range(int( len(grp_arr) )):

    message = "\t" + grp_arr[i] + "\n"

    print( message )
Parameters:

[in] – parm_container_id string Parm Container ID

Return type:

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

Returns:

vector<string> Array of Parm group names

openvsp.FindContainerParmIDs(parm_container_id)[source]

Get an array of Parm IDs included in the specified Container

#==== Add Pod Geometry ====//
pod_id = AddGeom( "POD" )

#==== Add FeaStructure to Pod ====//
struct_ind = AddFeaStruct( pod_id )

#==== Get Structure Name and Parm Container ID ====//
parm_container_name = GetFeaStructName( pod_id, struct_ind )

parm_container_id = FindContainer( parm_container_name, struct_ind )

#==== Get and List All Parms in the Container ====//
parm_ids = FindContainerParmIDs( parm_container_id )
assert len( parm_ids ) > 0, "FindContainerParmIDs found nothing"

for i in range(len(parm_ids)):

    name_id = GetParmName( parm_ids[i] ) + ": " + parm_ids[i] + "\n"

    print( name_id )
Parameters:

[in] – parm_container_id string Parm Container ID

Return type:

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

Returns:

vector<string> Array of Parm IDs

openvsp.GetVehicleID()[source]

Get the ID of the Vehicle Parm Container

#===== Get Vehicle Parm Container ID ====//
veh_id = GetVehicleID()
assert len( veh_id ) > 0, "GetVehicleID returned nothing"
Return type:

string

Returns:

string Vehicle ID

openvsp.GetNumUserParms()[source]

Get the number of user parameters

n = GetNumUserParms()

# A fresh model already carries the predefined user Parms, and the count has
# to match the list.
assert n == GetNumPredefinedUserParms(), "GetNumUserParms does not match the predefined count"
assert n == len( GetAllUserParms() ), "GetNumUserParms disagrees with the user Parm list"

# Adding one has to move the count.
AddUserParm( PARM_DOUBLE_TYPE, "ExampleParm", "ExampleGroup" )

assert GetNumUserParms() == n + 1, "GetNumUserParms did not follow AddUserParm"
Return type:

int

Returns:

int Number of user Parms

openvsp.GetNumPredefinedUserParms()[source]

Get the number of pre-defined user parameters

n = GetNumPredefinedUserParms()

assert n > 0, "GetNumPredefinedUserParms"
Return type:

int

Returns:

int Number of pre-defined user Parms

openvsp.GetAllUserParms()[source]

Get the vector of id’s for all user parameters

id_arr = GetAllUserParms()
assert len( id_arr ) > 0, "GetAllUserParms returned nothing"

print( "---> User Parm IDs: " )

for i in range(int( len(id_arr) )):

    message = "\t" + id_arr[i] + "\n"

    print( message )
Return type:

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

Returns:

vector <string> Array of user parameter ids

openvsp.GetUserParmContainer()[source]

Get the user parm container ID

up_id = GetUserParmContainer()
assert len( up_id ) > 0, "GetUserParmContainer returned nothing"
Return type:

string

Returns:

string User parm container ID

openvsp.AddUserParm(type, name, group)[source]

Function to add a new user Parm of input type, name, and group

length = AddUserParm( PARM_DOUBLE_TYPE, "Length", "Design" )

SetParmValLimits( length, 10.0, 0.001, 1.0e12 )

SetParmDescript( length, "Length user parameter" )

See also: PARM_TYPE :param [in]: type int Parm type enum (i.e. PARM_DOUBLE_TYPE) :param [in]: name string Parm name :param [in]: group string Parm group :rtype: string :return: string Parm ID

openvsp.DeleteUserParm(id)[source]

Get the user parm container ID

n = GetNumPredefinedUserParms()
id_arr = GetAllUserParms()

if  len(id_arr) > n :
    num_before_del = GetNumUserParms()
    DeleteUserParm( id_arr[n] )
    assert GetNumUserParms() < num_before_del, "DeleteUserParm removed nothing"
openvsp.DeleteAllUserParm()[source]

Delete all user created Parms. The predefined User_0 through User_15 Parms belong to the vehicle and are not removed.

# A fresh model already carries the predefined user Parms, so record the
# starting count rather than expecting to end at zero.
num_before = GetNumUserParms()

AddUserParm( PARM_DOUBLE_TYPE, "Param1", "Group1" )
AddUserParm( PARM_DOUBLE_TYPE, "Param2", "Group1" )

assert GetNumUserParms() == num_before + 2, "AddUserParm"

DeleteAllUserParm()

assert GetNumUserParms() == num_before, "DeleteAllUserParm"