Share
 
 

To Build Your First ObjectARX Application

Use the Autodesk template or the Cocoa template to build your first ObjectARX application.

Before you start building your ARX application, consider these essential requirements:
  • DBX module should be .framework type and have the .dbx file extension.
  • ARX module should be .bundle/.framework type and have the .bundle file extension.
  • ARX module works on 64-bit only.
You would require the following in your development environment:
  • AutoCAD for Mac: link symbols, debug and test your application
  • ObjectARX SDK: header files, configurations, samples, and templates

After installing the ObjectARX SDK, open the arxsdk/inc/prj_env.xcconfig file and check the paths of for the ObjectARX SDK and AutoCAD.

Creating "Hello World" From a Cocoa Bundle Project

  1. Start Xcode, create a Cocoa bundle project.
  2. Do the following setup configurations:
    1. Open the configuration, clean up the these items:
      • ARCHS
      • SDKROOT
      • ONLY_ACTIVE_ARCH
    2. Create a debug xconfig file.
      #include sdk/inc/prj_arx.xcconfig and prj_debug.xcconfig;
    3. Set the correct values for GCC_PREPROCESSOR_DEFINITIONS and OTHER_LDFLAGS.

      Add it to the project and set it as the debug configuration.

    4. Create a release xcconfig file.
      #include sdk/inc/prj_arx.xcconfig and prj_release.xcconfig;
    5. Set the correct values for GCC_PREPROCESSOR_DEFINITIONS and OTHER_LDFLAGS.

      Add it to the project and set it as the release configuration.

  3. Add the C++ source file. Follow these steps:
    1. Include these headers:winstubs.h,aced.h, and rxregsvc.h.
    2. Implement your command as shown:
      void mycmd()
      {
          acutPrintf(L"Hello world.");
      }
    3. Create the entry point and register your commands, as shown:
      #define COMMAND_GROUPNAME L"MYARX_COMMANDS"
      #define COMMAND_NAME L"mycmd"
      
      // All ARX apps must define this entry point
      extern "C" AcRx::AppRetCode
      acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
      {
          switch (msg)
          {
              case AcRx::kInitAppMsg:
                  acrxDynamicLinker->unlockApplication(pkt);
                  acrxRegisterAppMDIAware(pkt);
                  acedRegCmds->addCommand(COMMAND_GROUPNAME,
                                          COMMAND_NAME, COMMAND_NAME,
                                          ACRX_CMD_TRANSPARENT,
                                          &mycmd);
                  break;
              case AcRx::kUnloadAppMsg:
                  acedRegCmds->removeGroup(COMMAND_GROUPNAME);
                  break;
              default:
                  break;
          }
              return AcRx::kRetOK;
      }
  4. Build the project.
  5. Start AutoCAD and enter APPLOAD at the Command prompt. Browse to the ARX bundle and load it.
  6. At the Command prompt, enter mycmd and press Enter. The text "hello world" is displayed in the Command Line window.

Creating "Hello World" From a Cocoa Template

  1. Start Xcode, create a new "Arx with Cocoa" project using the Autodesk template.
  2. Build the project.
  3. Start AutoCAD and enter APPLOAD at the Command prompt. Browse to the ARX bundle and load it.
  4. At the Command prompt, enter mycmd and press Enter. The text "hello world" is displayed in the Command Line window.

Was this information helpful?