Attributes Manager Functions¶
This group is for functions included in the Attributes Manager. The Attributes Manager stores Attributes and provides methods to add, delete, get and set them.
Print a tab-delimited summary of all Attributes in the vehicle, denoting Name, Type, Data, Description, and path from Root of vehicle to Attribute |
|
Print a plain-text tree summary of all Attribute in the vehicle, each branch node showing the name and ID of the VSP object in the path to the attribute |
|
Returns a vector of string IDs for all Attributes in the vehicle |
|
|
Returns all attributes that contain the string search_str within their name, case insensitive |
|
Searches all attributes that contain the search string, case insensitive, and returns the user-specified index |
|
Searches all attributes in an OpenVSP object or AttributeCollection that contain the search string, case insensitive, and returns the user-specified index. |
|
Return a list of all attribute Names within an attribute collection |
|
Get all attribute IDs within a single AttributeCollection, referenced by collID |
Get array of IDs of all OpenVSP entities that have populated attributeCollections Includes attributeGroups |
|
|
Get the type of an OpenVSP Entity by ID |
|
Get the named type of an OpenVSP Entity by ID |
|
Get the name of an OpenVSP Entity by ID |
|
Get the string ID of the entity's parent Attributes -> Attribute Collections Attribute Collections -> Objects that contain attribute Collections Geoms->Parent Geoms Parms->ParmContainers etc. |
|
Get collection ID from any OpenVSP object If ID is an attribute collection, return the same ID back If ID is an attribute group, return its nested collection |
|
Get collection ID from a vehicle's GeomSet |
|
Return the name of an attribute by its ID |
|
Return the ID of an attribute by its name and collection ID |
|
Return string doc of attribute by its ID |
|
Get int enum type of attribute by ID Use in conjunction with GetAttributeTypeName for getting strings or with the following enums |
|
Get the attribute's type as a string |
|
Get the boolean value of a bool-type attribute |
|
Get the integer value of an int-type attribute |
|
Get the double value of a double-type attribute |
|
Get the string value of a string-type attribute |
|
Get the parm value of a parm-type attribute |
|
Get the parm value of a parm-type attribute |
|
Get the name of the referenced parm of a parm-type attribute |
|
Get the vec3d value of a string-type attribute |
|
Get the Int Matrix of an Int-matrix-type attribute |
|
Get the Double Matrix of an Double-matrix-type attribute |
|
Set the name of an Attribute by ID |
|
Set the docstring of an Attribute by ID |
|
Set the Bool value of a bool-type Attribute by ID |
|
Set the Int value of an int-type Attribute by ID |
|
Set the Double value of a double-type Attribute by ID |
|
Set the String value of a string-type Attribute by ID |
|
Set the ParmID value of a Parm-type Attribute by ID |
|
Set the Vec3d value of a Vec3d-type Attribute by ID |
|
Set the int matrix of a int-matrix-type Attribute by ID |
|
Set the double matrix of a double-matrix-type Attribute by ID |
|
Delete attribute by attribute ID |
|
Add a boolean attribute by name to an attribute collection |
|
Add a integer attribute by name to an attribute collection |
|
Add a double attribute by name to an attribute collection |
|
Add a string attribute by name to an attribute collection |
|
Add a parm attribute by name to an attribute collection |
|
Add a Vec3d attribute by name to an attribute collection use vec3d() to create a vec3d object to pass into the args! |
|
Add an Int Matrix attribute by name to an attribute collection use nested vectors/arrays of ints for matrix argument |
|
Add an Double Matrix attribute by name to an attribute collection use nested vectors/arrays of ints for matrix argument |
|
Add an empty Attribute Group-type attribute by name to an attribute collection |
|
Copy an attribute to the clipboard by attributeID |
|
Cut an attribute from its collection to the clipboard by attributeID |
|
Paste the attribute clipboard to the specified objectID ObjectID can be any OpenVSP entity that contains a AttributeCollection or simply the attributeCollectionID Returns a vector of pasted attributes IDs, if any |
Details¶
- openvsp.SummarizeAttributes()[source]¶
Print a tab-delimited summary of all Attributes in the vehicle, denoting Name, Type, Data, Description, and path from Root of vehicle to Attribute
##==== Attributes: SummarizeAttributes ====## SummaryText = SummarizeAttributes() assert len( SummaryText ) > 0, "SummarizeAttributes returned no id" print( SummaryText )
- Return type:
string
- Returns:
string Tab-delimited summary of all Attributes in vehicle
- openvsp.SummarizeAttributesAsTree()[source]¶
Print a plain-text tree summary of all Attribute in the vehicle, each branch node showing the name and ID of the VSP object in the path to the attribute
##==== Attributes: SummarizeAttributesAsTree ====## SummaryTextTree = SummarizeAttributesAsTree(); assert len( SummaryTextTree ) > 0, "SummarizeAttributesAsTree returned no id" print( SummaryTextTree )
- Return type:
string
- Returns:
string Plain-text attribute tree of vehicle
- openvsp.FindAllAttributes()[source]¶
Returns a vector of string IDs for all Attributes in the vehicle
##==== Attributes: FindAllAttributes ====## AttrIDs = FindAllAttributes() assert len( AttrIDs ) > 0, "FindAllAttributes found nothing" for AttrID in AttrIDs: print( AttrID )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector <string> Vector of All Attribute IDs
- openvsp.FindAttributesByName(search_str)[source]¶
Returns all attributes that contain the string search_str within their name, case insensitive
##==== Attributes: FindAttributesByName ====## AttrIDs = FindAttributesByName( "Watermark" ) assert len( AttrIDs ) > 0, "FindAttributesByName found nothing" for AttrID in AttrIDs: print( AttrID )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector <string> Vector of string IDs of matching Attributes
- Parameters:
[in] – search_str string for filtering attributes in model
- openvsp.FindAttributeByName(search_str, index)[source]¶
Searches all attributes that contain the search string, case insensitive, and returns the user-specified index
##==== Attributes: FindAttributeByName ====## AttrID = FindAttributeByName( "Watermark", 0 ) assert len( AttrID ) > 0, "FindAttributeByName found nothing" print( AttrID )
- Return type:
string
- Returns:
string Returns a StringID of the attribute indexed/searched by user, if found
- Parameters:
[in] – search_str string for filtering attributes in model
[in] – index int for indexing which of the vector of found attributes to select
- openvsp.FindAttributeInCollection(obj_id, search_str, index)[source]¶
Searches all attributes in an OpenVSP object or AttributeCollection that contain the search string, case insensitive, and returns the user-specified index. Works either with the ID of an object that contains an attributeCollection or just the ID of an attributeCollection.
##==== Attributes: FindAttributeInCollection ====## VehID = GetVehicleID() AttrID = FindAttributeInCollection( VehID, 'Watermark', 0 ) assert len( AttrID ) > 0, "FindAttributeInCollection found nothing" print( AttrID )
- Return type:
string
- Returns:
string Returns a StringID of the attribute indexed/searched by user, if found
- Parameters:
[in] – obj_id string id of object to search within for attributes
[in] – search_str string for filtering attributes in object
[in] – index int for indexing which of the vector of found attributes to select
- openvsp.FindAttributeNamesInCollection(collID)[source]¶
Return a list of all attribute Names within an attribute collection
##==== Attributes: FindAttributeNamesInCollection ====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrNames = FindAttributeNamesInCollection( CollID ) assert len( AttrNames ) > 0, "FindAttributeNamesInCollection found nothing" for AttrName in AttrNames: print( AttrName )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of result names
- Parameters:
[in] – collID string ID of an attribute collection
- openvsp.FindAttributesInCollection(collID)[source]¶
Get all attribute IDs within a single AttributeCollection, referenced by collID
##==== Attributes: FindAttributesInCollection ====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrIDs = FindAttributesInCollection( CollID ) assert len( AttrIDs ) > 0, "FindAttributesInCollection found nothing" for AttrID in AttrIDs: print( AttrID )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Vector of attribute IDs in an attribute collection.
- Parameters:
[in] – collID string ID of an attribute collection
- openvsp.FindAttributedObjects()[source]¶
Get array of IDs of all OpenVSP entities that have populated attributeCollections Includes attributeGroups
##==== Attributes: FindAttributedObjects ====## AttachIDs = FindAttributedObjects() assert len( AttachIDs ) > 0, "FindAttributedObjects found nothing" for AttachID in AttachIDs: print( AttachID )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of IDs of entities in OpenVSP that contain populated attribute collections
- openvsp.GetObjectType(attachID)[source]¶
Get the type of an OpenVSP Entity by ID
##==== Attributes: GetObjectType ====## AttachIDs = FindAttributedObjects() assert len( AttachIDs ) > 0, "FindAttributedObjects found nothing" for AttachID in AttachIDs: ObjType = GetObjectType( AttachID ) print( ObjType ) # Every object that carries attributes has to be a recognized kind, and # the enum has to agree with the name form. assert ObjType != ATTROBJ_FREE, "GetObjectType did not recognize " + AttachID assert len( GetObjectTypeName( AttachID ) ) > 0, "GetObjectTypeName returned nothing for " + AttachID
- Return type:
int
- Returns:
int return string of object name
- Parameters:
[in] – attachID string ID of an OpenVSP object
- openvsp.GetObjectTypeName(attachID)[source]¶
Get the named type of an OpenVSP Entity by ID
AttachIDs = FindAttributedObjects() for AttachID in AttachIDs: ObjTypeName = GetObjectTypeName( AttachID ) assert len( ObjTypeName ) > 0, "GetObjectTypeName returned nothing" print( ObjTypeName )
- Return type:
string
- Returns:
string return string of object name
- Parameters:
[in] – attachID string ID of an OpenVSP object
- openvsp.GetObjectName(attachID)[source]¶
Get the name of an OpenVSP Entity by ID
##==== Attributes: GetObjectName ====## AttachIDs = FindAttributedObjects() for AttachID in AttachIDs: ObjName = GetObjectName( AttachID ) assert len( ObjName ) > 0, "GetObjectName returned nothing" print( ObjName )
- Return type:
string
- Returns:
string return string of object name
- Parameters:
[in] – attachID string ID of an OpenVSP object
- openvsp.GetObjectParent(id)[source]¶
Get the string ID of the entity’s parent Attributes -> Attribute Collections Attribute Collections -> Objects that contain attribute Collections Geoms->Parent Geoms Parms->ParmContainers etc.
##==== Attributes: GetObjectParent ====## WingID = AddGeom( "WING" ) PodID = AddGeom( "POD", WingID ) ParentID = GetObjectParent( PodID ) assert len( ParentID ) > 0, "GetObjectParent returned nothing" if ParentID == WingID: print( "Parent of Pod is Wing") #Get first attribute in vehicle as an example AttrID = FindAllAttributes()[0] CollID = GetObjectParent( AttrID ) CollParentObjID = GetObjectParent( CollID ) print( CollParentObjID )
- Return type:
string
- Returns:
string ID of object parent
- openvsp.GetChildCollection(attachID)[source]¶
Get collection ID from any OpenVSP object If ID is an attribute collection, return the same ID back If ID is an attribute group, return its nested collection
##==== Attributes: GetChildCollection =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) assert len( CollID ) > 0, "GetChildCollection returned nothing" print( CollID )
- Return type:
string
- Returns:
string String ID of attribute collection associated with the attachID
- Parameters:
[in] – attachID string ID of an OpenVSP object
- openvsp.GetGeomSetCollection(index)[source]¶
Get collection ID from a vehicle’s GeomSet
##==== Attributes: GetGeomSetCollection =====## CollID = GetGeomSetCollection( 0 ) assert len( CollID ) > 0, "GetGeomSetCollection returned nothing" print( CollID )
- Return type:
string
- Returns:
string String ID of attribute collection associated with the geom set
- Parameters:
[in] – index int Geom set
- openvsp.GetAttributeName(attrID)[source]¶
Return the name of an attribute by its ID
##==== Attributes: GetAttributeName =====## AttrIDs = FindAllAttributes() for AttrID in AttrIDs: AttrName = GetAttributeName( AttrID ) assert len( AttrName ) > 0, "GetAttributeName returned nothing" print( AttrName )
- Parameters:
[in] – attrID string ID of an attribute
- Return type:
string
- Returns:
string name of attribute
- openvsp.GetAttributeID(collID, attributeName, index)[source]¶
Return the ID of an attribute by its name and collection ID
##==== Attributes: GetAttributeID =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrNames = FindAttributeNamesInCollection( CollID ) for AttrName in AttrNames: AttrID = GetAttributeID( CollID, AttrName, 0 ) assert len( AttrID ) > 0, "GetAttributeID returned nothing" print( AttrID )
- Return type:
string
- Returns:
string String ID of attribute based on collectionID and name
- Parameters:
[in] – collID string ID of an attribute collection
[in] – attributeName string name of an attribute in that collection
[in] – index int index of attribute in collection
- openvsp.GetAttributeDoc(attrID)[source]¶
Return string doc of attribute by its ID
##==== Attributes: GetAttributeDoc =====## AttrID = FindAllAttributes()[0] AttrDoc = GetAttributeDoc(AttrID) assert len( AttrDoc ) > 0, "GetAttributeDoc returned nothing" print( AttrDoc )
- Return type:
string
- Returns:
string Return string doc of attribute by its ID
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeType(attrID)[source]¶
Get int enum type of attribute by ID Use in conjunction with GetAttributeTypeName for getting strings or with the following enums
BOOL_DATA INT_DATA DOUBLE_DATA STRING_DATA VEC3D_DATA INT_MATRIX_DATA DOUBLE_MATRIX_DATA NAMEVAL_COLLECTION_DATA ATTR_COLLECTION_DATA
##==== Attributes: GetAttributeType =====## AttrIDs = FindAllAttributes() assert len( AttrIDs ) > 0, "FindAllAttributes found nothing" AttrID = AttrIDs[0] AttrType = GetAttributeType( AttrID ) print( AttrType ) # The attribute has to report a real type, and the enum has to agree with # the name form. assert AttrType != INVALID_TYPE, "GetAttributeType returned INVALID_TYPE" assert len( GetAttributeTypeName( AttrID ) ) > 0, "GetAttributeTypeName returned nothing" # An ID that is not an attribute has to report INVALID_TYPE. assert GetAttributeType( "NOSUCHATTRIBUTE" ) == INVALID_TYPE, "GetAttributeType accepted a bad ID" # That lookup failure was raised deliberately, so take it back off the queue. err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
- Return type:
int
- Returns:
int Int type of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeTypeName(attrID)[source]¶
Get the attribute’s type as a string
##==== Attributes: GetAttributeTypeName =====## AttrID = FindAllAttributes()[0] AttributeTypeName = GetAttributeTypeName( AttrID ) assert len( AttributeTypeName ) > 0, "GetAttributeTypeName returned nothing" print( AttributeTypeName )
- Return type:
string
- Returns:
string Type of attribute as string
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeBoolVal(attrID)[source]¶
Get the boolean value of a bool-type attribute
##==== Attribute: GetAttributeBoolVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = True AttrID = AddAttributeBool( CollID, "TestBoolAttr", InitVal ) GetVal = GetAttributeBoolVal( AttrID ) if GetVal[0] == InitVal: print( "Got matching Bool Value from Attribute" ) else: print( "GetAttributeBoolVal error!" ) assert False, "GetAttributeBoolVal error!"
- Return type:
std::vector< int,std::allocator< int > >
- Returns:
vector<int> Bool value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeIntVal(attrID)[source]¶
Get the integer value of an int-type attribute
##==== Attribute: GetAttributeIntVal =====// VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = 55 AttrID = AddAttributeInt( CollID, "TestIntAttr", InitVal ) GetVal = GetAttributeIntVal( AttrID ) if GetVal[0] == InitVal: print( "Got matching Int Value from Attribute" ) else: print( "GetAttributeIntVal error!" ) assert False, "GetAttributeIntVal error!"
- Return type:
std::vector< int,std::allocator< int > >
- Returns:
vector<int> Int value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeDoubleVal(attrID)[source]¶
Get the double value of a double-type attribute
##==== Attribute: GetAttributeDoubleVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = 3.14159 AttrID = AddAttributeDouble( CollID, "TestDoubleAttr", InitVal ) GetVal = GetAttributeDoubleVal( AttrID ) if GetVal[0] == InitVal: print( "Got matching Double Value from Attribute" ) else: print( "GetAttributeDoubleVal error!" ) assert False, "GetAttributeDoubleVal error!"
- Return type:
std::vector< double,std::allocator< double > >
- Returns:
vector<double> Double value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeStringVal(attrID)[source]¶
Get the string value of a string-type attribute
##==== Attribute: GetAttributeStringVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = "Hello_World_of_Attributes" AttrID = AddAttributeString( CollID, "TestStringAttr", InitVal ) GetVal = GetAttributeStringVal( AttrID ) if GetVal[0] == InitVal: print( "Got matching String Value from Attribute" ) else: print( "GetAttributeStringVal error!" ) assert False, "GetAttributeStringVal error!"
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> String value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeParmID(attrID)[source]¶
Get the parm value of a parm-type attribute
##==== Attribute: GetAttributeParmID =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) PodID = AddGeom( "POD", "" ) print( "---> Test Get Parm Val" ) ParmArray = GetGeomParmIDs( PodID ) ParmID = ParmArray[0] AttrID = AddAttributeParm( CollID, "TestParmAttr", ParmID ) GetID = GetAttributeParmID( AttrID ) if GetID[0] == ParmID: print( "Got matching Parm ID from Attribute" ) else: print( "GetAttributeParmID error!" ) assert False, "GetAttributeParmID error!"
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Parm value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeParmVal(attrID)[source]¶
Get the parm value of a parm-type attribute
##==== Attribute: GetAttributeParmVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) PodID = AddGeom( "POD", "" ) print( "---> Test Get Parm Val" ) ParmArray = GetGeomParmIDs( PodID ) ParmID = ParmArray[0] AttrID = AddAttributeParm( CollID, "TestParmAttr", ParmID ) InitVal = GetParmVal( ParmID ) GetVal = GetAttributeParmVal( AttrID ) if GetVal[0] == InitVal: print( "Got matching Parm Value from Attribute" ) else: print( "GetAttributeParmVal error!" ) assert False, "GetAttributeParmVal error!"
- Return type:
std::vector< double,std::allocator< double > >
- Returns:
vector <double> Parm value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeParmName(attrID)[source]¶
Get the name of the referenced parm of a parm-type attribute
##==== Attribute: GetAttributeParmName =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) PodID = AddGeom( "POD", "" ) print( "---> Test Get Parm Val" ) ParmArray = GetGeomParmIDs( PodID ) AttrName = 'Example_Parm_Attr' ParmID = ParmArray[0] AddAttributeParm( CollID, AttrName, ParmID ) AttrID = GetAttributeID( CollID, AttrName, 0 ) ParmName = GetAttributeParmName( AttrID )[0] if ParmName == GetParmName( ParmID ): print( "Got matching Parm Name from Attribute" ) else: print( "GetAttributeParmName error!" ) assert False, "GetAttributeParmName error!"
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector <string> Parm name of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeVec3dVal(attrID)[source]¶
Get the vec3d value of a string-type attribute
##==== Attribute: GetAttributeVec3dVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = vec3d([1., 0.5, -4.]) AttrID = AddAttributeVec3d( CollID, "TestVec3dAttr", [InitVal] ) Vec3dVal = GetAttributeVec3dVal( AttrID ) if ( Vec3dVal[0].x() == InitVal.x() ) and ( Vec3dVal[0].y() == InitVal.y() ) and ( Vec3dVal[0].z() == InitVal.z() ): print( "Got matching Vec3d Value from Attribute" ) else: print( "GetAttributeVec3dVal error!" ) assert False, "GetAttributeVec3dVal error!"
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Vec3d value of attribute
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeIntMatrixVal(attrID)[source]¶
Get the Int Matrix of an Int-matrix-type attribute
##==== Attribute: GetAttributeIntMatrixVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = [[0, 1,],[-4, -1000]] AttrID = AddAttributeIntMatrix( CollID, "TestIntMatrixAttr", InitVal ) IntMatrixVal = GetAttributeIntMatrixVal( AttrID ) IntMatrixVal = [list(row) for row in IntMatrixVal] if IntMatrixVal == InitVal: print( "Got matching IntMatrix Value from Attribute" ) else: print( "GetAttributeIntMatrixVal error!" ) assert False, "GetAttributeIntMatrixVal error!"
- Return type:
std::vector< std::vector< int,std::allocator< int > >,std::allocator< std::vector< int,std::allocator< int > > > >
- Returns:
vector<vector <int>> Int Matrix value of attribute as vector < vector < int > >
- Parameters:
[in] – attrID string ID of attribute
- openvsp.GetAttributeDoubleMatrixVal(attrID)[source]¶
Get the Double Matrix of an Double-matrix-type attribute
##==== Attribute: GetAttributeDoubleMatrixVal =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = [[0., 1.,],[-4., -1000.]] AttrID = AddAttributeDoubleMatrix( CollID, "TestDoubleMatrixAttr", InitVal ) DblMatrixVal = GetAttributeDoubleMatrixVal( AttrID ) DblMatrixVal = [list(row) for row in DblMatrixVal] if DblMatrixVal == InitVal: print( "Got matching Double Matrix Value from Attribute" ) else: print( "GetAttributeDoubleMatrixVal error!" ) assert False, "GetAttributeDoubleMatrixVal error!"
- Return type:
std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >
- Returns:
vector<vector <double>> Double Matrix value of attribute as vector < vector < Double > >
- Parameters:
[in] – attrID string ID of attribute
- openvsp.SetAttributeName(attrID, name)[source]¶
Set the name of an Attribute by ID
##==== Attribute: SetAttributeName =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = "Hello_World_of_Attributes" AttrID = AddAttributeString( CollID, "TestStringAttr", InitVal ) NameString = 'NewName_Example' SetAttributeName( AttrID, NameString ) AttrName = GetAttributeName( AttrID ) if NameString == AttrName: print( "Got matching name from Attribute") else: print( "SetAttributeName error!" ) assert False, "SetAttributeName error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – name string name for attribute
- openvsp.SetAttributeDoc(attrID, doc)[source]¶
Set the docstring of an Attribute by ID
##==== Attribute: SetAttributeDoc =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = "Hello_World_of_Attributes" AttrID = AddAttributeString( CollID, "TestStringAttr", InitVal ) DocString = 'New_docstring_for_attribute' SetAttributeDoc( AttrID, DocString ) NewDocString = GetAttributeDoc( AttrID ) if NewDocString == DocString: print( "Got matching DocString from Attribute") else: print( "SetAttributeDoc error!" ) assert False, "SetAttributeDoc error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – doc string of documentation for attribute
- openvsp.SetAttributeBool(attrID, value)[source]¶
Set the Bool value of a bool-type Attribute by ID
##==== Attribute: SetAttributeBool =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = True AttrID = AddAttributeBool( CollID, "TestBoolAttr", InitVal ) SetVal = False SetAttributeBool( AttrID, SetVal ) GetVal = GetAttributeBoolVal( AttrID ) if GetVal[0] == SetVal: print( "Set matching Bool Value from Attribute" ) else: print( "SetAttributeBoolVal error!" ) assert False, "SetAttributeBoolVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value bool boolean value for attribute
- openvsp.SetAttributeInt(attrID, value)[source]¶
Set the Int value of an int-type Attribute by ID
##==== Attribute: SetAttributeInt =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = 55 AttrID = AddAttributeInt( CollID, "TestIntAttr", InitVal ) NewIntVal = -55 SetAttributeInt( AttrID, NewIntVal ) GetVal = GetAttributeIntVal( AttrID ) if GetVal[0] == NewIntVal: print( "Set matching Int Value from Attribute" ) else: print( "SetAttributeIntVal error!" ) assert False, "SetAttributeIntVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value int value for attribute
- openvsp.SetAttributeDouble(attrID, value)[source]¶
Set the Double value of a double-type Attribute by ID
##==== Attribute: SetAttributeDouble =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = 3.14159 AttrID = AddAttributeDouble( CollID, "TestDoubleAttr", InitVal ) DoubleVal = 3.15 SetAttributeDouble( AttrID, DoubleVal ) GetVal = GetAttributeDoubleVal( AttrID ) if GetVal[0] == DoubleVal: print( "Set matching Double Value from Attribute" ) else: print( "SetAttributeDoubleVal error!" ) assert False, "SetAttributeDoubleVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value double value for attribute
- openvsp.SetAttributeString(attrID, value)[source]¶
Set the String value of a string-type Attribute by ID
##==== Attribute: SetAttributeString =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = "Hello_World_of_Attributes" AttrID = AddAttributeString( CollID, "TestStringAttr", InitVal ) StringVal = "Du bist supergeil!" SetAttributeString( AttrID, StringVal ) GetVal = GetAttributeStringVal( AttrID ) if GetVal[0] == StringVal: print( "Got matching String Value from Attribute" ) else: print( "GetAttributeStringVal error!" ) assert False, "GetAttributeStringVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value string value for attribute
- openvsp.SetAttributeParmID(attrID, value)[source]¶
Set the ParmID value of a Parm-type Attribute by ID
##==== Attribute: SetAttributeParmID =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) PodID = AddGeom( "POD", "" ) print( "---> Test Get Parm Val" ) ParmArray = GetGeomParmIDs( PodID ) ParmID = ParmArray[0] AttrID = AddAttributeParm( CollID, "TestParmAttr", ParmID ) NewParmID = ParmArray[1] SetAttributeParmID( AttrID, NewParmID ) GetID = GetAttributeParmID( AttrID ) if GetID[0] == NewParmID: print( "Set matching Parm ID from Attribute" ) else: print( "SetAttributeParmID error!" ) assert False, "SetAttributeParmID error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value string value for attribute
- openvsp.SetAttributeVec3d(attrID, value)[source]¶
Set the Vec3d value of a Vec3d-type Attribute by ID
##==== Attribute: SetAttributeVec3d =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = vec3d([1., 0.5, -4.]) AttrID = AddAttributeVec3d( CollID, "TestVec3dAttr", [InitVal] ) Vec3dVal = vec3d([0.5, 0.75, -0.4]) SetAttributeVec3d( AttrID, [Vec3dVal] ) GetVal = GetAttributeVec3dVal( AttrID ) if ( GetVal[0].x() == Vec3dVal.x() ) and ( GetVal[0].y() == Vec3dVal.y() ) and ( GetVal[0].z() == Vec3dVal.z() ): print( "Set matching Vec3d Value from Attribute" ) else: print( "SetAttributeVec3dVal error!" ) assert False, "SetAttributeVec3dVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value vec3d value for attribute
- openvsp.SetAttributeIntMatrix(attrID, value)[source]¶
Set the int matrix of a int-matrix-type Attribute by ID
##==== Attribute: SetAttributeIntMatrix =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = [[0, 1,],[-4, -1000]] AttrID = AddAttributeIntMatrix( CollID, "TestIntMatrixAttr", InitVal ) ImatVal = [[1,5],[-8,0]] SetAttributeIntMatrix( AttrID, ImatVal ) IntMatrixVal = GetAttributeIntMatrixVal( AttrID ) IntMatrixVal = [list(row) for row in IntMatrixVal] if IntMatrixVal == ImatVal: print( "Set matching IntMatrix Value from Attribute" ) else: print( "SetAttributeIntMatrixVal error!" ) assert False, "SetAttributeIntMatrixVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value int matrix value for attribute
- openvsp.SetAttributeDoubleMatrix(attrID, value)[source]¶
Set the double matrix of a double-matrix-type Attribute by ID
##==== Attribute: SetAttributeDoubleMatrix =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = [[0., 1.,],[-4., -1000.]] AttrID = AddAttributeDoubleMatrix( CollID, "TestDoubleMatrixAttr", InitVal ) NewDmatVal = [[0.,1.5],[8.4,1.1566]] SetAttributeDoubleMatrix( AttrID, NewDmatVal ) DblMatrixVal = GetAttributeDoubleMatrixVal( AttrID ) DblMatrixVal = [list(row) for row in DblMatrixVal] if DblMatrixVal == NewDmatVal: print( "Got matching Double Matrix Value from Attribute" ) else: print( "GetAttributeDoubleMatrixVal error!" ) assert False, "GetAttributeDoubleMatrixVal error!"
- Parameters:
[in] – attrID string of attribute ID
[in] – value double matrix value for attribute
- openvsp.DeleteAttribute(attrID)[source]¶
Delete attribute by attribute ID
##==== Attribute: DeleteAttribute =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = "This_Attribute_Will_Be_Deleted" AttrID = AddAttributeString( CollID, "TestStringAttr", InitVal ) AttrIDs = FindAllAttributes() AttrAdded = AttrID in AttrIDs DeleteAttribute( AttrID ) NewAttrIDs = FindAllAttributes() AttrDeleted = AttrID not in NewAttrIDs if AttrAdded and AttrDeleted: print( "Attribute successfully deleted" ) else: print( "DeleteAttribute error!" ) assert False, "DeleteAttribute error!"
- Parameters:
[in] – attrID string of attribute ID
- openvsp.AddAttributeBool(collID, attributeName, value)[source]¶
Add a boolean attribute by name to an attribute collection
##==== Attribute: AddAttributeBool =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = True AttrID = AddAttributeBool( CollID, "TestBoolAttr", InitVal ) GetVal = GetAttributeBoolVal( AttrID ) if GetVal[0] == InitVal: print( "Added Bool Attribute" ) else: print( "AddAttributeBool error!" ) assert False, "AddAttributeBool error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value bool boolean value of new attribute
- openvsp.AddAttributeInt(collID, attributeName, value)[source]¶
Add a integer attribute by name to an attribute collection
##==== Attribute: AddAttributeInt =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) InitVal = 55 AttrID = AddAttributeInt( CollID, "TestIntAttr", InitVal ) GetVal = GetAttributeIntVal( AttrID ) if GetVal[0] == InitVal: print( "Added Int Attribute" ) else: print( "AddAttributeInt error!" ) assert False, "AddAttributeInt error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value int integer value of new attribute
- openvsp.AddAttributeDouble(collID, attributeName, value)[source]¶
Add a double attribute by name to an attribute collection
##==== Attribute: AddAttributeDouble =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_Double_Attr' DoubleValue = 3.14159 AttrID = AddAttributeDouble( CollID, AttrName, DoubleValue ) GetVal = GetAttributeDoubleVal( AttrID ) if GetVal[0] == DoubleValue: print( "Added Double Attribute" ) else: print( "AddAttributeDouble error!" ) assert False, "AddAttributeDouble error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value double value of new attribute
- openvsp.AddAttributeString(collID, attributeName, value)[source]¶
Add a string attribute by name to an attribute collection
##==== Attribute: AddAttributeString =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_String_Attr' StringValue = 'Example_String_Attr_DataVal' AttrID = AddAttributeString( CollID, AttrName, StringValue ) GetVal = GetAttributeStringVal( AttrID ) if GetVal[0] == StringValue: print( "Added String Attribute" ) else: print( "AddAttributeString error!" ) assert False, "AddAttributeString error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value string value of new attribute
- openvsp.AddAttributeParm(collID, attributeName, parmID)[source]¶
Add a parm attribute by name to an attribute collection
##==== Attribute: AddAttributeParm =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) pid = AddGeom( "POD", "" ) print( "---> Test Add Parm Attr" ) parm_array = GetGeomParmIDs( pid ) AttrName = 'Example_Parm_Attr' ParmID = parm_array[0] AttrID = AddAttributeParm( CollID, AttrName, ParmID ) GetVal = GetAttributeParmID( AttrID ) if GetVal[0] == ParmID: print( "Added Parm Attribute" ) else: print( "AddAttributeParm error!" ) assert False, "AddAttributeParm error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – parmID string Parm ID to add to attribute
- openvsp.AddAttributeVec3d(collID, attributeName, value)[source]¶
Add a Vec3d attribute by name to an attribute collection use vec3d() to create a vec3d object to pass into the args!
##==== Attribute: AddAttributeVec3d =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_Vec3D_Attr' Vec3dVal = vec3d( 0.5, 0.75, -0.4 ) AttrID = AddAttributeVec3d( CollID, AttrName, [Vec3dVal] ) GetVal = GetAttributeVec3dVal( AttrID ) if ( GetVal[0].x() == Vec3dVal.x() ) and ( GetVal[0].y() == Vec3dVal.y() ) and ( GetVal[0].z() == Vec3dVal.z() ): print( "Added Vec3d Attribute" ) else: print( "AddAttributeVec3d error!" ) assert False, "AddAttributeVec3d error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value vector <vec3d> Vec3d value of new attribute
- openvsp.AddAttributeIntMatrix(collID, attributeName, value)[source]¶
Add an Int Matrix attribute by name to an attribute collection use nested vectors/arrays of ints for matrix argument
##==== Attribute: AddAttributeIntMatrix =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_IntMatrix_Attr' IntMatrix = [[1,5],[-8,0]] AttrID = AddAttributeIntMatrix( CollID, AttrName, IntMatrix ) IntMatrixVal = GetAttributeIntMatrixVal( AttrID ) IntMatrixVal = [list(row) for row in IntMatrixVal] if IntMatrixVal == IntMatrix: print( "Added IntMatrix Attribute" ) else: print( "AddAttributeIntMatrix error!" ) assert False, "AddAttributeIntMatrix error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value int matrix value of new attribute
- openvsp.AddAttributeDoubleMatrix(collID, attributeName, value)[source]¶
Add an Double Matrix attribute by name to an attribute collection use nested vectors/arrays of ints for matrix argument
##==== Attribute: AddAttributeDoubleMatrix =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_DoubleMat_Attr' DoubleMatrix = [[0.,1.5],[8.4,1.1566]] AttrID = AddAttributeDoubleMatrix( CollID, AttrName, DoubleMatrix ) DoubleMatrixVal = GetAttributeDoubleMatrixVal( AttrID ) DoubleMatrixVal = [list(row) for row in DoubleMatrixVal] if DoubleMatrixVal == DoubleMatrix: print( "Added DoubleMatrix Attribute" ) else: print( "AddAttributeDoubleMatrix error!" ) assert False, "AddAttributeDoubleMatrix error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute
[in] – value vector <vector <double>> Double matrix value of new attribute
- openvsp.AddAttributeGroup(collID, attributeName)[source]¶
Add an empty Attribute Group-type attribute by name to an attribute collection
##==== Attribute: AddAttributeGroup =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_Attr_Group' AttrID = AddAttributeGroup( CollID, AttrName ) if GetAttributeType( AttrID ) == ATTR_COLLECTION_DATA: print( "Added Attribute Group" ) else: print( "AddAttributeGroup error!" ) assert False, "AddAttributeGroup error!"
- Parameters:
[in] – collID string ID of attribute collection
[in] – attributeName string name of new attribute group
- openvsp.CopyAttribute(attrID)[source]¶
Copy an attribute to the clipboard by attributeID
##==== Attribute: CopyAttribute =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_String_Attr' StringValue = 'Example_String_Attr_DataVal' AttrID = AddAttributeString( CollID, AttrName, StringValue ) CopyError = CopyAttribute( AttrID ) if not CopyError: print("Successfully copied Attribute") else: print("CopyAttribute Error!") assert False, "CopyAttribute Error!"
- Parameters:
[in] – attrID string ID of attribute to be copied
- openvsp.CutAttribute(attrID)[source]¶
Cut an attribute from its collection to the clipboard by attributeID
##==== Attribute: CopyAttribute =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_String_Attr' StringValue = 'Example_String_Attr_DataVal' AttrID = AddAttributeString( CollID, AttrName, StringValue ) CutAttribute( AttrID ) NewCollID = GetChildCollection( "_AttrWMGroup" ) NewAttrIDs = PasteAttribute( NewCollID ) MatchIDs = NewAttrIDs[0] == AttrID Attr_Cut_Check = AttrID not in FindAttributesInCollection( CollID ) if MatchIDs and Attr_Cut_Check: print("Successfully cut Attribute") else: print("CutAttribute Error!") assert False, "CutAttribute Error!"
- Parameters:
[in] – attrID string ID of attribute to be copied
- openvsp.PasteAttribute(coll_id)[source]¶
Paste the attribute clipboard to the specified objectID ObjectID can be any OpenVSP entity that contains a AttributeCollection or simply the attributeCollectionID Returns a vector of pasted attributes IDs, if any
##==== Attribute: PasteAttribute =====## VehID = GetVehicleID() CollID = GetChildCollection( VehID ) AttrName = 'Example_String_Attr' StringValue = 'Example_String_Attr_DataVal' AttrID = AddAttributeString( CollID, AttrName, StringValue ) CutAttribute( AttrID ) NewCollID = GetChildCollection( "_AttrWMGroup" ) NewAttrIDs = PasteAttribute( NewCollID ) MatchIDs = NewAttrIDs[0] == AttrID Attr_Cut_Check = AttrID not in FindAttributesInCollection( CollID ) Attr_Paste_Check = AttrID in FindAttributesInCollection( NewCollID ) if MatchIDs and Attr_Cut_Check and Attr_Paste_Check: print("Successfully pasted Attribute") else: print("PasteAttribute Error!") assert False, "PasteAttribute Error!"
- Parameters:
[in] – coll_id string ID of destination for pasting attribute into