Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Working with the oda:condition Tag

The <oda:condition> means "if" in programming. It has two attributes:

  • name="name" — Name of the element that contains the value used in the condition.
  • oda:conditionValue="value" — Value or expression that will be compared with the element specified in the "name" attribute. Types of expressions:
    • ">value" — Greater than. The program enters the tag <oda:condition> if the value that is taken from the cache by the attribute "name" is greater than the value from the "oda:conditionValue" attribute. For example:
      
      <xs:element name="someNameElement" type="xs:boolean" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue=">0">
      	...
      </oda:condition>
      	  
    • "<value" — Less than. The program enters the tag <oda:condition> if the value that is taken from the cache by the attribute "name" is less than the value from the "oda:conditionValue" attribute. For example:
      
      <xs:element name="someNameElement" type="xs:int" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="<0"> 
        ...
      </oda:condition>
      	  
    • "!value" — Not equal. The program enters the tag <oda:condition> if value that is taken from the cache by the attribute "name" is not equal to the value from the "oda:conditionValue" attribute. For example:
      
      <xs:element name="someNameElement" type="xs:int" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="!0"> 
        ...
      </oda:condition>
      	  
    • "value" — Equal to a numerical value. The program enters the tag <oda:condition> if the value that is taken from the cache by the attribute "name" is equal to the value from the "oda:conditionValue" attribute. For example:
      
      <xs:element name="someNameElement" type="xs:int" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="0"> 
        ...
      </oda:condition>
      	  
    • "true | false" — Equal to bool value. The program enters the tag <oda:condition> if the value that is taken from the cache by the attribute "name" is equal to the value from the "oda:conditionValue" attribute. For example:
      
      <xs:element name="someNameElement" type="xs:boolean" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="true">
        ...
      </oda:condition>
      	  
    • "*value" — Bit conjunction (AND) for a numerical value. The program enters the tag <oda:condition> if the result of the bit conjunction of the value that is taken from the cache by the attribute "name" and the value from the "oda:conditionValue" attribute return a non-zero result. For example:
      
      <xs:element name="someNameElement" type="xs:int" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="*3"> 
        ...
      </oda:condition>
      	  
    • "!*value" — Inversion of bit conjunction (AND) for a numerical value. The program enters the tag <oda:condition> if the result of the bit conjunction of the value that is taken from the cache by the attribute "name" and the value from "oda:conditionValue" attribute return a zero result. For example:
      
      <xs:element name="someNameElement" type="xs:int" oda:isCondition=""/>
      <oda:condition name="someNameElement" oda:conditionValue="!*3"> 
        ...
      </oda:condition>
      	  

Useful extra attributes for <oda:condition>:

  • oda:isMarkCondition="" — Used for conditions that do not have a value in the cache. For example, in C++ and XML:
    
    bool bEntry = pFiler->rdBool();
    bool bEntry_2 = false;
    if(bEntry)
    {
      bEntry_2 = pFiler->rdBool();
    }
    if(bEntry_2)
    {
      tolerance = pFiler->rdDouble();
    }
    
    <xs:element name="bEntry" type="xs:boolean" oda:isCondition/>
    <oda:condition name="bEntry" oda:conditionValue="true">
      <xs:element name="bEntry_2" type="xs:boolean" oda:isCondition/>
    </oda:condition>
    <oda:condition name=" bEntry_2" oda:conditionValue="true" oda:isMarkCondition="">
      <xs:element name="tolerance " type="xs:double"/>
    </oda:condition>
      
  • oda:isOwner="value" — Searches in the call stack for the string/name of the specified class. The program enters the tag if oda:conditionValue="false" and the class wasn't found in the stack or if oda:conditionValue="true" and the class was found in the stack.
    Note: An " oda:isMarkCondition="" " attribute must always be with an "oda:isOwner" attribute. For example, in C++ and XML:
    
    void OdChildClass::dwgOutFields(OdDbDwgFiler* pFiler) const
    {
      OdBaseClass::dwgOutFields(pFiler);
      //Do something
    }
    
    
    void OdBaseClass::dwgOutFields(OdDbDwgFiler* pFiler) const
    {
      if(strcmp(this->isA()->name(), "OdChildClass") == 0)
      {
        //Do something
      }
      //Do something
    }
    
    <xs:complexType name=" OdChildClass" oda:version="1.0">
      <xs:complexContent>
        <xs:extension base=" OdBaseClass ">
          <xs:sequence>
            //Do something
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
    
    
    <xs:complexType name=" OdBaseClass" oda:version="1.0">
      <xs:sequence>
        <oda:condition name="empty" oda:conditionValue="true" oda:isMarkCondition="" oda:isOwner=" OdChildClass">
          //Do something
        </oda:condition>
        //Do something
      </xs:sequence>
    </xs:complexType>
      

To place a value into the cache, you must use the " oda:isCondition="" " attribute for the "xs:element" tag. This attribute marks only an xs:element tag that has one of the following types:

  • Bool
  • Byte
  • Short
  • Int
  • UnsignedByte
  • UnsignedShort
  • UnsignedInt
  • Long
  • Handle
  • SoftOwnershipId
  • HardOwnershipId
  • SoftPointerId
  • HardPointerId

You don't need to set a value to this attribute. It should be empty.

See Also

Working with the XML Scheme for Revision Control

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.