Cyrille Fauvel - Advanced Deepclone API in AutoCAD
Cyrille Fauvel - Advanced Deepclone API in AutoCAD
You learn
AutoCAD deepClone API and cloning techniques
Benchmarks, performance and implementation considerations
Aspects of controlling cloning operations in AutoCAD
We do not discuss and assume knowledge of
How to program in .NET or ObjectARX
The basics of the AutoCAD .Net or ObjectARX API
AutoCAD product usage
About the Presenter
Cyrille Fauvel
Autodesk Developer Network
Cyrille is a member of the M&E workgroup of the Autodesk Developer Network (ADN)
team, providing developer support, training, and conference presentations on
AutoCAD, RealDWG, Inventor, Maya, 3ds Max, FBX API.
www.autodesk.com/joinadn
Agenda
Overview
1 Cloning! What is it?
Why should I care?
Basics
2 Shallow Clone, deep Clone & wblock Clone
Who is using cloning?
API
3 Cloning and ID Translations
ObjectARX or .Net?
A concrete example
4
Modify the default AutoCAD behavior
Additional information
5
Inspect, spy, learning more
Overview
Shallow Cloning
Copy of a singleton ObjectARX C++ object
AcRxObject::clone()
RTTI and C++ object copy
copyFrom() to copy properties
Deep Cloning
clones an object and its hard/soft ownership references
but do not clone hard/soft pointer referenced objects
however, copies the pointer reference values
Wblock Cloning
clones an object and its hard owner and hard pointer references
but ignores any soft references
and reset non cloned references to null
First user is AutoCAD
4 types
Combination of [ Hard or Soft ] and [ Ownership or Pointer ]
Hard
Reference required for the object to survive in a database
Soft
Reference not required (can be ignored depending of the context)
Ownership
Parent – Child relation ship
Pointer
Cooperative object the object is referencing for its definition
References
ObjectARX
AcDbHardOwnershipId
AcDbSoftOwnershipId
AcDbHardPointerId
AcDbSoftPointerId
.Net
ObjectId
Hard Owner
Soft Owner
Hard Pointer
Soft Pointer
Entity ownership
Hard Owner
Soft Owner
Hard Pointer
Soft Pointer
Can we get things more complicated?
Entities are objects
Hard Owner
Soft Owner
Hard Pointer
Soft Pointer
A DWG database
Hard Owner
Soft Owner
Hard Pointer
Soft Pointer
Extension dictionary
Instead use
Within the same database
AcDbDatabase::deepCloneObjects()
Across databases
AcDbDatabase::wblockCloneObjects()
AcDbDatabase::wblock()
AcDbDatabase::insert()
API
Acad::ErrorStatus wblock(AcDbDatabase*&);
Acad::ErrorStatus wblock(AcDbDatabase*&, AcDbObjectId);
Acad::ErrorStatus wblock(AcDbDatabase*&, const AcDbObjectIdArray&, const AcGePoint3d&);
Acad::ErrorStatus wblock AcDbDatabase*, const AcDbObjectIdArray&, const AcGePoint3d&,
AcDb::DuplicateRecordCloning);
Acad::ErrorStatus wblockCloneObjects(AcDbObjectIdArray&, AcDbObjectId&, AcDbIdMapping&,
AcDb::DuplicateRecordCloning, bool);
AcRxEventReactor / AcEditorReactor
Autodesk.AutoCAD.DatabaseServices.Database
ObjectARX and .Net
void beginDeepClone(AcDbDatabase*, AcDbIdMapping&);
void beginWblockObjects(AcDbDatabase*, AcDbIdMapping&);
void beginInsert(AcDbDatabase*, const AcGeMatrix3d&, AcDbDatabase*);
void beginInsert(AcDbDatabase*, const ACHAR *, AcDbDatabase*);
void beginWblock(AcDbDatabase*, AcDbDatabase*);
void beginWblock(AcDbDatabase*, AcDbDatabase*, AcDbObjectId);
void beginWblock(AcDbDatabase*, AcDbDatabase*, const AcGePoint3d*&);
void wblockNotice(AcDbDatabase*);
void otherInsert(AcDbDatabase*, AcDbIdMapping&, AcDbDatabase*);
void otherWblock(AcDbDatabase*, AcDbIdMapping&, AcDbDatabase*);
void beginDeepCloneXlation(AcDbIdMapping&, Acad::ErrorStatus*);
void endDeepClone(AcDbIdMapping&);
void endWblock(AcDbDatabase*);
void abortDeepClone(AcDbIdMapping&);
void abortWblock(AcDbDatabase*);
void abortInsert(AcDbDatabase*);
Acad::ErrorStatus veto();
RefEdit
ObjectARX Only
AcDbObject
Autodesk.AutoCAD.DatabaseServices.DBObject
.Net implements these method, but you cannot override them
You can call them in a cloning context/operation
API Sealed in ARX now
Acad::ErrorStatus deepClone(AcDbObject*, AcDbObject*&, AcDbIdMapping&,
Adesk::Boolean) const;
Acad::ErrorStatus wblockClone(AcRxObject*, AcDbObject*&, AcDbIdMapping&,
Adesk::Boolean) const;
Use the subXXX() version instead
Acad::ErrorStatus subDeepClone(AcDbObject*, AcDbObject*&, AcDbIdMapping&,
Adesk::Boolean) const;
Acad::ErrorStatus subWblockClone(AcRxObject*, AcDbObject*&, AcDbIdMapping&,
Adesk::Boolean) const;
Overrule API
Can ‘modify’
Draw aspect,
Grips,
PropertiesOverrule
DrawableOverrule
OsnapOverrule
TransformOverrule
GripOverrule
SubentityOverrule
HighlightOverrule
GeometryOverrule
ObjectOverrule
Overrule API
AcDbObjectOverrule
Acad::ErrorStatus deepClone(const AcDbObject*, AcDbObject*, AcDbObject*&,
AcDbIdMapping&, Adesk::Boolean);
Acad::ErrorStatus wblockClone(const AcDbObject*, AcRxObject*, AcDbObject*&,
AcDbIdMapping&, Adesk::Boolean);
Autodesk.AutoCAD.DatabaseServices.ObjectOverrule
DBObject DeepClone(DBObject, DBObject, IdMapping, [MarshalAs(UnmanagedType.U1)] bool);
DBObject WblockClone(DBObject, RXObject, IdMapping, [MarshalAs(UnmanagedType.U1)] bool);
A concrete example
CLONE1 command
Performs a shallow clone of a non-database resident object.
CLONE2 command
Performs a shallow clone of a database resident object into the same
database
CLONE3 command
Performs a shallow clone of a database resident object to another
DWG database
OPLine1
Custom entity derived from AcDbPolyline
And a companion custom object derived from AcDdBObject stored in
the NOD
OPLine2
Try to replicate the above structure without custom object but using
reactors instead
OPLine3
Same but using the new overrule API
Additional information
Handout
AU10_CP220-3C_ARX_Cloning_2011_API.docx
Presentation
AU10_CP220-3C_ARX_Cloning_2011_API.pptx
[email protected]
Autodesk [and other] 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
ght 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
All rights reserved.
Hard Owner
Soft Owner
Hard Pointer
Soft Pointer