Functions for Sets¶
The following group of API functions deals with set manipulation.
Get the total number of defined sets. |
|
|
Set the name of a set at specified index |
|
Get the name of a set at specified index |
|
Get an array of Geom IDs for the specified set index |
|
Get an array of Geom IDs for the specified set name |
|
Get the set index for the specified set name |
|
Check if a Geom is in the set at the specified set index |
|
Set whether or not a Geom is a member of the set at specified set index |
|
Copies all the states of a geom set and pastes them into a specific set based on passed in indexs |
|
Get the corners of the bounding box of the specified Set. |
Get the corners of the scale independent bounding box of the specified Set. |
|
|
Show every Geom in a set, leaving the rest of the model as it is. |
|
Hide every Geom in a set, leaving the rest of the model as it is. |
|
Show every Geom in a set and hide everything else. |
Details¶
- openvsp.GetNumSets()[source]¶
Get the total number of defined sets. Named sets are used to group components and read/write on them. The number of named sets will be 10 for OpenVSP versions up to 3.17.1 and 20 for later versions.
if GetNumSets() <= 0 : print( "---> Error: API GetNumSets " ) assert False, "---> Error: API GetNumSets"
- Return type:
int
- Returns:
int Number of sets
- openvsp.SetSetName(index, name)[source]¶
Set the name of a set at specified index
SetSetName( 3, "SetFromScript" ) if GetSetName(3) != "SetFromScript": print("---> Error: API Get/Set Set Name") assert False, "---> Error: API Get/Set Set Name"
See also: SET_TYPE :param [in]: index int Set index :param [in]: name string Set name
- openvsp.GetSetName(index)[source]¶
Get the name of a set at specified index
SetSetName( 3, "SetFromScript" ) if GetSetName(3) != "SetFromScript": print("---> Error: API Get/Set Set Name") assert False, "---> Error: API Get/Set Set Name"
See also: SET_TYPE :param [in]: index int Set index :rtype: string :return: string Set name
- openvsp.GetGeomSetAtIndex(index)[source]¶
Get an array of Geom IDs for the specified set index
SetSetName( 3, "SetFromScript" ) geom_arr1 = GetGeomSetAtIndex( 3 ) geom_arr2 = GetGeomSet( "SetFromScript" ) if len(geom_arr1) != len(geom_arr2) : print( "---> Error: API GetGeomSet " ) assert False, "---> Error: API GetGeomSet"
See also: SET_TYPE :param [in]: index int Set index :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Array of Geom IDs
- openvsp.GetGeomSet(name)[source]¶
Get an array of Geom IDs for the specified set name
SetSetName( 3, "SetFromScript" ) geom_arr1 = GetGeomSetAtIndex( 3 ) geom_arr2 = GetGeomSet( "SetFromScript" ) if len(geom_arr1) != len(geom_arr2) : print( "---> Error: API GetGeomSet " ) assert False, "---> Error: API GetGeomSet"
- Parameters:
[in] – name string const string set name
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
array<string> array of Geom IDs
- openvsp.GetSetIndex(name)[source]¶
Get the set index for the specified set name
SetSetName( 3, "SetFromScript" ) if GetSetIndex("SetFromScript") != 3: print("ERROR: GetSetIndex") assert False, "ERROR: GetSetIndex"
- Parameters:
[in] – name string Set name
- Return type:
int
- Returns:
int Set index
- openvsp.GetSetFlag(geom_id, set_index)[source]¶
Check if a Geom is in the set at the specified set index
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) SetSetFlag( fuseid, 3, True ) if not GetSetFlag(fuseid, 3): print("---> Error: API Set/Get Set Flag") assert False, "---> Error: API Set/Get Set Flag"
- Parameters:
[in] – geom_id string Geom ID
[in] – set_index int Set index
- Return type:
boolean
- Returns:
bool True if geom is in the set, false otherwise
- openvsp.SetSetFlag(geom_id, set_index, flag)[source]¶
Set whether or not a Geom is a member of the set at specified set index
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) SetSetFlag( fuseid, 3, True ) if not GetSetFlag(fuseid, 3): print("---> Error: API Set/Get Set Flag") assert False, "---> Error: API Set/Get Set Flag"
- Parameters:
[in] – geom_id string Geom ID
[in] – set_index int Set index
[in] – flag bool Flag that indicates set membership
- openvsp.CopyPasteSet(copyIndex, pasteIndex)[source]¶
Copies all the states of a geom set and pastes them into a specific set based on passed in indexs
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) #set fuseid's state for set 3 to true SetSetFlag( fuseid, 3, True ) #Copy set 3 and Paste into set 4 CopyPasteSet( 3, 4 ) #get fuseid's state for set 4 flag_value = GetSetFlag( fuseid, 4 ) if flag_value != True: print( "---> Error: API CopyPasteSet " ) assert False, "---> Error: API CopyPasteSet"
- Parameters:
[in] – copyIndex int Copy Index
[in] – pasteIndex int Paste Index
- openvsp.GetBBoxSet(set)[source]¶
Get the corners of the bounding box of the specified Set.
#==== Add Pod Geometry ====// pid = AddGeom( "POD" ) Update() sethasmembers, xmin, ymin, zmin, xlen, ylen, zlen = GetBBoxSet( SET_ALL ) # A pod was added above, so the set is populated and the box has real size. assert sethasmembers, "GetBBoxSet" assert xlen > 0.0 and ylen > 0.0 and zlen > 0.0, "GetBBoxSet extent"
- Parameters:
[in] – set int Desired Set
[out] – xmin_out double Minimum bounding box X coordinate
[out] – ymin_out double Minimum bounding box Y coordinate
[out] – zmin_out double Minimum bounding box Z coordinate
[out] – xlen_out double Maximum bounding box X length
[out] – ylen_out double Maximum bounding box Y length
[out] – zlen_out double Maximum bounding box Z length
- Return type:
boolean
- Returns:
bool Flag indicating whether the set has members (is non-empty)
- openvsp.GetScaleIndependentBBoxSet(set)[source]¶
Get the corners of the scale independent bounding box of the specified Set.
#==== Add Pod Geometry ====// pid = AddGeom( "POD" ) Update() sethasmembers, xmin, ymin, zmin, xlen, ylen, zlen = GetScaleIndependentBBoxSet( SET_ALL ) # A pod was added above, so the set is populated and the box has real size. assert sethasmembers, "GetScaleIndependentBBoxSet" assert xlen > 0.0 and ylen > 0.0 and zlen > 0.0, "GetScaleIndependentBBoxSet extent"
- Parameters:
[in] – set int Desired Set
[out] – xmin_out double Minimum bounding box X coordinate
[out] – ymin_out double Minimum bounding box Y coordinate
[out] – zmin_out double Minimum bounding box Z coordinate
[out] – xlen_out double Maximum bounding box X length
[out] – ylen_out double Maximum bounding box Y length
[out] – zlen_out double Maximum bounding box Z length
- Return type:
boolean
- Returns:
bool Flag indicating whether the set has members (is non-empty)
- openvsp.ShowSet(set_index)[source]¶
Show every Geom in a set, leaving the rest of the model as it is. This is the Geom browser’s Show Set button.
pid = AddGeom( "POD" ) SetSetFlag( pid, 3, True ) NoShowSet( 3 ) assert not GetSetFlag( pid, SET_SHOWN ), "NoShowSet did not hide the set" ShowSet( 3 ) assert GetSetFlag( pid, SET_SHOWN ), "ShowSet did not show the set" # A set index past the end has to be rejected. err_mgr = ErrorMgrSingleton.getInstance() ShowSet( GetNumSets() ) assert err_mgr.GetNumTotalErrors() > 0, "ShowSet accepted a set index past the end" while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: NoShowSet, ShowOnlySet :param [in]: set_index int Set index
- openvsp.NoShowSet(set_index)[source]¶
Hide every Geom in a set, leaving the rest of the model as it is.
pid = AddGeom( "POD" ) Update() SetSetFlag( pid, SET_FIRST_USER, True ) NoShowSet( SET_FIRST_USER )
See also: ShowSet, ShowOnlySet :param [in]: set_index int Set index
- openvsp.ShowOnlySet(set_index)[source]¶
Show every Geom in a set and hide everything else. This is the Geom browser’s Show Only Set button.
pod1 = AddGeom( "POD" ) pod2 = AddGeom( "POD" ) SetSetFlag( pod1, 3, True ) ShowOnlySet( 3 ) # The set is shown and everything outside it is hidden. assert GetSetFlag( pod1, SET_SHOWN ), "ShowOnlySet did not show the set" assert not GetSetFlag( pod2, SET_SHOWN ), "ShowOnlySet did not hide the rest of the model"
See also: ShowSet, NoShowSet :param [in]: set_index int Set index