Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Course Outline:
The first program in ObjectARX is the hardest. There are many pieces to get in place and several things that must be set up
properly in order to do the development work. The purpose of this lab is to provide a simple ObjectARX example program for you
to create and compile on the computers. The template file developed will enable you to use other templates supplied by Autodesk
and begin a path towards advanced programming of AutoCAD.
We will use two programs in this course. Please start the following as soon as you have selected your
workstation for the class.
AutoCAD
Microsoft Visual C++ 6
If either of these programs are not present on the computer you have selected please let the instructor or
lab assistant know before class starts.
These handouts contain screen component captures to enable you to keep up with the class and
to serve as a reminder of the steps involved. We are going to compile an existing C++ program
and perform each step on the computer. We will then read through the source code to understand
how it works and if time permits, do another example. The handouts make this look worse than it
really is.
You should already have Microsoft C++ 6.0 up and running on your computer. Each computer is
equipped with the ObjectARX tool kit (a set of C++ libraries for the creation of ARX programs) as
well as Microsoft C++ and AutoCAD.
Set Microsoft Visual C++ as the current window and start a new project. Click on
the File pull down menu and pick New... to present the New dialog box.
Select Win32 Dynamic-Link Library, and a custom project name "AU2001" in the
C:\CSOURCE\ location. C++ will create a new directory. If C:\CSOURCE\AU2001\ already
exists, then select a new name in the C:\CSOURCE\ folder.
Create an empty DLL project
Now we will add the files already on your hard disk to the project
You will have to repeat the process of adding files to the project to add both files.
To view the source code select the "File View" tab (lower left) and open the Source files
folder in the panel above the tabs. Then select the CPP file to see the source code of our
project (note code may appear different than presented in the following screen).
The first time a project is created, you must modify the default DLL creation settings for the
project.
4
We need to adjust a couple of things in the Project Settings. They are located under the
C/C++ tab on the right. Select the C/C++ tab and then select "Code Generation" from the
Category: pop up list.
In the code generation panel change the Use run-time library setting to "Multithreaded DLL".
5
The next stop is the Link panel entries where we need to change the name of the output file
name so that it has an ARX extension. By default it will be DLL.
Where we change the base address to be 0x1c000000 - this is a hex number, only the x and
c are letters. Everything else is a numeral.
In the Input settings of the Link panel we need to add a list of libraries. These are the
libraries that enable your program to communicate with AutoCAD.
6
The names to type in are:
The project is now ready, the next step is to prepare C++ to look for the ObjectARX files in
the ObjectARX folders. You will only do this once at your work station at home since these
values are retained from one project to the next.
Add the ObjectARX 2000 folder path to both the Include Files and Library files entries.
7
That's it! We are ready to build the program!
If we have time, let's do another one! This time use MCOPY2.CPP and call the project
"MCOPY".
9
EXPORTS
acrxEntryPoint PRIVATE
acrxGetApiVersion PRIVATE
10
RTPOINT, ptBase,
RTPOINT, ptBase,
0);
//
// Drag set on screen
iRet = acedDragGen(SS1,
"Copy location: ",
0, //flag for normal cursor
dragSet, //transform function
ptTo //result point
);
//
if (iRet == RTNORM)
{
acedCommand(RTSTR,"_MOVE",
RTPICKS, SS1,
RTSTR,"",
RTPOINT, ptBase,
RTPOINT, ptTo,
0
);
ptBase[0] = ptTo[0];
ptBase[1] = ptTo[1];
ptBase[2] = ptTo[2];
}else{
acedCommand(RTSTR,"_ERASE",
RTPICKS, SS1,
RTSTR,"",
RTSTR,"_REDRAW",
0
);
}
}
}
}
At the completion of this class, please delete the C:\CSOURCE folder from your computer.
Please remember to fill out the class evaluation form. I hope this helps get you started
along the road of using ObjectARX.
11