For years, Microsoft has provided developers with the tools needed to produce software applications. Beginning in 2005, Microsoft began to offer a free version of the Visual Studio software to enable anyone with a computer to write their own software applications.
The promis.e V8i software allows the development of custom plug-ins using the Microsoft .NET Framework. Whether you are an experienced software developer with access to the professional versions of Visual Studio, or you are just getting started with the Express Edition, this guide will help you develop your first promis.e V8i Plug-in.
Any version of Visual Studio 2005 or 2008 and any .NET language can be used to develop plug-ins for promis.e. This guide covers using Visual Basic 2008 Express Edition, as it will be the easiest product to obtain and use for most Promis.e users. However, a more advanced version of Visual Studio may be used, just as the C# language may be used.
The following URL is the starting point for downloading the Express Edition products from Microsoft. Download and install the Visual Basic 2008 Express Edition, unless you have a desire to use an alternate product. A download link may need to be searched for, but Visual Basic 2008 Express Edition could be downloaded from the following link when this article was last updated.
Upon completion of the install, start Visual Basic. Your screen will look something like this:
Create your first plug-in by following these steps:
When there are errors in a program, it is often helpful to run the program line-by-line in order to find where a problem is occurring. It is possible to set up Visual Studio to launch MicroStation or AutoCAD (or simply promise.exe if using promis.e V8i Standalone SELECTseries 5 or higher) and start promis.e. You can then have breakpoints set in your code in order to watch and debug the execution of your program.
The first step is to enable advanced build configurations. Go to Tools > Options… Under Project and Solutions>General, check Show advanced build configurations if it is not already checked. Click OK.
Go to Build > Configuration Manager... Select Debug as the Active solution configuration. Click Close.
Right-click MyPlugin in the Solution Explorer and select Properties. Select the Debug tab. The following items need to be set:
Command line arguments:
"C:\Program Files\Bentley\promis-e\EctEcad.dgn" "-wsms_dgnapps=C:\Program Files\Bentley\promis-e\EctEcad.ma" "-r" -wc"C:\Program Files\Bentley\promis-e\support\promisev8i.cfg"
At this point, the project has been set up to build under the Debug configuration, which will include additional data in the build that Visual Studio will use to enable line-by-line debugging of the plug-in. The Start Options that were just set will direct MicroStation to load the promis.e environment. The only thing that hasn’t been done yet is to tell Visual Basic to launch MicroStation. The method of doing this depends on whether you are using Visual Studio Express Edition or Professional Edition.
If you are using Visual Basic Express Edition, there is no option in the Debug settings to launch an external application. This feature was intentionally left out of the Express Edition user interface. Fortunately, there is a workaround to this by editing a project file.
Save the project. Use Windows Explorer to go to the project folder. (If you are not sure where the project folder is, select MyPlugin in the Solution Explorer. The project folder will be listed in the Properties window.) Look for the file “MyPlugin.vbproj.user”.
Open this file in Notepad. If the file is not present, make sure you have followed the other steps in this section and have saved the project.
Two new elements need to be added to the XML, StartAction and StartProgram. The content of the MyPlugin.vbproj.user file should end up looking similar to the following. The StartAction and StartProgram elements that must be added are shown in blue.
Note: The actual path to use for ustation.exe (MicroStation) or draft.exe (PowerDraft) depends on where the software is installed.
Close and reopen the project in Visual Basic in order for the updated file settings to be loaded. Open Class1.vb and set a breakpoint at the line “MsgBox("This my plug-in!")”. Go to Debug > Start Debugging. The project will build and MicroStation will start and load promis.e. From the Plug-ins menu, select My Plugin, as you did earlier. This time, execution will pause at the breakpoint.
Note: If you get any errors related to LoaderLock you can ignore them and click continue to proceed. If you wish you can turn of LoaderLock by deselecting it in Debug > Exceptions > Managed Debugging Assistants.
If you are using Visual Studio Professional, setting up the debugging environment is a somewhat easier than in the Express Edition. In addition to the Start Options set earlier in the Debug page, you should also select Start external program and enter the path to the main MicroStation executable.
To debug promis.e V8i Standalone (SELECTseries 5 or higher), follow the instructions above, but use the settings in this section instead.In the Debug tab of the Properties dialog make these settings:Command Line Arguments: "C:\ProgramData\Bentley\promis-e V8i(M)\Config\Ecad.dgn"Working Directory: C:\Program Files (x86)\Bentley\promise V8i\promise\To execute an External program enter this: C:\Program Files (x86)\Bentley\promise V8i\promise\promise.exe
To debug promis.e using AutoCAD, follow the instructions above, but use the settings in this section instead.
In the Debug tab of the Properties dialog make these settings:
Command Line Arguments: "C:\Program Files\Bentley\promis-e\ECAD.dwg" /b "C:\Program Files\Bentley\promis-e\autocad2007\autoload2009.scr"
Working Directory: C:\Program Files\Bentley\promis-e\autocad2007\
To execute an External program enter this: C:\Program Files\AutoCAD 2009\acad.exe
Note: The actual external program path to use depends on the location of acad.exe. If AutoCAD 2006 is used, use the autocad2006 subfolder and the script file in that folder. If AutoCAD 2007 – 2009 is used, use the autocad2007 subfolder and the appropriate script file in that folder.