cancel
Showing results for 
Search instead for 
Did you mean: 

How get External ID from component?

Creator
Creator

Hello,

Please give me information how I can get External ID from component. Thank You.

6 REPLIES

Betreff: How get External ID from component?

Legend
Legend

Here an example with robot:

        public string GetExternalId(TxRobot robot)
        {
            return robot.ProcessModelId.ExternalId;
        }

Betreff: How get External ID from component?

Creator
Creator

Hello;

I prepard function for get ExternalID from each component. I have question how to check if I put all possible types inside. Below is function:

 

private string strGetExternalID(ITxComponent InputComponent)
{
TxComponent newTxComponent = InputComponent as TxComponent;
TxDevice newTxDevice = InputComponent as TxDevice;
TxRobot newTxRobot = InputComponent as TxRobot;
TxGun newTxGun = InputComponent as TxGun;
TxGripper newTxGripper = InputComponent as TxGripper;
TxHuman newTxHuman = InputComponent as TxHuman;
TxPneumaticServoGun newTxPneumaticServoGun = InputComponent as TxPneumaticServoGun;

string strExternalID = "";
try
{
if (newTxComponent != null) strExternalID = newTxComponent.ProcessModelId.ExternalId.ToString();
if (newTxDevice != null) strExternalID = newTxDevice.ProcessModelId.ExternalId.ToString();
if (newTxRobot != null) strExternalID = newTxRobot.ProcessModelId.ExternalId.ToString();
if (newTxGun != null) strExternalID = newTxGun.ProcessModelId.ExternalId.ToString();
if (newTxGripper != null) strExternalID = newTxGripper.ProcessModelId.ExternalId.ToString();
if (newTxHuman != null) strExternalID = newTxHuman.ProcessModelId.ExternalId.ToString();
if (newTxPneumaticServoGun != null) strExternalID = newTxPneumaticServoGun.ProcessModelId.ExternalId.ToString();
}
catch
{
strExternalID = "";
}

return strExternalID;
}

Betreff: How get External ID from component?

Valued Contributor
Valued Contributor

Hi

 

Is this not simpler and does the same and you don't have to worry about the type.

 

public string getexternal(ITxPlanningObject obj)
{
 string id = obj.ProcessModelId.ExternalId;

 if (!string.IsNullOrEmpty(id)) {
  return id;
 } else {
  return "";
 }

}

 

 

Betreff: How get External ID from component?

Legend
Legend

A quick look in the .Net help file:

 

Inheritance Hierarchy
System.Object
      Tecnomatix.Engineering.TxBaseGeometryCreationObject
         Tecnomatix.Engineering.TxBasePlcConveyor
         Tecnomatix.Engineering.TxComponent
         Tecnomatix.Engineering.TxConveyor
         Tecnomatix.Engineering.TxDevice
         Tecnomatix.Engineering.TxGripper
         Tecnomatix.Engineering.TxGun
         Tecnomatix.Engineering.TxHuman
         Tecnomatix.Engineering.TxPaintGun
         Tecnomatix.Engineering.TxPneumaticServoGun
         Tecnomatix.Engineering.TxRobot
         Tecnomatix.Engineering.TxServoGun
         Tecnomatix.Engineering.TxTcPlcResource
         Tecnomatix.Engineering.TxTool

Betreff: How get External ID from component?

Valued Contributor
Valued Contributor

HI

 

Yes but ITxProcessModelObject is an interface to all of these and hence TxProcessModelId is available

 

Regards

Betreff: How get External ID from component?

Legend
Legend

I think Blumenbecker's problem is to loop over all the different objects (TxComponent, TxDevice,...) in the resource tree.

In my opinion, casting is the biggest problem in this case.

At the moment, I cannot try this to provide a solution for this.

And I also have to read the helpfile first.