Hi,
I am currently trying to adapt the 'DgnECManagedCrudExample' (https://communities.bentley.com/products/programming/microstation_programming/b/weblog/posts/ec-crud-operations-with-native-and-managed-dgnec-apis#CreateECInstancesAndRelationships) to our needs.It works fine with the simple (custom) schema from the example. If I try with the class 'Concrete__x0020__Column' from the 'BuildingDataGroup' schema I run into an 'EnvironmentalException' ("CreateInstanceOnElement failed with error code: 32768") when I try to create the 'IDgnECInstance'. The 'SupportsCreateInstanceOnElement' flag is also false (it´s true in case of the simple schema). I tried the other methods of creating an instance in 'DgnECInstanceEnabler' as well.
bool supportsCreateInstanceOnElement = widgetEnabler.SupportsCreateInstanceOnElement; IDgnECInstance widgetInstance = widgetEnabler.CreateInstanceOnElement(lineElement, widgetWipInstance, false);
I have columns with that exact EC instance attached in the same model.
Am I missing something here? Is this not allowed?
Cheers
My example code:
DgnFile activeDgnFile = Session.Instance.GetActiveDgnFile(); ModelId modelId = activeDgnFile.DefaultModelId; StatusInt statusInt; DgnModel activeDgnModel = activeDgnFile.LoadRootModelById(out statusInt, modelId, true, true, true); DgnECManager dgnECManager = DgnECManager.Manager; DPoint2d startPoint = new DPoint2d(0, 0); DPoint2d endPoint = new DPoint2d(10 * UoR, 10 * UoR); DSegment3d segment3D = new DSegment3d(startPoint, endPoint); LineElement lineElement = new LineElement(activeDgnModel, null, segment3D); if (null != lineElement) lineElement.AddToModel(); string schemaName = "BuildingDataGroup"; FindInstancesScope scope = FindInstancesScope.CreateScope(Session.Instance.GetActiveDgnFile(), new FindInstancesScopeOption(DgnECHostType.All, false)); IECSchema schema = DgnECManager.Manager.LocateSchemaInScope(scope, schemaName, 1, 0, SchemaMatchType.Latest); string className = "Concrete__x0020__Column"; IECClass ecClass = schema.GetClass(className); DgnECInstanceEnabler widgetEnabler = dgnECManager.ObtainInstanceEnabler(activeDgnFile, ecClass); ECDInstance widgetWipInstance = widgetEnabler.SharedWipInstance; bool supportsCreateInstanceOnElement = widgetEnabler.SupportsCreateInstanceOnElement; IDgnECInstance widgetInstance = widgetEnabler.CreateInstanceOnElement(lineElement, widgetWipInstance, false);
Hi Tilman,
Building products might have handlers/listeners for their own classes. Or, Concrete__x0020__Column could be an intrinsic class. Meaning, Concrete class properties may not be persisted as "ECXAttributes". Ideally, you should use Building APIs to create the concrete columns. Let me check if someone could direct you to Building development communities.
Thanks,
Mangesh
Hi Mangesh,with using the 'Building APIs' you are referring to Bentley.Building.Api (and not the COM interface) right?If you could help me with some directions, that would be highly welcome!
Tilman Reinhardt said:If you could help me with some directions, that would be highly welcome!
As Mangesh wrote: Let me check if someone could direct you to Building development communities.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Mangesh & Jon, Any updates on the Building development communities?
Tony Zhang said: Any updates
I neither work for Bentley Systems nor have any relationship with the building product developers. I can't help further.
Mangesh.Shelar is a Bentley Systems staffer and is knowledgable and helpful about EC and Item Type technologies. However, he works for core development and is not a building product developer. To help your cause, it would be encouraging if a Bentley Systems building developer would respond to your question.
Regards, Jon Summers LA Solutions
Hi Tony,
Tony Zhang said:Any updates on the Building development communities?
as Jon wrote, you should ask people from building team, because it's really product specific issue.
Tilman Reinhardt said:My example code:
To share test case (Visual Studio solution with simple DGN) would help a lot, because probably nobody from users tries to create complete project, write code and try it in OBD.
Tilman Reinhardt said:If I try with the class 'Concrete__x0020__Column' from the 'BuildingDataGroup' schema
Why you want to do such thing?
I have no OBD installed, so I am not able to check whether the schema is delivered as external with product, is created ad hoc in product or there is schema provider, dynamically transforming proprietary data to standard EC representation (see Mangesh's answer).
You should always expect, that you cannot freely create "some EC class", because very often they represent data, stored in different format (e.g. when DGN elements are represented as EC instances), or have plenty of dependencies, so API fails. In these cases, proper API must be used to create an object, that can be later queried as EC data.
With regards,