I've been able to access certain drainage properties I need using a PropertyHandler on drainage node elements when the drainage model is in the active model. I can't get to that information if I'm in a master file with the drainage file referenced. Is this possible?
Below is my code, when the drainage is in the active model, the ConsensusConnection.GetAllGeometricModels() returns the GeoModel with the drainage, if the drainage model is in a reference the GetAllGeometricModels returns nothing.
public static void FindDrainageStructures(string unparsed) { using (ConsensusConnection consensusConnection = new ConsensusConnection(Session.Instance.GetActiveDgnModel())) { foreach (GeometricModel geoModel in consensusConnection.GetAllGeometricModels()) { if (geoModel != null) { Bentley.Civil.Subsurface.SDKNet.SubsurfaceModel act_sueModel = SubsurfaceModel.Create(geoModel); IEnumerable<Node> sue_nodes = act_sueModel.GetNodes(); foreach (Node node in sue_nodes) { Element element = node.Element; BIM.Element comElement = BMI.Utilities.ComApp.ActiveModelReference.GetElementByID(element.ElementId); Bentley.Interop.MicroStationDGN.PropertyHandler propertyHandler = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.CreatePropertyHandler(comElement); double curbOpeningLength = 0.00; if (propertyHandler != null) { if (propertyHandler.SelectByAccessString("Physical_CurbOpeningLength")) { string curbOpeningLengthString = propertyHandler.GetValue().ToString(); double.TryParse(curbOpeningLengthString, out curbOpeningLength); } } } } } } }
Hi Mike,
Mike Robertson said:I need using a PropertyHandler
In my opinion there is no single reason to use PropertyHandler when C# is used in CE products.
I recommend to learn more about EC data. Blog CRUD operations is good place where to start (plus to search Programming Forum files for presentations and materials).
What is not covered in the mentioned blog, is simple and very useful method DgnECManager.GetElementProperties(), but you can find mentioned this method in many discussions.
Mike Robertson said:I can't get to that information if I'm in a master file with the drainage file referenced. Is this possible?
I do not know Subsurface data model in detail and how API works in relation to active / reference data, but alternative approach (less efficient I guess) is to iterate reference file(s) content and to check what EC data is attached to elements and to consume data directly.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jan Šlegr said:CRUD operations is good place where to start (plus to search Programming Forum files for presentations and materials).
FYI. I would also like to point out our CONNECT APIS > EC (topic you may need to scroll Up and Down) that provides a lot of helpful (orientatiion and reference) information on EC and BIS. The EC link above will continue to work as a great starting point for getting started resources for EC, BIS and Digital Twins however I will move that information and better organize the topics content into a more formal and dedicated EC wiki page (soon).
Thank you and HTH,Bob