Parm Functions¶
Every Parm in OpenVSP can be accessed and modified through the functions defined in this API group. Every Parm has an associated ParmContainer.
|
Get Parm ID |
|
Check if given Parm is valid |
|
Overload 1: |
|
Set the value along with the upper and lower limits of the specified Parm |
|
Overload 1: |
|
Overload 1: |
|
Get the value of the specified int type Parm |
|
Get the value of the specified bool type Parm |
|
Set the upper limit value for the specified Parm |
|
Get the upper limit value for the specified Parm |
|
Set the lower limit value for the specified Parm |
|
Get the lower limit value for the specified Parm |
|
Get the data type for the specified Parm |
|
Get the name for the specified Parm |
|
Get the group name for the specified Parm |
|
Get the display group name for the specified Parm |
|
Get Parm Container ID for the specified Parm |
|
Set the description of the specified Parm |
|
Get the description of the specified Parm |
|
Find a Parm ID given the Parm Container ID, Parm name, and Parm group |
Details¶
- openvsp.GetParm(geom_id, name, group)[source]¶
Get Parm ID
#==== Add Pod Geometry ====// pid = AddGeom( "POD" ) lenid = GetParm( pid, "Length", "Design" ) if not ValidParm( lenid ) : print( "---> Error: API GetParm " ) assert False, "---> Error: API GetParm"
- Parameters:
[in] – geom_id string Geom ID
[in] – name string Parm name
[in] – group string Parm group name
- Return type:
string
- Returns:
string Parm ID
- openvsp.ValidParm(id)[source]¶
Check if given Parm is valid
#==== Add Pod Geometry ====// pid = AddGeom( "POD" ) lenid = GetParm( pid, "Length", "Design" ) if not ValidParm( lenid ) : print( "---> Error: API GetParm " ) assert False, "---> Error: API GetParm"
- Parameters:
[in] – id string Parm ID
- Return type:
boolean
- Returns:
bool True if Parm ID is valid, false otherwise
- openvsp.SetParmVal(*args)[source]¶
Overload 1:
Set the value of the specified Parm.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 23.0 ) if abs( GetParmVal( wid ) - 23 ) > 1e-6 : print( "---> Error: API Parm Val Set/Get " ) assert False, "---> Error: API Parm Val Set/Get"
See also: SetParmValUpdate :param [in]: parm_id string Parm ID :param [in]: val double Parm value to set :rtype: float :return: double Value that the Parm was set to
Overload 2:
Set the value of the specified Parm.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 23.0 ) if abs( GetParmVal( wid ) - 23 ) > 1e-6 : print( "---> Error: API Parm Val Set/Get " ) assert False, "---> Error: API Parm Val Set/Get"
See also: SetParmValUpdate :param [in]: geom_id string Geom ID :param [in]: name string Parm name :param [in]: group string Parm group name :param [in]: val double Parm value to set :rtype: float :return: double Value that the Parm was set to
- openvsp.SetParmValLimits(parm_id, val, lower_limit, upper_limit)[source]¶
Set the value along with the upper and lower limits of the specified Parm
pod_id = AddGeom( "POD" ) length = FindParm( pod_id, "Length", "Design" ) SetParmValLimits( length, 10.0, 0.001, 1.0e12 ) SetParmDescript( length, "Total Length of Geom" ) # The value and both limits have to take. assert abs( GetParmVal( length ) - 10.0 ) < 1e-9, "SetParmValLimits did not take" assert abs( GetParmLowerLimit( length ) - 0.001 ) < 1e-9, "SetParmValLimits did not take" assert abs( GetParmUpperLimit( length ) - 1.0e12 ) < 1.0, "SetParmValLimits did not take" assert GetParmDescript( length ) == "Total Length of Geom", "SetParmDescript did not take" # The limits are limits, so a value outside them gets clamped. SetParmVal( length, -1.0 ) assert abs( GetParmVal( length ) - 0.001 ) < 1e-9, "the lower limit did not hold"
See also: SetParmLowerLimit, SetParmUpperLimit :param [in]: parm_id string Parm ID :param [in]: val double Parm value to set :param [in]: lower_limit double Parm lower limit :param [in]: upper_limit double Parm upper limit :rtype: float :return: double Value that the Parm was set to
- openvsp.SetParmValUpdate(*args)[source]¶
Overload 1:
Set the value of the specified Parm and force an Update.
#==== Add Pod Geometry ====// pod_id = AddGeom( "POD" ) parm_id = GetParm( pod_id, "X_Rel_Location", "XForm" ) SetParmValUpdate( parm_id, 5.0 ) assert abs( GetParmVal( parm_id ) - 5.0 ) < 1e-9, "SetParmValUpdate"
See also: SetParmVal :param [in]: parm_id string Parm ID :param [in]: val double Parm value to set :rtype: float :return: double Value that the Parm was set to
Overload 2:
Set the value of the specified Parm and force an Update.
#==== Add Pod Geometry ====// pod_id = AddGeom( "POD" ) parm_id = GetParm( pod_id, "X_Rel_Location", "XForm" ) SetParmValUpdate( parm_id, 5.0 ) assert abs( GetParmVal( parm_id ) - 5.0 ) < 1e-9, "SetParmValUpdate"
See also: SetParmVal :param [in]: geom_id string Geom ID :param [in]: parm_name string Parm name :param [in]: parm_group_name string Parm group name :param [in]: val double Parm value to set :rtype: float :return: double Value that the Parm was set to
- openvsp.GetParmVal(*args)[source]¶
Overload 1:
Get the value of the specified Parm. The data type of the Parm value will be cast to a double
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 23.0 ) if abs( GetParmVal( wid ) - 23 ) > 1e-6 : print( "---> Error: API Parm Val Set/Get " ) assert False, "---> Error: API Parm Val Set/Get"
- Parameters:
[in] – parm_id string Parm ID
- Return type:
float
- Returns:
double Parm value
Overload 2:
Get the value of the specified Parm. The data type of the Parm value will be cast to a double
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 23.0 ) if abs( GetParmVal( wid ) - 23 ) > 1e-6 : print( "---> Error: API Parm Val Set/Get " ) assert False, "---> Error: API Parm Val Set/Get"
- Parameters:
[in] – geom_id string Geom ID
[in] – name string Parm name
[in] – group string Parm group name
- Return type:
float
- Returns:
double Parm value
- openvsp.GetIntParmVal(parm_id)[source]¶
Get the value of the specified int type Parm
#==== Add Prop Geometry ====// prop_id = AddGeom( "PROP" ) num_blade_id = GetParm( prop_id, "NumBlade", "Design" ) num_blade = GetIntParmVal( num_blade_id ) # A new propeller has three blades, and the int form has to agree with the # double form. assert num_blade == 3, "GetIntParmVal did not report the blade count" assert num_blade == int( GetParmVal( num_blade_id ) ), "GetIntParmVal disagrees with GetParmVal" # Setting it has to move both. SetParmVal( num_blade_id, 5 ) assert GetIntParmVal( num_blade_id ) == 5, "GetIntParmVal did not follow the Parm"
- Parameters:
[in] – parm_id string Parm ID
- Return type:
int
- Returns:
double Parm value
- openvsp.GetBoolParmVal(parm_id)[source]¶
Get the value of the specified bool type Parm
#==== Add Prop Geometry ====// prop_id = AddGeom( "PROP" ) rev_flag_id = GetParm( prop_id, "ReverseFlag", "Design" ) SetParmVal( rev_flag_id, 1.0 ) reverse_flag = GetBoolParmVal( rev_flag_id ) assert reverse_flag, "GetBoolParmVal did not read back a set flag" SetParmVal( rev_flag_id, 0.0 ) assert not GetBoolParmVal( rev_flag_id ), "GetBoolParmVal did not read back a cleared flag"
- Parameters:
[in] – parm_id string Parm ID
- Return type:
boolean
- Returns:
bool Parm value
- openvsp.SetParmUpperLimit(parm_id, val)[source]¶
Set the upper limit value for the specified Parm
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 23.0 ) SetParmUpperLimit( wid, 13.0 ) if abs( GetParmVal( wid ) - 13 ) > 1e-6 : print( "---> Error: API SetParmUpperLimit " ) assert False, "---> Error: API SetParmUpperLimit"
See also: SetParmValLimits :param [in]: parm_id string Parm ID :param [in]: val double Parm upper limit
- openvsp.GetParmUpperLimit(parm_id)[source]¶
Get the upper limit value for the specified Parm
#==== Add Prop Geometry ====// prop_id = AddGeom( "PROP" ) num_blade_id = GetParm( prop_id, "NumBlade", "Design" ) max_blade = GetParmUpperLimit( num_blade_id )
- Parameters:
[in] – parm_id string Parm ID
- Return type:
float
- Returns:
double Parm upper limit
- openvsp.SetParmLowerLimit(parm_id, val)[source]¶
Set the lower limit value for the specified Parm
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) SetParmVal( wid, 13.0 ) SetParmLowerLimit( wid, 15.0 ) if abs( GetParmVal( wid ) - 15 ) > 1e-6 : print( "---> Error: API SetParmLowerLimit " ) assert False, "---> Error: API SetParmLowerLimit"
See also: SetParmValLimits :param [in]: parm_id string Parm ID :param [in]: val double Parm lower limit
- openvsp.GetParmLowerLimit(parm_id)[source]¶
Get the lower limit value for the specified Parm
#==== Add Prop Geometry ====// prop_id = AddGeom( "PROP" ) num_blade_id = GetParm( prop_id, "NumBlade", "Design" ) min_blade = GetParmLowerLimit( num_blade_id ) # A propeller needs at least one blade, and the limits have to bracket the # current value. assert min_blade >= 1.0, "GetParmLowerLimit allows a propeller with no blades" assert min_blade <= GetParmVal( num_blade_id ), "the lower limit is above the value" assert min_blade <= GetParmUpperLimit( num_blade_id ), "the lower limit is above the upper limit" # Asking for less than the limit allows has to clamp to it. SetParmVal( num_blade_id, min_blade - 10.0 ) assert abs( GetParmVal( num_blade_id ) - min_blade ) < 1e-9, "the lower limit did not hold"
- Parameters:
[in] – parm_id string Parm ID
- Return type:
float
- Returns:
double Parm lower limit
- openvsp.GetParmType(parm_id)[source]¶
Get the data type for the specified Parm
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) if GetParmType( wid ) != PARM_DOUBLE_TYPE : print( "---> Error: API GetParmType " ) assert False, "---> Error: API GetParmType"
See also: PARM_TYPE :param [in]: parm_id string Parm ID :rtype: int :return: int Parm data type enum (i.e. PARM_BOOL_TYPE)
- openvsp.GetParmName(parm_id)[source]¶
Get the name for the specified Parm
#==== 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 ) for i in range(len(parm_ids)): name_id = GetParmName( parm_ids[i] ) + ": " + parm_ids[i] + "\n" assert len( name_id ) > 0, "GetParmName returned nothing" print( name_id )
- Parameters:
[in] – parm_id string Parm ID
- Return type:
string
- Returns:
string Parm name
- openvsp.GetParmGroupName(parm_id)[source]¶
Get the group name for the specified Parm
veh_id = FindContainer( "Vehicle", 0 ) #==== Get and List All Parms in the Container ====// parm_ids = FindContainerParmIDs( veh_id ) print( "Parm Groups and IDs in Vehicle Parm Container: " ) for i in range(len(parm_ids)): group_str = GetParmGroupName( parm_ids[i] ) + ": " + parm_ids[i] + "\n" assert len( group_str ) > 0, "GetParmGroupName returned nothing" print( group_str )
- Parameters:
[in] – parm_id string Parm ID
- Return type:
string
- Returns:
string Parm group name
- openvsp.GetParmDisplayGroupName(parm_id)[source]¶
Get the display group name for the specified Parm
veh_id = FindContainer( "Vehicle", 0 ) #==== Get and List All Parms in the Container ====// parm_ids = FindContainerParmIDs( veh_id ) print( "Parm Group Display Names and IDs in Vehicle Parm Container: " ) for i in range(len(parm_ids)): group_str = GetParmDisplayGroupName( parm_ids[i] ) + ": " + parm_ids[i] + "\n" assert len( group_str ) > 0, "GetParmDisplayGroupName returned nothing" print( group_str )
- Parameters:
[in] – parm_id string Parm ID
- Return type:
string
- Returns:
string Parm display group name
- openvsp.GetParmContainer(parm_id)[source]¶
Get Parm Container ID for the specified Parm
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) cid = GetParmContainer( wid ) if len(cid) == 0 : print( "---> Error: API GetParmContainer " ) assert False, "---> Error: API GetParmContainer"
- Parameters:
[in] – parm_id string Parm ID
- Return type:
string
- Returns:
string Parm Container ID
- openvsp.SetParmDescript(parm_id, desc)[source]¶
Set the description of the specified Parm
pod_id = AddGeom( "POD" ) length = FindParm( pod_id, "Length", "Design" ) SetParmValLimits( length, 10.0, 0.001, 1.0e12 ) SetParmDescript( length, "Total Length of Geom" ) assert GetParmDescript( length ) == "Total Length of Geom", "SetParmDescript did not take"
- Parameters:
[in] – parm_id string Parm ID
[in] – desc string Parm description
- openvsp.GetParmDescript(parm_id)[source]¶
Get the description of the specified Parm
pod_id = AddGeom( "POD" ) length = FindParm( pod_id, "Length", "Design" ) SetParmValLimits( length, 10.0, 0.001, 1.0e12 ) desc = GetParmDescript( length ) assert len( desc ) > 0, "GetParmDescript returned nothing" print( desc )
- Parameters:
[in] – parm_id string Parm ID
- Return type:
string
- Returns:
string desc Parm description
- openvsp.FindParm(parm_container_id, parm_name, group_name)[source]¶
Find a Parm ID given the Parm Container ID, Parm name, and Parm group
#==== Add Wing Geometry ====// wing_id = AddGeom( "WING" ) #==== Turn Symmetry OFF ====// sym_id = FindParm( wing_id, "Sym_Planar_Flag", "Sym") assert len( sym_id ) > 0, "FindParm found nothing" SetParmVal( sym_id, 0.0 ) # Note: bool input not supported in SetParmVal
- Parameters:
[in] – parm_container_id string Parm Container ID
[in] – parm_name string Parm name
[in] – group_name string Parm group name
- Return type:
string
- Returns:
string Parm ID