Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod FindOrCreate (Lib3DS_Root owner, String id, String physicalid) as Lib3DS_Object 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    object := null( Lib3DS_Object ); 
 | 
    entity := Lib3DS_Entity::FindEntityByID( id ); 
 | 
     
 | 
    // If entity is found 
 | 
    if( not isnull( entity ) ) 
 | 
    { 
 | 
      // If entity is invalid (incorrect type or physical ID does not match) 
 | 
      if ( not entity.istype( Lib3DS_Object ) or entity.PhysicalID() <> physicalid ) 
 | 
      { 
 | 
        // Delete entity (to be recreated later) 
 | 
        entity.DeleteObject(); 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        object := entity.astype( Lib3DS_Object ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
     
 | 
    // If object is not found 
 | 
    if( isnull( object ) ) 
 | 
    { 
 | 
      // Create object 
 | 
      object := Lib3DS_Object::Create( owner, id, physicalid ); 
 | 
    } 
 | 
     
 | 
    return object; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |