Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up an ObjectARX Development Environment Manually

Tech May 15 1

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

  1. Create a new Win32 Project in Visual Studio. Name it (e.g., ArxHello) and proceeed.
  2. 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

  1. Open the project properties (Project → Properties):
    • Under Configuration Properties → General, change Target Extension from .dll to .arx.
    • Navigate to VC++ Directories → Library Directories. Add the path to the lib-win32 folder inside your ObjectARX SDK installation.
    • Go to C/C++ → General → Additional Enclude Directories. Add both the inc and inc-win32 directories from the SDK. (For 64-bit builds, use inc-x64 instead.)
  2. Under C/C++ → Code Generation, set Runtime Library to Multi-threaded DLL (/MD).
  3. In Linker → Input → Additional Dependencies, add the following libraries: ``` rxapi.lib acdb18.lib acge18.lib acad.lib
    
    

Source Files

  1. Add two files to your project:
    • A Module-Definition File (.def) named ArxHello.def.
    • A C++ Source File (.cpp) named ArxHello.cpp.

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.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.