Publish Date: January 2006
Bentley recommends using "native code" for application development with MicroStation V8 XM Edition -- native code being a term for an application written in Visual C/C++ and compiled into a DLL. In this article, three points will be addressed; how to build a new native code application; what needs to be done to convert existing applications to native code; and finally how to work with native code applications (i.e. load, debug, etc.) Before getting started, you need to make sure you have the right development tools. For native code application development in MicroStation V8 XM Edition, you need VisualStudio .NET 2003 Edition, which includes VisualC/C++ 7.1. It is also recommended to use C++ rules for compiling, since those provide a stricter environment to build applications with and can also help find programming errors. When you install the MicroStation SDK, the MicroStation Developer Shell will detect where VisualStudio is installed and run the vsvars32.bat file to set the correct paths and environment variables. Once the basic environment is established, the next thing to consider is actual development. For new applications, the development process is somewhat similar to traditional MDL application development. The main source code file name should be in the form FileName.cpp, where the the .cpp extension is associated to the Visual C/C++ compiler. Other important points include:
Private MdlCommandName commandName[] = { {AddData, "AddData"}, {ReviewData, "ReviewData"}, 0 }; Private MdlCommandNumber commandNumber[] = { {templateapp_command_test, CMD_TEMPLATEAPP_TEST }, {templateapp_command_sctest, CMD_TEMPLATEAPP_SCTEST }, 0 }; /* **//** * @description Main entry point for the example. * @param argc IN Number of arguments passed in argv * @param *argv[] IN Array of pointers to arguments * @return SUCCESS * @remarks + + + ~-+ + + */ extern "C" DLLEXPORT int MdlMain ( int argc, char *argv[] ) { RscFileHandle rscFileH; /* a resource file handle */ mdlResource_openFile (&rscFileH, NULL, 0); mdlSystem_registerCommandNumbers (commandNumber); mdlParse_loadCommandTable (NULL); mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, templateapp_onUnload); mdlState_registerStringIds (STRINGLISTID_CommandNames, STRINGLISTID_CommandNames); return SUCCESS; }
#define DLLAPPID 1 /* associate app with dll */ DllMdlApp DLLAPPID = { "PlaceLineToolDLL", "PlaceLineToolMDL" }
#------------------------------------------------ # Set up to use dlrncornp.rnki and dlrnlink.rnki #------------------------------------------------ dlrnObjs = $(0) $(appNarne) $(oext) DLM_DEST = $(rndlapps) DLM_OBJECT_DEST = $(0) DLM_LIBDEF_SRC = $(baseDir) DLM_NAME = $(appNarne) DLM_ENTRY_NAME = dllentry DLM_RESL_NAME = fileresl DLM_OBJECT_FILES = $(dlrnObjs) DLM_NO_DLS = 1 # Used DLLEXPORT in .c file DLM_NO_DEF = 1 DLM_NOENTRY = 1 DLM_NO_SIGN = 1 DLM_LIBRARY_FILES = $(mdlLibs)dgnfileio.lib $ (mdlLibs) tool subs. lib $(mdlLibs)ditemlib.lib #------------------------------------------------ # Compile the source files for the DLM #------------------------------------------------ %include dlmcomp.mki
$(o)$(appName)$(oext): $(baseDir)$(appName) .cpp \ $(privateInc)$(appName).h \ $ (genSrc) $ (appName)cmd.h
#----------------------------------------------------------------------- # Merge Objects into one file # ~-------------- $(mdIApps)$(appName).ma : $(appRscs) $(msg) >$(0)make.opt -o$@ $(appRscs) < $(RLibCmd) @$(o)make.opt ~time
msdev %ms%\ustation.exe
__asm int 3;