Setting Up an ObjectARX Development Environment Manually
This guide demonstrates how to configure a development enviroment for ObjectARX using Visual Studio 2010 and AutoCAD 2012. The same general approach applies to newer versions of AutoCAD with minor adjustments.
Prerequisites
Ensure you have the following installed:
- Visual Studio 2010 (or compatible version)
- AutoCAD 2012 (or target version)
- ObjectARX SDK matching your AutoCAD version (e.g., ObjectARX SDK 2012)
Project Setup
- Create a new Win32 Project in Visual Studio. Name it (e.g.,
ArxHello) and proceeed. - In the Application Wizard:
- Click Next on the first screen.
- On the second screen, select DLL as the application type and check Empty project.
- Click Finish.
Project Configuration
- Open the project properties (Project → Properties):
- Under Configuration Properties → General, change Target Extension from
.dllto.arx. - Navigate to VC++ Directories → Library Directories. Add the path to the
lib-win32folder inside your ObjectARX SDK installation. - Go to C/C++ → General → Additional Enclude Directories. Add both the
incandinc-win32directories from the SDK. (For 64-bit builds, useinc-x64instead.)
- Under Configuration Properties → General, change Target Extension from
- Under C/C++ → Code Generation, set Runtime Library to Multi-threaded DLL (/MD).
- In Linker → Input → Additional Dependencies, add the following libraries: ```
rxapi.lib
acdb18.lib
acge18.lib
acad.lib
Source Files
- Add two files to your project:
- A Module-Definition File (.def) named
ArxHello.def. - A C++ Source File (.cpp) named
ArxHello.cpp.
- A Module-Definition File (.def) named
Place the following code in ArxHello.cpp:
#include <rxregsvc.h>
#include <aced.h>
void registerCommands();
void unregisterCommands();
void helloCommand();
void registerCommands()
{
acedRegCmds->addCommand(
L"HELLO_GROUP",
L"HELLO",
L"SayHello",
ACRX_CMD_TRANSPARENT,
helloCommand);
}
void unregisterCommands()
{
acedRegCmds->removeGroup(L"HELLO_GROUP");
}
void helloCommand()
{
acutPrintf(L"\nHello, ObjectARX!\n");
}
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
registerCommands();
break;
case AcRx::kUnloadAppMsg:
unregisterCommands();
break;
}
return AcRx::kRetOK;
}
And place this content in ArxHello.def:
LIBRARY ArxHello
EXPORTS
acrxEntryPoint PRIVATE
acrxGetApiVersion PRIVATE
Build the project (F6). If configured correctly, it should compile without errors.
To test, launch AutoCAD 2012, type ARX at the command line, then use the L option to load your compiled .arx file. Once loaded, enter the HELLO command to see the output.