DgnPlatformNet |
This article is for C# developers who want to write an AddIn for MicroStation CONNECT. It is an introduction to the coding required to manage reference attachments in a DGN model.
If you want to ask questions about C# development for MicroStation CONNECT, post your question to the MicroStation Programming Forum.
A DGN model is a container. It contains graphic elements, such as lines, arcs and shapes, and reference attachments. The Reference Example project shows how to attach and detach a reference. It is implemented in C# using the DgnPlatformNET and MstnPlatformNET APIs.
The class that does most of the work is the ReferenceManager
in the downloadable project.
A mystery of the .NET attachment process is that it requires a DgnDocumentMoniker
…
The DgnDocumentMoniker
is created from a file specification and is required when creating an attachment.
This MicroStation AddIn has a command table, in file Commands.xml
.
The command handlers are in class KeyinCommands
.
You can key-in the commands below in MicroStation's key-in dialog.
Commands are not case-sensitive …
Command | Sub Command 1 | Sub Command 2 | Comment |
---|---|---|---|
REFERENCEEXAMPLE | HELP | VERSION | Show the version of this AddIn |
REFERENCEEXAMPLE | REFERENCE | ATTACH | Pops a File Open dialog to locate a file to attach. Optionally, pass a logical name for the attachment |
REFERENCEEXAMPLE | REFERENCE | DETACH | Pass a logical name to detach |
DGN attachments can be assigned a
logical name.
This example lets you attach a reference, optionally specifying a logical name for the new attachement.
When you invoke the DETACH
command, you must provide a logical name,
which the code uses to identify the reference to be detached.
You can download the Reference Example Visual Studio project. The project is built using Visual Studio 2015 and .NET Framework 4.6.2 as required by MicroStation CONNECT.
The project is complete: it includes all source code, the command table XML file,
the Visual Studio solution file and is set up to build a DLL.
The DLL is placed in your ..\MicroStation\mdlapps
folder.
It's similar, in that respect, to the .NET examples delivered with the MicroStation CONNECT SDK.
Build the project, which will place file ReferenceExample.DLL
in your ..\MicroStation\mdlapps
folder.
Start MicroStation and open the key-in window (from the Utilities ribbon group).
Key-in
mdl load ReferenceExample
You should see a message confirming that the application is loaded.
Next key-in the command shown above.
Post questions about MicroStation programming to the MicroStation Programming Forum.