Home > Service & Support > Technical Tips > How to Start DRX Programming
 
  • • How to Start DRX Programming
  • Apr 15, 2008

How to Start DRX Programming

DRX function is similar to ARX of AutoCAD. In previous ZWCAD versions, DRX does not support custom objects. Now, in ZWCAD 2008i, we can create custom objects using DRX. That’s great! I used to be an ARX user of AutoCAD, and began using ZWCAD recently. I need to migrate my previous work built by ARX to ZWCAD using DRX, so it is really a good news for me. I am so excited that I would like to share my happiness with all users who are expecting better DRX function and those who seldom use DRX.

DRX is a useful tool for developing your own application. Maybe some users are not familiar with DRX, so I’d like to present a quick guide for everyone who wants to get a start to use DRX, and take the opportunity to express my excitement at the same time.

To create a DRX file, a compiler is required. Microsoft Visual C++. NET 2003 is introduced in this guide. The following is an example demonstrating the basic procedures needed to develop a DRX application that could be used in ZWCAD.

In this example, we are going to develop a simple application with the function below:

Type “hello” in the Command Line, then a prompt shows up: “I like the enhanced DRX of ZWCAD!”

 

Procedures:

1, Launch Microsoft Visual C++. NET 2003. From the Menu Bar, choose File >> New >> Project.

2, In the “New Project” dialogue box, choose Visual C++ Projects from the “Project Types” box and then MFC DLL from the “Templates” box. Specify a name, “example” here, and then the location, which points to

C:\Program Files\ZWCAD 2008i Eng\DRXSDK\sample\vc7.1

Click More, and check Create Directory for Solution check box.

Click OK.

3, A dialogue box “MFC DLL Wizard – example” will show. Choose Regular DLL using shared MFC DLL in “Application Settings” option, then click Finish.

4, Environment Settings

(1) From Menu Bar, choose Tools >> Options.

In the left frame, choose VC++ Directories under the folder Projects. Select Include files from the "Show Directories for" drop-down list, and add the paths that point to the folders which contain .h files and drxlib.drx of ZWCAD. Here in this example, add the following two paths:

C:\Program Files\ZWCAD 2008i Eng

(The folder where drxlib.drx is)

C:\Program Files\ZWCAD 2008i Eng\DRXSDK\inc

(The folder where .h files are)

Click OK.

(2) From Menu Bar, choose Project >> Properties. In the “example Propertiy Pages” dialogue box, select General under Linker, and then specify the paths for Output File:

C:\Program Files\ZWCAD 2008i Eng\DRXSDK\sample\vc7.1\example\example\debug\example.drx

(Note: It is important to name the output file name with extension .drx)

Click OK.

4, Edit the example.cpp file.

The follwing codes should be added in front of other codes in the file, so as to include the three .h files of ZWCAD.

#include "../../../../inc/drx.h"

#include "../../../../inc/inclib.h"

#include "../../../../inc/incEntry.h"

(Notes: “../” means returning to an upper level folder from the current folder where the source file is. The number of “../” should match actual cases. Take "../../../../inc/drx.h" for example, the system may chase upwards through four levels of folder and reach the folder DRXSDK, and then keep on searching downwards until it find the file drx.h)

The following is the main body of the file which enables the function of the application. This part should be placed at the end of the file, that is, after those originally existing template codes.

DRXLOAD("hello","example","drx_cmd_example",drx_cmd_example);

void drx_cmd_example()

{

    odre_prompt("\n I like the enhanced DRX of ZWCAD!");

}

(Notes: DRXLOAD is to load a function. “hello” is the command name, “example” is the command group name, and “drx_cmd_example” is the command function name. “void” is to define a function)

Save the file.

5, From the Menu Bar, choose “Build” >> “Build Solution”. Then the example.drx can be successfully built.

6, Run example.drx in ZWCAD

(1) Launch ZWCAD. Type “drx” in the Command Line, and then “L” after you see the prompt:

“Load/Unload/Command/Option:”

(2) Load example.drx in the “Load/Unload DRX” dialogue box, then click Close.

(3) In the Command Line, type “hello”, then we can see the prompt:

“I like the enhanced DRX of ZWCAD!”

  •  
  •  
  •  
 
 
86-20-38259726