What should be used as entity ID

  XML_API > CAD XML API Reference > How To >

What should be used as entity ID

Previous pageReturn to chapter overviewNext page

Each Entity and also each Class has an unique identification: 64bit digital Handle which stays the same after saving to the file and after any changes which can be implemented to this entity.

Handles are convenient IDs to work with the entities. For instance, we sign to event "OnSelectEntity":

<?xml version="1.0" encoding="UTF-8"?>
<cadsofttools version="2">
    <!-- Sign to OnSelectEntity event. Handle in result will be the last selected entity. 
    All the selected entities can be accessed through calling "GetSelected" command, see GetSelected.xml -->
  <signtoevent Event="OnSelectEntity"/>
</cadsofttools>   

When we click on any entity, we got its handle in result parameter:

<cadsofttools version="2.0">
  <selectEntities>
    <result handle="$2B"/>
  </selectEntities>
</cadsofttools>  

 

After we can use this handle handle="$2B" to work with the entity.

If we add the entity, the application creates new Handle automatically , it is not possible to set Handle. This is a problem - when we add an entity, we do not know it's handle.

Solution:

Use HandleSave parameter with "@UniqueDigit"when add entity and after it can be called as Handle alias.

Example, Add3.xml:

<?xml version="1.0" encoding="utf-8"?>
<cadsofttools version="2">
  <!-- Description: Example shows how to work with HandleSave -->  
  <add>     
    <cstText point="10,10,0" Text="HandleSave is @77" Height="3" HandleSave="@77" />  
</add>            
<!-- Handle alias @77 can be used for select and other instructions -->
<select Handle="@77" />
 <apply Color="0;1;"/>     
<FitToSize/>                      
   <!-- Sign to OnSelectEntity event. Handle in result will be the last selected entity. 
    If you press entity which is created in this example, result will be its real Handle. -->
  <signtoevent Event="OnSelectEntity"/>
</cadsofttools>                      

 

 

Go to ABViewer