Lab 3 - Creating a custom object
Our third Lab will cover custom objects. You will need to create a custom object, its properties, functions and Dictionary related methods.
* Class 1 to 12;
* AutoCAD 2004/2005/2006 or compatible vertical installed;
* Visual Studio .NET 2002 installed;
* ObjectARX Wizard installed.
The main idea is to create the first part of a complete custom shape application. This part consist of building the custom object which will represent the shape form with properties that allows you to completely define it.
The second step will be the custom entity which will refer to its associated shape. As several entities may use the same shape it is not a good idea to repeat the shape information inside each entity. Exactly due that we will create this custom object which will store de shape information and share this information with all custom entities related to it.
It will be an "I" shape with equal top and bottom flanges and it will need to store the following information:
-web height (d) - double;
-web thickness (tw) - double;
-flange width (bf) - double;
-flange thickness (tf) - double;
-shape name (desig) - CString;
- You will create two projects. The first, called ShapesUi (which will be the ObjectARX module) and the second called ShapesObj (which will be the ObjectDBX module) using ObjectARX Wizard;
- Enable Using MFC option in both projects;
- After created both projects, open the Autodesk View toolbar , select the ShapesObj project and create the custom object called ShapeObject;
- Override filling functions (dwgOutFields / dwgInFields);
- Implement all necessary properties to this object and provide is persistence through DWG filling functions;
- Create two functions. One to create the object and stored it inside NOD and other to list all existing objects. Use your custom Dictionary as ShapeApp;
- Use "*" as the key name of each shape inside ShapeApp Dictionary;
- Create a research function which will receive the shape information and will lookup an existing shape that matches with the information. If it is found, return it's ObjectId instead of create a duplicated shape. If it is not found, create a new shape and return its brand new ObjectId;
- Don't forget to create a == operator for your class to make easy to compare shapes when researching the Dictionary;
- Use the class 12 code fragment to help you with this project;
- Add properties using ARXWizard because it will create the access methods and will put the filling line at dwgInFields() and dwgOutFields() functions;
- Be careful about code flow inside Dictionary manipulation functions;
- Double check your open / close scopes;
- Test SAVE and OPEN the DWG to assert that the custom objects are successfully saved and loaded;
- Use ARXDBG to verify if your custom objects are placed into the right place;
- Use the ObjectARX documentation when necessary;
If you have any questions please post your issue on this article to share with others.
- I will give you 7 days to accomplish this Lab;
- After this period, I will post my suggested solution for this.