Hi,I am trying to access the grid properties (grid lines, coordinates, orientation, etc.) of a OpenBuildings Designer model from a c# addin. I can see from the XML export that the used EC schema should be StructuralModelingComponents.06.00.When I ask the DgnECManager for discover-able schemas, it doesn´t include that schema though.
List<string> schemas = Enumerable.ToList(manager.DiscoverSchemas(Session.Instance.GetActiveDgnFile(), ReferencedModelScopeOption.All, true));
I also tried
FindInstancesScope scope = FindInstancesScope.CreateScope(Session.Instance.GetActiveDgnFile(), new FindInstancesScopeOption(DgnECHostType.All, true)); IECSchema schema = manager.LocateSchemaInScope(scope, "StructuralModelingComponents", 6, 0, SchemaMatchType.Latest);
The IntegratedStructuralModel schema wouldn´t work either.
Are grid lines somehow not part of the model or should I look in a different schema?
Might there be a different way to access grids?
See also https://www.itwinjs.org/bis/domains/processphysical.ecschema/#ismcartesiangrid for reference.
Hi Tilman,
please respect and follow this forum best practices: Specify exactly what product and version (build number) do you use. The only information you shared so far is that you are on CONNECT Edition platform and you have design file, created in OpenBuilding (I guess OpenBuilding Designer?). But does it mean you use MicroStation to read the file? Or you have OBD (or some other OpenBuilding product)?
Tilman Reinhardt said:of a OpenBuildings model
Can you share a small example of the file?
Tilman Reinhardt said:Might there be a different way to access grids?
You did not share the whole code and also you did not share any DGN example. I do not know a structure of OBD models in detail, but I assume grid lines etc. are standard MicroStation elements with EC data attached? In your code I do not see anything, that access these elements.
Tilman Reinhardt said:Are grid lines somehow not part of the model or should I look in a different schema?
What exactly do you want to achieve?
Tilman Reinhardt said:See also https://www.itwinjs.org/bis/domains/processphysical.ecschema/#ismcartesiangrid for reference.
Not at all! What you referenced is BIS (Base Infrastructure Schema), not EC schema used in PowerPlatform CE. BIS is the successor of EC, but it is not the same.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
sorry, I also accidentally sent the post without a proper subject. (edit: found the edit button)
So I created a very simple file with AECOsim Building Designer Connect Edition Update 4 - Version 10.04.00.69
see /cfs-file/__key/communityserver-discussions-components-files/343173/grid.dgn
To read the file I use Building Designer as well.
As far as I understand, this is a feature specific to this product. Microstation (and OpenRail or OpenRoads) only allow a simple, regular grid (see screenshot). I am not looking for that (it´s stored in the ModelInfo btw).
This is why I would assume that those grids are not part of the standard EC schema (but that´s just me guessing). When I try to export the grid to .xml I get the following output, which made me assume that the model would come with a StructuralModelingComponents.06.00 schema, which I can´t access/find.
<?xml version="1.0" encoding="utf-16"?><ECInstanceXML> <IsmCartesianGrid instanceID=":56FF00000001:15A1A70000" xmlns="StructuralModelingComponents.06.00"> <Id>0f779f2e-6908-49d0-88d2-e1d5c3e50cc8</Id> <Name>BuildingGrid</Name> <RAxis> <Coordinate xmlns="">www.bentley.com/.../Bentley.Geometry.Common.1.0"> <xyz>1,0,0</xyz> </Coordinate> </RAxis> <SAxis> <Coordinate xmlns="">www.bentley.com/.../Bentley.Geometry.Common.1.0"> <xyz>0,1,0</xyz> </Coordinate> </SAxis> <Origin> <Coordinate xmlns="">www.bentley.com/.../Bentley.Geometry.Common.1.0"> <xyz>0,0,0</xyz> </Coordinate> </Origin> </IsmCartesianGrid> ... </ECInstanceXML>
My thought was to use the ECManager to access the IsmCartesianGrid:
FindInstancesScope scope = FindInstancesScope.CreateScope(Session.Instance.GetActiveDgnFile(), new FindInstancesScopeOption(DgnECHostType.All, true)); IECSchema schema = manager.LocateSchemaInScope(scope, "StructuralModelingComponents_IsmCartesianGrid", 6, 0, SchemaMatchType.Latest); IECClass[] classes = ItemInstanceCollector.ItemInstanceCollector.GetSearchClasses(schema); ECQuery query = new ECQuery(classes); DgnECInstanceCollection instances = manager.FindInstances(scope, query);
I am looking for the grid line geometry (start and end points of the lines in respect to the global coordinate system).
Thanks for pointing out the difference to the BIS.
Best,Tilman
Tilman Reinhardt said:So I created a very simple file with AECOsim Building Designer Connect Edition Update 4 - Version 10.04.00.69
Isn't it a bit old? I know it is not topic of this discussion, but I recommend to upgrade to the latest Update 8. Even when for some reason building team is not able to release new version when PowerPlatform is updated, so Update 8 is based on CE U15 platform, whereas the current is U16.1, but U15 is still much faster and stable than U11 that I guess was used for OBD CE U4.
Tilman Reinhardt said:This is why I would assume that those grids are not part of the standard EC schema (but that´s just me guessing).
I think there is a misunderstanding what EC data is and how it is used in MicroStation (but maybe the problem is only in formulation).
EC data can be attached to an element (like ItemTypes, which are a functional subset of EC data, using pre-defined EC schema), or (nearly) any element can be represented as EC data (when proper EC schema is available). But, elements are not store as EC data, so to access them as EC classes is (usually) possible, but does not makes sense, because it is just overkill.
Tilman Reinhardt said:I am looking for the grid line geometry (start and end points of the lines in respect to the global coordinate system).
Why you not access the grid line geometry using standard location and geometry API? E.g. to enumerate model to search the grid elements and to obtain its geometry using proper query?
Regards,
Is really the grid placed in the attached design file? I see one simple line with not any data attached. And in OBD (using Neutral metric dataset) it is not recognized as any building object.
Tilman Reinhardt said:As far as I understand, this is a feature specific to this product
Do you mean Grid created by Grid Manager? Why not to share this information from the beginning?
Tilman Reinhardt said:sorry, I also accidentally sent the post without a proper subject.
I think, as author, you can edit subject anytime.
it is not always visible in the view. I was also wondering, if it might be not part of the design file. But where would it come from then? And it might be not a traditional building object (also can´t be selected)?
I am also just about to update to Version 8.
Tilman Reinhardt said:it is not always visible in the view.
Ok, I found it (with some search in documentation, because my OBD knowledge is limited): Floor Manager has to be set to specific level, so the grid defined for this level is displayed.
Tilman Reinhardt said:I was also wondering, if it might be not part of the design file.
It is written in documentation that grid is transient snapable object ... which tells everything (if the terminology is the same as in API).
Tilman Reinhardt said:But where would it come from then?
Evey application can create so called transient elements: They are very similar to normal elements (they belong to levels, are displayed in views etc.), but they are not stored anywhere and are hold in memory only.
Tilman Reinhardt said:And it might be not a traditional building object (also can´t be selected)?
It seems to me more like visual aid than building object.
Tilman Reinhardt said:I am trying to access the grid properties
Let's assume the grid is implemented using transient elements. In such case, it is not accessible using standard MicroStation API, because transient elements do not exist in DGN file.
Theoretically there are two options, both using native (C/C++) API:
Tilman Reinhardt said:it might be not part of the design file
Here's some background information about transient elements.
Regards, Jon Summers LA Solutions
thank you for those extensive answers.There are functions available to access the GridSystem, but they seem to not be included in the c# wrappers.
Best,
Tilman
Tilman Reinhardt said:There are functions available to access the GridSystem, but they seem to not be included in the c# wrappers
While you're waiting for the OBD developers to extend their API, you'll have to write your own P/Invoke wrappers for the functions you want.
It isn't hard to write a wrapper, provided you known the data types of the parameters. Sometimes it's not so easy to translate between C-style data types and .NET. Here's an example from the ProjectWise programming people (MostOfDavesClasses.cs)...
MostOfDavesClasses.cs
[DllImport("dmscli.dll", CharSet = CharSet.Unicode)] public static extern bool aaApi_SelectDatasourceStatistics();
That C# file is full of useful examples, definitions, and idioms that help get you from C to C#.
Jan Ĺ legr said:Unfortunately, I think OBD API is the worst and most fragmented API from power platform products APIs, where the most of functionality is available only in (very) old C API
The ProjectWise APIs are similarly antiquated. That's why I found MostOfDavesClasses.cs extremely useful when programming with C# for PW Explorer.
Tilman Reinhardt said:There are functions available to access the GridSystem
Yes, good old C TriForma API ;-)
Unfortunately, I think OBD API is the worst and most fragmented API from power platform products APIs, where the most of functionality is available only in (very) old C API, existing from MicroStation TriForma times, and only some are available in other APIs.
Tilman Reinhardt said:but they seem to not be included in the c# wrappers.
As Jon wrote, use P/Invoke (which is standard and often used feature of NET Framework).
I have not extensive experience with OBD development, but what I heard from other people, to use C/C++ API is still "must do", when code for OBD is written.
Hi everyone,
thanks again for all your answers.
Bentley.Building.Api actually does provide an (undocumented) API.
Luckily I finally found the following example in the SDK:
BBA.ITFDrawingGrid drawingGrid = null; BBA.ITFGridSystemList gridSystems = null; BBA.ITFLoadableProject proj = GetCurrentProject(); if (null == proj) return; proj.GetDrawingGrid(false, 0, out drawingGrid); if (null == drawingGrid) return; drawingGrid.GetGridSystems(0, out gridSystems); BBA.ITFGridSystemList gridSystemNode = gridSystems; for (BBA.ITFGridSystem gridSystem = gridSystemNode.AsTFGridSystem; gridSystem != null; gridSystemNode.GetNext("", out gridSystemNode), gridSystem = (gridSystemNode != null) ? gridSystemNode.AsTFGridSystem : null) { BBA.ITFGridCurveList curves; gridSystem.GetGridCurves(0, out curves); BBA.ITFGridCurveList gridCurveNode = curves; for (BBA.ITFGridCurve gridCurve = gridCurveNode.AsTFGridCurve; gridCurve != null; gridCurveNode.GetNext("", out gridCurveNode), gridCurve = gridCurveNode != null ? gridCurveNode.AsTFGridCurve : null) { BBA.TFdGridCurveType curveType; gridCurve.GetType(0, out curveType); double gridValue; gridCurve.GetValue(0, out gridValue); } }
Cheers