C# Microstation CONNECT Update 13
I have a .dgn file loaded in the current session of MicroStation which contains a design model named "default" and a sheet model named "Sheet1".
How can I set the active model programmatically by the name "Sheet1" so that it is the currently active model for the user in the current MicroStation session?
I can do it crudely by sending a key-in command to activate the model, but was hoping I could do this more directly with .NET.
Thank you
Regards
Stephen
Hi Stephen,
Stephen Holmes said:I can do it crudely by sending a key-in command to activate the model
What is crude in using key-ins?
To use key-ins when alternative in API exists is bad practice, but in some situations and scenarios (like the discussed one) it can be elegant solution.
Stephen Holmes said:How can I set the active model programmatically by the name "Sheet1" so that it is the currently active model for the user in the current MicroStation session?
Did you search existing discussions? I remember it has been asked many times.
Stephen Holmes said:but was hoping I could do this more directly with .NET.
I think there is no "activate" method in new NET API available. Maybe it can be achieved to simulate individual steps related to loading caches etc. but it's not straightforward and simple.
But you can always use what is available and works fine in Interop (see e.g. this discussion) or you can call something like mdlModelRef_activateAndDisplay() through P/Invoke.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan
I found a post from 2 years ago that said an enhancement request had been submitted to include it in the .NET API.
Was just checking that I had not missed it in the API.
Not ventured into using P/Invoke yet, so will give it a try.
Thanks for confirming.
I'm not sure, you have the code still. But could you just share if it is worked ?
I have the same situation here.