AutoCAD: intelligent objects Nikolay Poleshchuk IT specialist in JSC “Shipbuilding and Shiprepair Technology Center” (Saint Petersburg)

Download Report

Transcript AutoCAD: intelligent objects Nikolay Poleshchuk IT specialist in JSC “Shipbuilding and Shiprepair Technology Center” (Saint Petersburg)

AutoCAD: intelligent objects
Nikolay Poleshchuk
IT specialist in JSC “Shipbuilding and Shiprepair
Technology Center” (Saint Petersburg)
Design inside AutoCAD
Quality and speed of work in AutoCAD
environment depend very much from the
preliminary preparation of images of your design
branch objects (scheme elements, product nodes
etc.).
Demands to objects
Prepared objects can:
 contain necessary data (node number, material name, etc.)
 have certain flexibility (intelligence)
Common tools used
for objects preparation
 Usual blocks
 Dynamic blocks
Usual blocks
Usual blocks references:
 Can store data in attributes (or in extended data, dictionaries).
It is impossible to store data of variable length
 Do not have flexibility
Usual block examples
Images of the same type
Dynamic blocks
 Can store data
 Have certain flexibility
 Still are two-dimensional
Samples can be found in Tool Palettes of the latest AutoCAD
versions
Dynamic block example
Block with two-dimensional door image
Do you need more flexibility
and functionality?
User can create more interesting objects.
AutoCAD has a technology of “custom objects”. This
technology is being applied by Autodesk itself for inserting new
entities in AutoCAD and specialized vertical applications
(AutoCAD Architecture, AutoCAD Mechanical, etc.).
Custom objects
Custom objects can have geometry but may be with
no geometry too. The first case is the most
interesting one. These objects are called custom
entities.
Advantages
 Can contain data (inside of objects themselves)
 Various parts of the object can be drawn in
different manner (color, layer, linetype, etc.)
 Can be three-dimensional
 Can have changeable geometry
 Can have intelligence (operations permitted for the
objects)
Example 1 of unusual object
Element of non-flat union having form
of the Y letter, with grips at endpoints
Example 1 (continuation)
Sometimes the object should have more than two
exits. You need changeable geometry
Example 2
Similar to polyline but segments have different
colors
Example 3
• Part from flat sheet metal (like region) but user
must have possibility of editing it
What do you need
for custom objects creation?
 Knowledge of C++ programming language
 Class manipulation experience
 Microsoft Visual Studio package of corresponding
version and configuration
C++ experience
 Language knowledge (including classes handling
experience)
 Experience of work with ObjectARX libraries
 ADN (Autodesk Developer Network) membership
is welcome
Developer tools
 Microsoft Visual Studio or MS VC++,
configurations: Standard, Professional (Express
does not match)
 Autodesk ObjectARX libraries for corresponding
AutoCAD versions
Version matching
 AutoCAD 2007-2009 - Visual Studio 2005 SP1
 AutoCAD 2010-2012 - Visual Studio 2008 SP1
 AutoCAD 2013
- Visual Studio 2010 SP1
Developers
To start process of intelligent (custom) objects
building you need:
 Task planning – experienced user (designer)
 Applications developer – programmer
Application types
C++ applications in AutoCAD are DLL files with the
following extensions:
 dbx – custom object classes description
 arx – other applications (including those that work with custom
objects)
For example: myobj.dbx, myapp.arx
ObjectARX and Visual Studio
After installation of Autodesk ObjectARX package
onto MS Visual Studio there appear auxiliary tools
(Wizards) that facilitate creation of skeletons for
applications of certain type.
Next in my presentation there will be some
information useful for practical work.
Select project type
On Visual Studio 2010 basis: ObjectARX/DBX Project
ObjectARX Wizard (Page 1)
Page 1
ObjectARX Wizard (Page 2)
Page 2 (select ObjectDBX as project type)
Class of custom object
Classes are used to describe custom objects. Each
object type has its corresponding class.
 Sample class name: MyObj.
 Every entity in AutoCAD has its own class: AcDbLine,
AcDbArc, AcDbSpline, AcDbPolyline, etc.
Class creation Wizard
On Visual Studio 2010 basis: Project Add
class Custom Object Wizard
Custom Object Wizard (Page 1)
On page 1 of Wizard you should enter name of your
custom object class (e.g. MyObj) and name of the
parent class (usually AcDbEntity).
Inheritance
Inheritance process is used to create a new class.
The parent class can be:
 AcDbObject – for objects without graphics
 AcDbEntity – for objects with graphics
We are interested in the second case. More simple inheritance is
possible too (from AcDbLine, AcDbSpline, etc.).
Custom Object Wizard (Page 2)
On page 2 you should check all necessary boxes to
get protocol feature functions in class skeleton
Custom Object Wizard (Page 3)
On page 3 you can check additional properties
(skeletons of cloning functions and reactors)
MyObj.h
 The MyObj.h file that was created contains data
types, methods (functions).
 You may add here your data with types (int,
double, etc.). To store data with variable length
you can use dynamic arrays.
MyObj.cpp
The file contains function bodies. Presence of
advanced methods defines intelligence of the
object.
 Inheriting from the AcDbEntity class we get draft versions of
methods that exist for all the AutoCAD entities.
 You can develop these methods according to your wish.
 You can add your own methods to the class.
Read/write methods
Read/write methods are obligatory and play a very
important role:
 subDwgInFields, subDwgOutFields – read/write to DWG
 subDxfInFields, subDxfOutFields – read/write to DXF
It is very important to create subDwgInFields and
subDwgOutFields methods correctly.
Methods of graphics visualization
 subWorldDraw – graphics in model
 subViewportDraw – graphics in layout viewports
Here you can realize all the modes of your custom object display.
Graphics can change depending on data or settings.
Snap to object
Object snap functions work is defined in the
subGetOsnapPoints method.
Grips position and functionality
 The subGetGripPoints, subMoveGripPointsAt
methods are used.
 It is here where we describe functionality
(intelligence) of grips. Tooltips, menus, etc. can be
applied.
Grip form
You can apply your own form and color to grips. In
fact you create two-dimensional auxiliary custom
objects and define rules for drawing their contours.
Proxy objects
 Your custom objects will not work properly in the
drawing if you won’t load their definitions in DBX
files (custom object enablers).
 Proxy objects appear if enabler is missing.
 Enablers should be easily accessible (e.g. upload
them to web server).
Samples
Cylinder has axes whose number is changing while
editing radius with grip
Samples
• Training model of floating product with changeable
dimensions
Thank you for your attention!
[email protected]
http://poleshchuk.spb.ru/cad/eng.html
Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its
subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings,
and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2011 Autodesk, Inc. All rights reserved.