I am working on a C# application to be run inside OpenRoads Designer that creates a variety of 3D items (cells, cylinders, blocks, etc.) and would like to programatically create 3D constraints between these items and items that already exist in the 3D model. The MicroStation SDK includes a good example for how to do this with 2D models using native C++. Is there a managed API over Contstraint3d so that I can more readily code this using C#? Also is it possible to query for existing constraints using an ECQuery?
John Majerle said:I am working on a C# application to be run inside OpenRoads Designer
To be clear, are you looking to using the MicroStation SDK or some other functionality provided by the ORD SDK?
It looks like the Constraint3D API for C++ is new-ish. I can't see any 3D examples. The Bentley developers probably haven't got around yet to writing the .NET wrappers.
Regards, Jon Summers LA Solutions
Hi John,
John Majerle said:The MicroStation SDK includes a good example for how to do this with 2D models using native C++. Is there a managed API over Contstraint3d
It's a big jump in your formulation: Based on existing 2D C++ examples you ask about NET 3D examples ;-)
John Majerle said:so that I can more readily code this using C#?
No. General recommendation for any 3D code is "use C++". As Jon wrote, 3D modeling, including parametric and constrains, is pretty new, and when opened for 3rd party developers, it happens firstly in C++ API (and NET follows, but not always, with unspecified delay).
3D constraint API is available in C++, it's not available in NET. But you can write your own wrappers or to implement the logic in C++ and to call it from C# code.
John Majerle said:Also is it possible
Please, respect this forum rules! Do not ask more different questions in one post!
My assumption is: Yes, it would be possible. My question is: Why do you not try it yourself? The code receive relationship is not so complicated.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
I started looking into creating my own C# wrapper over the native Constraint3d. However I see that the Constraint3d API is significantly different from the Constraint2d API, so the delivered example constraint2ddemo is not very helpful in this regard. I didn't find any examples or documentation that describes how to use the Constraint3d API. Can you point me to either? I also see from the comments in Constraint3dCoreApi.h that this feature likely developed back in 2016 so the API should be fairly mature by now.
John Majerle said: I also see from the comments in Constraint3dCoreApi.h that this feature likely developed back in 2016 so the API should be fairly mature by now
Constraint3dCoreApi.h
Well, that's an optimistic view.
From class declarations like this, I suspect that things continue to evolve...
struct FixedElementId : GeometryId // NO LONGER CREATED -- For beta compatibility only.
There's also, by the way, Constraint3dElementApi.h. What does that do?
Constraint3dElementApi.h
That header file defines Constraint3dElement which looks promising. But without any documentation its hard to know what to do with it. I see functions there for reporting on existing constraints but nothing that says to me "add a constraint of a given type to an element." Perhaps the function SaveConstraints might be the one to use?
Hi John Majerle,
I have asked development to review this thread and see if we can provide some additional information (documentation and example) for your questions and to be added to a future SDK release. If enhancements are generated I will update this response with them accordingly.
Thank you,Bob
Hey Bob,
Thanks! Much appreciated.
--John M.
ConstraintsAPI_3d.pptx
here is a presentation which introduce 3d constraint in details and with some example
dorlig na said:here is a presentation which introduce 3d constraint in details and with some example
Excellent!
The PowerPoint defines a function SaveConstraintsToHost() that does not compile on the following line:
hostEh.GetDisplayHandler()->ValidateElementRange(hostEh, true);
...because the function ValidateElementRange is not defined on the struct DisplayHandler.