Tuesday, June 07, 2005

The First ObjectARX for Dummies Contest will be officially opened on next Friday (June 10th). By now everyone may download the contest rules here. Please fill this rules form and return to me from June 10th until June 25th.

For those who not have an AutoCAD 2006 version to build and test their samples I would suggest you to download a 30 day evaluation copy of AutoCAD or use one from a friend or your company's computer.

Be creative and explore the new AutoCAD 2006 features!

To be fare with everyone I will limit all support questions to basic features to avoid give any privilege to any contest user.

The winners will be judged by me, Shaan Hurley (from Autodesk) and Lynn Allen (from Autodesk).

Saturday, June 04, 2005

On this class I will complete the Class 13 with a tutorial to show you how to create a simple custom entity step by step. This entity has some features that will help you to see what is possible to do using ObjectARX. Please read carefully the following instructions.

-Create a Blank Solution called CustomEntitySample;
-Add a new DBX project called CustEntityDBX;
-Add a new ARX project called CustEntityARX;
-Remember to enable MFC Extension on both projects;
-Create a dependency from ARX project to DBX:

-Choose MyCustomEntity as class name and derive it from AcDbEntity;
-Other fields will be filled automatically (you may change these values);

-Go to the Protocols TAB and enable both Osnap and Grip-points protocols:

-Rebuild your project to see if everything is ok;
-Now, open again the Autodesk Class Explorer, go to CustEntityDBX project;
-Select the MyCustomEntity node (if it is not there, click on Refresh icon);
-Right click on it and select "Add Variable...":

-Name it as "m_PtA", type will be an AcGePoint3d and its access will be protected;
-Enable "Participate to DWG filing protocol", disable "Increase Version number";
-Enable "Implement Get/Put methods" and fill desired comments for it;
-Repeat the process and create : "m_PtB", "m_PtAB" and "m_PtBA":

-Now, add a CString variable called "m_Text";
-Remember to correct the CString manipulation and filing as we have done in Lab3;
-Now you should compile your code ok;

Before continue, we will need to remove some functions that we will not use. First remove the following from .H file:

-Open remaining getGripPoints() method inside MyCustomEntity implementation (cpp);
-We would like to enable 5 grips for this entity. One at each point (A,B,AB and BA) plus one at the center;
-Inside the getGripPoints(), add the following code:

gripPoints.append(m_PtA);gripPoints.append(m_PtAB);gripPoints.append(m_PtB);gripPoints.append(m_PtBA);gripPoints.append(AcGePoint3d((m_PtB.x+m_PtA.x)/2.0,(m_PtB.y+m_PtA.y)/2.0,m_PtA.z));
-Now, when user clicks on each Grip we would like to perform an action. This is done using the moveGripPointsAt() method;
-We need to check the index of each fired grip accordingly to the getGripPoints() method and then apply the transformation;
-Inside remaining moveGripPointsAt() method, add the following code:

-Right click on this method and select "Implement Base Class Method";
-This function logic is very simple, just add the following code:

assertWriteEnabled();m_PtA.transformBy(xform);m_PtAB.transformBy(xform);m_PtB.transformBy(xform);m_PtBA.transformBy(xform);return (Acad::eOk);
-This function will allow the custom entity to be transformed;

ARX PROJECT

-First we will need to add a new command called "MyCustEnt";
-This will create a method inside acxrEntryPoint.cpp file;
-Now, add the necessary include instruction after the #include "StdAfx.h":

#include "..\CustEntityDBX\MyCustomEntity.h"
-Inside the method we will create our entity:

-Rebuild your project;
-Open AutoCAD and load DBX module first and then load the ARX;
-Fire command MYCUSTENT and create as many entities as you want;
-Test it against GRIP edit, MOVE, ROTATE, SCALE;
-Fire a LINE command and try to get precision points (EndPoint, MidPoint and Center) over your entities;