I am trying to insert an instance of an Equipment prototype using:
Dim EPInsert As New TxInsertComponentCreationData("Name", Path)
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:
I get an error in application exception.
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.
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.
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.