Author Topic: Enhanced Polyline Tutorial - Part 3 - Boiler Plate Code  (Read 2244 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Enhanced Polyline Tutorial - Part 3 - Boiler Plate Code
« on: April 10, 2009, 09:12:35 PM »
The enhanced polyline (EPline) will need 2 projects.  One project will be a standard ARX and
have entry points defined that can be run from the AutoCAD command line.  The new
commands are
  • EPlineSettings – Displays a dialog box allowing the offset and layer state settings to be changed.
  • EPline – Command used to add the custom entity to AutoCAD’s database.
  • ConvertEPline – Converts LWPolyline’s to EPline’s, and vice-versa.
  • TouchEPline – Updates offset and layer values to the current state in EPlineSettings.

The second project is actually a sub project of the first.  The compiled DLL from this project will
have a DBX extension and be responsible for reading, writing, displaying the custom entity.

Make sure the ObjectARX Wizard extension is installed for MSVS.  This will be used to
create the skeleton code need for both the ARX and DBX projects.

Create the First Project:
From MSVS create a new ObjectARX project.  This project will be called EPlineTut.  Make sure
the following items are selected in wizard dialog:  Application Type: ObjectARX; MFC Support:
Extension DLL and AutoCAD MFC Extension Support.  Turn off .Net mixed managed code
support.  All other options are optional, I’m going to leave them off.

Once the wizard is finished try and compile the project.  If it compiles great, if not you probably
need to add the ObjectARX include and library paths to the projects properties.  Go ahead and
do this for both Debug and Release.  Compile and fix any problem before proceeding.

Create The Second Project:
With the first project still open and active create a new project “File->New->Project”.  Select
ObjectARX/DBX/OMF Project template (same as the first project), and name it EPlineTutDb. 
For the Solution drop down select “Add to Solution”, this should automatically set the location
base directory to the first projects directory.
  Click OK.

Again the ObjectARX wizard dialog is displayed.  Select the following options: Application type:
ObjectDBX; MFC Support: No MFC Support.  Turn off .Net mixed managed code support.  All
other options are off.

In the MSVC solution explore pane right click the EPlineTutDb project to display the popup
window.  Click the build menu item and fix any errors.

Wizard Code
So far all the code is generated by the ObjectARX wizard and not much exciting is going on if
run in AutoCAD.  Still go ahead and test the ARX and DBX to make sure they are both loadable
without errors.

Automatically Load the Applications into AutoCAD
There are a number of methods to do this.  This simplest while developing your application is to
create an ACAD.RX file inside AutoCAD’s root direction.  Edit the file with Notepad or some
other text editor.  Each line in the file is an entry for an application to load into AutoCAD at
startup.  Mine looks like this
Code: [Select]
Now when F5 from MSVS is pressed AutoCAD and the 2 arx programs are loaded ready for
testing and debugging.

EPlineTut has MFC support turned on when that project was created.  When the application is
finished, EPlineSettings will display a dialog built using the MFC dialog box wizard.  There is also
a couple collection types we might need and MFC has some already built in.

Right clicking a project in MSVS Solution Explorer displays a popup window.  One useful item is
the “Set as startup project”.  Whichever project is set to startup gets the default focus for
compiling, debugging, project settings, etc.

This part of the tutorial is all boiler plate code generated by the ObjectARX wizard.  Under the
hood this code does a lot for you.  Take time to study it and lookup the functions and data types
in the ARX help docs.

In the next tutorial we’ll create the first implementation of the custom entity EPline.