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?
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
Very helpful,Thanks!
Hello Gaurav, do you have an example to build the parameter 'query' of ecManager.FindInstances(scope, query)?
I tried this:
ECQuery ecQuery = new ECQuery(); ecQuery.AddSearchClass(/*need an IECClass parameter*/);
If i want to search all pipes,which parameter should i pass?
Hi,
an alternative, that can be used when MicroStation element is known (e.g. you obtain it iterating element cache), is to use GetElementProperties() method. It's simpler than to create query and provides everything that can be expressed as EC data, but is applicable to one element only.
DgnECManager.Manager.GetElementProperties(element, ECQueryProcessFlags.SearchAllClasses);
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
The question is that i don't have those element,i want to scan them an find them by id. but get id by IECInstance seems cant do it.
I am not familiar how plant data is structured, but when working with ECQuery, there are typically two important steps:
Often I choose to search for everything and to filter necessary information later, iterating obtained collection.