[OpenPlantModeler C#]Does anyone knows how to get elementid from IECInstance?

I found a way to get all pipe of current plant in OPM SDK's example as follow :

ECInstanceList pipeInstances = DgnUtilities.FindInstancesAndLoadRelated("PIPE", false, "PIPING_COMPONENT_HAS_PORT", true);
if (pipeInstances != null && pipeInstances.Count > 0)
{
    foreach (IECInstance pipeInst in pipeInstances)
    {
        //do something
    }
}

I could get most EC value in the pipeInst,but i can't get ElementId from it.Does Anyone knows how to get ElementId from it or have an easy way to get all pipe's ElementId?

Parents
  • there is this example code in MSSDK for CE. You will need to create the IdgnECInstance from your IECInstance

    DgnPlatformNET.DgnEC.FindInstancesScope scope = DgnPlatformNET.DgnEC.FindInstancesScope.CreateScope(activeFile, new DgnPlatformNET.DgnEC.FindInstancesScopeOption (hostType, false));
    using (DgnPlatformNET.DgnEC.DgnECInstanceCollection coll= ecManager.FindInstances(scope, query))
    {
    foreach (DgnPlatformNET.DgnEC.IDgnECInstance instance in coll)
    {
    string instanceName = instance.ClassDefinition.Name;
    string id = instance.Element.ElementId.ToString();
    string message = "Class name: " + instanceName + " Element Id: " + id;

    Answer Verified By: MingQuan Tang 

Reply
  • there is this example code in MSSDK for CE. You will need to create the IdgnECInstance from your IECInstance

    DgnPlatformNET.DgnEC.FindInstancesScope scope = DgnPlatformNET.DgnEC.FindInstancesScope.CreateScope(activeFile, new DgnPlatformNET.DgnEC.FindInstancesScopeOption (hostType, false));
    using (DgnPlatformNET.DgnEC.DgnECInstanceCollection coll= ecManager.FindInstances(scope, query))
    {
    foreach (DgnPlatformNET.DgnEC.IDgnECInstance instance in coll)
    {
    string instanceName = instance.ClassDefinition.Name;
    string id = instance.Element.ElementId.ToString();
    string message = "Class name: " + instanceName + " Element Id: " + id;

    Answer Verified By: MingQuan Tang 

Children