Eplan Platform API
Eplan.EplApi.DataModel Namespace / PropertyValue Class
Members Example

In This Topic
    PropertyValue Class
    In This Topic
    Class holding value of P8 property.
    Inheritance Hierarchy

    System.Object
       Eplan.EplApi.DataModel.PropertyValue

    Syntax
    [DefaultMember("Item")]
    public sealed class PropertyValue 
    [DefaultMember("Item")]
    public ref class PropertyValue sealed 
    Remarks

    Its object can be created and assigned to the following types:

    • int

    • string

    • double

    • bool

    • DateTime

    Eplan.EplApi.Base.MultiLangString

    Eplan.EplApi.Base.PointD

    By definition of several conversion operators from and to other types, it simplifies access to P8 properties stored inside all kinds of PropertyList classes. The user does not have to use this class explicitly, it allows to simply assign a P8 property value to a user defined variable (See example below).

    The PropertyValue object can appear in 3 different states. Please take a look at the corresponding examples below.

    Example
    1st state: Transient – created by the user
    // This will create a new transient property and assign it to the variable oTransientProperty. 
    // If you wish to change the value of the property, use the method Eplan::EplApi::DataModel::PropertyValue::Set.
    
    PropertyValue oTransientProperty = oFunction.Properties[Properties.Function.FUNC_COMMENT];
    oTransientProperty = oTransientProperty + " additional comment";
    Again 1st state: Transient – created by the user
    // This object is not connected with any property list or StorableObject. That is why this type of property is called "transient" (or "offline").
    
    PropertyValue oTransientProperty = new PropertyValue();
    oTransientProperty.Set("Setting a value to a transient property.");
    
    
    2nd state: Persistent – collected from property list
    // The object stays connected to the property list and is therefore called a "persistent" (or "online") property.
    // In this case, the usage of Eplan::EplApi::DataModel::PropertyValue::Set updates the values in the original locations.
    
    FunctionPropertyList oFunctionPropertyList = new FunctionPropertyList();
    
    PropertyValue oPersistentProperty2 = oFunctionPropertyList["EPLAN.Project.UserSupplementaryField1"];
    // oFunctionPropertyList["EPLAN.Project.UserSupplementaryField1"] contains an empty string
    // oPersistentProperty2 contains an empty string
    
    oFunctionPropertyList["EPLAN.Project.UserSupplementaryField1"] = "Test_1";
    // oPersistentProperty2 also contains the value "Test_1"
    
    oPersistentProperty2.Set("Test_2");
    // oFunctionPropertyList["EPLAN.Project.UserSupplementaryField1"] also contains the value "Test_2"
    
    
    3rd state: Persistent – collected from any data model object
    // The object stays connected to the data model object and is therefore called a "persistent" (or "online") property.
    // In this case, the usage of Eplan::EplApi::DataModel::PropertyValue::Set updates the values in the original locations.
    
    PropertyValue oPersistentProperty = m_oTestProject.Properties["EPLAN.Project.UserSupplementaryField1"];
    // m_oTestProject.Properties.PROJ_CUSTOM_SUPPLEMENTARYFIELD01 contains an empty string
    
    m_oTestProject.Properties["EPLAN.Project.UserSupplementaryField1"] = "Test1";
    // Now oPersistentProperty also has the value "Test1"
    
    oPersistentProperty.Set("Test2");
    // Now m_oTestProject.Properties.PROJ_CUSTOM_SUPPLEMENTARYFIELD01 also has the value "Test2"
    
    
    Assigning and retrieving the property value
    Article article = myProject.Articles[0]; // A valid Article object
    
    // Below here the PropertyValue is implicitly created from int '2' and assigned to the property list.
    article.Properties[Properties.Article.ARTICLE_HEIGHT] = 2; 
    
    // Below here the PropertyValue is implicitly created from string "5" and assigned to the property list.
    article.Properties[Properties.Article.ARTICLE_HEIGHT] = "5";
    
    // Below here the PropertyValue is read form the property list and implicitly converted to string.
    string s = article.Properties[Properties.Article.ARTICLE_HEIGHT]; 
    
    // Below here the PropertyValue is read form the property list and implicitly converted to int.
    int i = article.Properties[Properties.Article.ARTICLE_HEIGHT]; 
    
    
    
    Public Constructors
     NameDescription
    Public ConstructorDefault constructor. Creates the PropertyValue object.  
    Top
    Public Properties
     NameDescription
    Public PropertyReturns an object that provides information about the property and its definition. The information includes: name of the property, its data type, whether it's indexed or not, whether it's read-only, upper/lower bounds of values for numerical properties. To use the Definition property, the PropertyValue object must point to a project property (persistent property).It cannot point to an individual value (transient property).  
    Public PropertyReturns the P8 property descriptor (id and index) that the object points to. To use the Id property, the PropertyValue object must point to a project property (persistent property). Transient PropertyValue objects don't have descriptors because they point directly to a value. A transient PropertyValue is created by operator and takes values of base types.  
    Public PropertyReturns the valid / actually used indexes. It can be used with the PropertyValue::operator []. To use the Indexes property, the PropertyValue object must point to a project property (persistent property).It cannot point to an individual value (transient property).  
    Public PropertyChecks if the property is empty. If it's not, it could be read. IMPORTANT: If property is indexed you have to set the index.  
    Public PropertyReturns or sets the object of a persistent PropertyValue which points to a specific index. To use the Item property, the PropertyValue object must point to a project property (persistent property).It cannot point to an individual value (transient property).  
    Public PropertyReturns the number of the highest used index. Indexes start at 1. If the property is not indexed or there is no used index, LastUsedIndex is 0. To use the LastUsedIndex property, the PropertyValue object must point to a project property (persistent property).It cannot point to an individual value (transient property).  
    Public PropertyProperty list to which this property value is connected.  
    Top
    Public Methods
     NameDescription
    Public MethodCopies property value to destination including all indexes. If source property is indexed destination has to be also indexed. Only indexes from 1 to minimum of both MaxIndex are copied.  
    Public MethodDestructor for deterministic finalization of PropertyValue object.  
    Public MethodOverloaded. Determines whether two PropertyValues objects have the same value.  
    Public MethodDisplay value of property as Eplan.EplApi.Base.MultiLangString.  
    Public MethodServes as the default hash function.  
    Public MethodOverloaded. Sets System.DateTime value in PropertyValue object.  
    Public MethodUsed in conversion of the PropertyValue object to bool.  
    Public MethodUsed in conversion of the PropertyValue object to double.  
    Public MethodUsed in conversion of the PropertyValue object to int.  
    Public MethodUsed in conversion of the PropertyValue object to Eplan.EplApi.Base.MultiLangString.  
    Public MethodUsed in conversion of the PropertyValue object to Eplan.EplApi.Base.PointD.  
    Public MethodOverloaded. Returns string value of this property. When type of property is MultiLangString then only the specified language is returned. In case of a transient PropertyValue object, the stored value is returned without any cast. When property can not be read, default_value is returned instead of throwing an EmptyPropertyException .  
    Public MethodUsed in conversion of the PropertyValue object to time.  
    Top
    Public Operators
    Determines whether two PropertyValues objects have the same value.
    Overloaded. Used in conversion of the PropertyValue object to int.
     
    Top
    See Also