Developing BabaCAD Extension Modules


Currently (2014), there is no free CAD software with customization option, with exception of BabaCAD. Developers can extend BabaCAD with runtime extension modules (BEM). BEM modules are simply dll's that BabaCAD loads in runtime and executes custom commands and functions. To start programming these Add-On modules for BabaCAD, you need to have Microsoft Visual Studio 2010 and also you need some knowledge of c++.
I will here give an example of custom application (BabaCAD BEM Add-On module) that allows you to draw slope lines, one of the important features in civil design. We will define two additional (custom) commands: SLOPE and SLOPESET. Also to help other users to start using add-on easy, we will also create new toolbar with two icons for new commands. Command slope lines toolbar


1. Start Visual Studio and create a new MFC DLL project "CivilTools" in c++ templates.
2. Open Project properties and change output extension from .dll to .bem
3. Add declarations of Slope, SlopeSet, CivilTools functions and also default entry point function for BabaCAD extension (file CivilTools.h):

#include "resource.h" // main symbols

extern "C"
{
BOOL __declspec(dllexport) BabaCADExtEntryPoint(TCHAR &defaultCmdSymbol, TCHAR &getVarSymbol);
BOOL __declspec(dllexport) Slope(int &CmdSeq);
BOOL __declspec(dllexport) SlopeSet(int &CmdSeq);
BOOL __declspec(dllexport) CivilTools(int &CmdSeq);
}

4. Open CivilTools.cpp, add BabaCAD extension header and lib, add entry-point function and command functions:

#include "stdafx.h"
#include "\Program Files (x86)\BabaCAD\BabaCAD\API\Inc\BabaCADExtensions.h"
#include "CivilTools.h"

#import "\Program Files (x86)\BabaCAD\BabaCAD\API\Lib\BabaCAD.lib" no_namespace

BOOL BabaCADExtEntryPoint(TCHAR &defaultCmdSymbol, TCHAR &getVarSymbol)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

AddCommand(_T("Slope"),L"",_T("Terrain slope lines"),_T("CivilTools.bem"), m_hInstDLL, ID_SLOPE);
AddCommand(_T("SlopeSet"),L"",_T("Configure slope lines"),_T("CivilTools.bem"),m_hInstDLL ,ID_SLOPESET);
AddCommand(_T("CivilTools"),L"",_T("Civil Tools"),_T("CivilTools.bem"),m_hInstDLL);

return TRUE;
}

Add implementation of slope, slopeset and civiltools functions...
(download zip file - full VS2010 c++ project: CivilTools.zip)

5. Compile and copy civiltools.bem to \Program Files (x86)\BabaCAD\BabaCAD\ExtensionModules\
6. Start BabaCAD and type SLOPE in command window to draw slope lines. Type command CIVILTOOLS to show custom toolbar for new commands SLOPE and SLOPESET (use slopeset command to change long/short lines ratio).











Legal Stuff
Trademarks: BabaCAD and BabaCAD Extension Modules are trademarks of Mirza Coralic. Other product names mentioned here are trademarks of their respective owners