Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Inserting an Instance of an Equipment prototype

Experimenter
Experimenter

I am trying to insert an instance of an Equipment prototype using:

 

Dim EPInsert As New TxInsertComponentCreationData("Name", Path)

TxApplication.ActiveDocument.PhysicalRoot.InsertComponent(EPInsert)

 

The problem seems to be that the 'Prototype' property of the TxInsertComponentCreationData class needs to be set for equipment prototypes. However I am struggling to retrieve the Equipment prototype from the Engineering Resource library as there is no obvious way to do this.

 

If i try use:

 

PlanningRepresentation.GetField("masterObj")

 

I get an error in application exception.

5 REPLIES 5

Re: Inserting an Instance of an Equipment prototype

Legend
Legend

@KyleRobotics 

 

  1. You have know which planing object have been used as a prototype. E.g. the user can select this object in the navigation tree.
  2. I have took a look in the customization. The ToolPrototype class has not a field "masterObj". 

Best Regards

Witalij.

 

Re: Inserting an Instance of an Equipment prototype

Experimenter
Experimenter

I am aware that the user can select the proptotype as you suggested in point 1) and this will work.

However this does not solve my problem as the selection needs to be done through the API.

Re: Inserting an Instance of an Equipment prototype

Legend
Legend

you can get the selection with TxApplication.ActiveSelection.

Re: Inserting an Instance of an Equipment prototype

Experimenter
Experimenter

I'm trying to insert instances from a list of equipment prototypes from a database so there can be no user selection.

The solution I came up with:

1) Load every prototype from the Resource Library with TxEmsTraversalManager.GetAllDescendants, into a dictionary(using its directory path as the key).
2) Get the directory path for the given equipment prototype that is being inserted.
3) Retrieve the prototype from the dictionary using the directory path.

 

This is however extremely slow because I have to load every single prototype using TxEmsTraversalManager, there must be an easier way to retrieve an equipment prototype.

 

 

 

Re: Inserting an Instance of an Equipment prototype

Legend
Legend

@KyleRobotics 

you can try to use the GetObjectsByProcessModelIds or GetObjectsByInternalIds, depending on what IDs have you stored in the database, of the TxEmsGlobalServicesProvider Class. In case if you run Proces Simulate with eM Server, you get an instance of this class under TxApplication.ActiveDocument.PlatformGlobalServicesProvider.

 

Best Regards

Witalij.