ObjectARX

ObjectARX

Reply
Valued Contributor
mbujak
Posts: 53
Registered: ‎07-07-2004
Message 1 of 6 (219 Views)

Purpose of DocData created by the wizard?

219 Views, 5 Replies
03-30-2012 11:31 AM

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 

Distinguished Mentor
owenwengerd
Posts: 686
Registered: ‎08-06-2002
Message 2 of 6 (217 Views)

Re: Purpose of DocData created by the wizard?

03-30-2012 11:59 AM in reply to: mbujak

CDocData is designed for non-persistent data.

--
Owen Wengerd
ManuSoft
Valued Contributor
mbujak
Posts: 53
Registered: ‎07-07-2004
Message 3 of 6 (213 Views)

Re: Purpose of DocData created by the wizard?

03-30-2012 12:27 PM in reply to: owenwengerd

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? :smileyvery-happy:

 

Thanks Owen

 

Mike

Moderator
Alexander.Rivilis
Posts: 1,458
Registered: ‎04-09-2008
Message 4 of 6 (194 Views)

Re: Purpose of DocData created by the wizard?

03-31-2012 09:50 AM in reply to: mbujak

mbujak wrote:

Anyone have any good examples?


Per-document data. Such as pointer to database reactor (class AcDbDatabaseReactor)  to document database.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 5 of 6 (169 Views)

Re: Purpose of DocData created by the wizard?

04-09-2012 02:33 PM in reply to: Alexander.Rivilis

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


Valued Contributor
mbujak
Posts: 53
Registered: ‎07-07-2004
Message 6 of 6 (152 Views)

Re: Purpose of DocData created by the wizard?

04-10-2012 05:18 AM in reply to: fenton.webb

Didn't even think of database reactors.

 

Thanks for the clear explanation and example.

 

Mike B

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.