cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a component has entities loaded

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

Question:

How to check if a component has entities loaded and if not how to load/unload them?
I've seen the IsOpenForModeling Property but i cannot find a "reload component" method (only "End Modeling" which saves changes) - my intention is to read some data from the entities but only in "read only" mode.

 

Answer: 

 

If you need only read only access to the entities, you better use the entity level.

Still, for modeling changes we have the following methods on ITxComponent interface – SetModelingScope, IsOpenForModeling and EndModeling.

Load Entity Level can be called from the .NET API using the following code (example):

 

ITxObject obj = TxApplication.ActiveSelection.GetItems()[0];
ITxStorable storableObj = obj as ITxStorable;

if (storableObj != null)
{
    TxLibraryStorage libraryStorageObject = storableObj.StorageObject as TxLibraryStorage;
    if ((libraryStorageObject != null) && libraryStorageObject.HasDetailedRepresentation)
    {
        try
        {
            if ((obj as ITxComponent).RepresentationType == TxRepresentationType.United)//if the representation type is Detailed, then it is already in entity level.
            {
                libraryStorageObject.Reload(TxRepresentationLevel.Detailed);
            }
        }
        catch (Exception e)
        {
            ...
        }
    }
}