Autodesk ObjectARX
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I understand that a single instance of this class is created for each autocad document created and that the purpose is to add to the CDocData class any "drawing" related information I may want to, but........ is this class automatically persisted by the document manager? If it isn't, than why not just used to NOD for document related data???
Any thoughts appreciated!
Mike B
Re: Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
CDocData is designed for non-persistent data.
Owen Wengerd
ManuSoft
Re: Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Man-o-man, for the life of me, I cannot think of a single piece of data used in a cad system that would not need to be persisted. Anyone have any good examples? ![]()
Thanks Owen
Mike
Re: Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The CDocData class is a class used to store your Document specific data.
What is document specific data? The best way to explain it is to show you some code and the results of running the code…
First, lets input an integer and have a static variable that offers a default value…
staticintdefaultValue = 0;
voidmyCmd()
{
TCHARprintBuffer[256];
_stprintf(printBuffer, _T("\nEnter value <%d> : "), defaultValue);
acedGetInt(printBuffer, &defaultValue);
}
If you load this code into AutoCAD and run it, it will first offer a default value of 0, and then offer any value you type in as the following default. If you create a new drawing, that default value is shown for each drawing.
Now to create some document specific data…
classCDocData {
public:
CDocData ()
{
defaultValue = 0;
};
CDocData (constCDocData &data)
{
defaultValue = data.defaultValue;
}
~CDocData () ;
intdefaultValue;
} ;
AcApDataManager<CDocData> DocVars ;
voidmyCmd()
{
TCHARprintBuffer[256];
_stprintf(printBuffer, _T("\nEnter value <%d> : "), DocVars.docData().defaultValue);
acedGetInt(printBuffer, &DocVars.docData().defaultValue);
}
If you load this code into AutoCAD and run it, it will first offer a default value of 0, and then offer any value you type in as the following default. However, this time, if you create a new drawing, you will be offered a 0 default and any value that you type in will be stored separately to any other document. Pretty cool.
As you can see this data is not persisted, and my example is very basic – where would this class really become useful? The answer is for document specific reactors, here’s an example..
classCDocData
{
public:
CDocData();
CDocData(constCDocData &data) ;
~CDocData();
asdkMyDatabaseReactor* m_pasdkMyDatabaseReactor;
};
//
// Implementation of the document data class.
//
CDocData::CDocData()
{
m_pasdkMyDatabaseReactor = NULL;
}
CDocData::CDocData(constCDocData &data)
{
m_pasdkMyDatabaseReactor = NULL;
}
CDocData::~CDocData()
{
if (m_pasdkMyDatabaseReactor) deletem_pasdkMyDatabaseReactor;
}
//
// setting up the reactor – now it is contained by the document data, don’t need to worry about it anymore
//
DocVars
.docData().m_pasdkMyDatabaseReactor = newasdkMyDatabaseReactor();
cuDoc()->database()->addReactor(DocVars.docData().m_pasdkMyDatabaseReactor);
Fenton Webb
Developer Technical Services
Autodesk Developer Network
Re: Purpose of DocData created by the wizard?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Didn't even think of database reactors.
Thanks for the clear explanation and example.
Mike B



