<< Click to Display Table of Contents > 

Client Control Interface Manual > Programming Examples > Retrieve Entities

Retrieve Entities
Previous pageReturn to chapter overviewNext page

The following C# code uses SAMLight Client Control first to list all toplevel entities and then all entities including their possible entity names by message box. If further parameters of all entities like the set pen number or the Mark Loop Count should be requested, empty entities have to be renamed to a unique entity name first. Then parameter has to be requested by entity settings command and entity name has to be reset again. To speed up an automatic entity scan the command ScSetMode can be used similar as in Optimize Performance Example 2.

 

Retrieve Entities
 

// important: the BSTR-pointer has to be initialized, otherwise the COM -interface may crash!

string name = "", type = "";

int i, count;

// step through all available toplevel entities

cci.ScSetMode( ( int )ScComSAMLightClientCtrlFlags.scComSAMLightClientCtrlModeFlagTopLevelOnly );

count = cci.ScGetLongValue( ( int )ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeTopLevelEntityNum );

if( count > 0 )

{

  for( i = 0; i < count; i++ )

   {

      // get the name of the entity at the index position "i"

       cci.ScGetIDStringData( ( int )

      ScComSAMLightClientCtrlFlags.scComSAMLightClientCtrlStringDataIdGetToplevelEntity, i, ref name );

      if( name == "" )

           name = "'empty'";

       cci.ScGetIDStringData( ( int )

      ScComSAMLightClientCtrlFlags.scComSAMLightClientCtrlStringDataIdGetEntityType, i, ref type );

      MessageBox.Show( "entity number: " + ( i + 1 ) + ", entity name: " + name + ",entity type: " + type, "total number of toplevel entities: " + count.ToString() );

   }

}

else

  MessageBox.Show( "No top level entities found", "total number of toplevel entities: 0" );

// step through all available entities

cci.ScSetMode( 0 );

count = cci.ScGetLongValue( ( int )

ScComSAMLightClientCtrlValueTypes.scComSAMLightClientCtrlLongValueTypeTotalEntityNum );

if( count > 0 )

{

  for( i = 0; i < count; i++ )

   {

      // get the name and type of the entity at the index position "i"

       cci.ScGetIDStringData( ( int )ScComSAMLightClientCtrlFlags.scComSAMLightClientCtrlStringDataIdGetEntity_Name, i, ref name );

      if( name == "" )

           name = "'empty'";

       cci.ScGetIDStringData( ( int )

      ScComSAMLightClientCtrlFlags.scComSAMLightClientCtrlStringDataIdGetEntityType, i, ref type );

      MessageBox.Show( "entity number: " + ( i + 1 ) + ", entity name: " + name + ", entity type: " + type, "total number of entities: " + count.ToString() );

   }

}

else

  MessageBox.Show( "No entities found", "total number of entities: 0" );

Table 417: Retrieve Entities