• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Contributor
    Posts: 16
    Registered: ‎12-04-2001

    Save data in the named object dictionary

    205 Views, 6 Replies
    11-19-2001 02:11 PM
    I want to save some private data in the named object dictionary when the database is closed. Then I have two questions:

    1. Where should I put the codes?
    I think the proper place should be AcDbDatabase::saveAs(), but how do I replace "AcDbHostApplicationServices()->workingDatabase()" with this overridden class? In fact, I tried AsdkDataManager::documentToBeDestroyed() created by the appwizard and OnkUnloadDwgMsg(). But how can I know if the user want to save the database or just close it without saving any data?

    2. In the two function mentioned above, the following code
    AcDbDictionary* pNamedobjDict;
    Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNamedobjDict, AcDb::kForWrite)
    return Acad::eWasOpenForRead, then I can not save any data to the dictionary. Even more, in "OnkUnloadDwgMsg()", CDocData (created by appwizard) is no longer valid, and the data it kept are inaccessible now.



    How can I do?
    Anyone help me?
    Please use plain text.
    Contributor
    Posts: 16
    Registered: ‎12-04-2001

    Re: Save data in the named object dictionary

    11-20-2001 09:42 AM in reply to: killerxia
    No one can answer this question? I'm a little disappointed.
    Maybe you're confused about the format of the paragraph, me too. In fact, before it's posted, it was devided into several paragraph, but after it's posted, the system(discusstion board) eliminated the carriage return, I don't know why.
    But, I still want to know how to solve this problem, can anyone give me a hand?
    Please use plain text.
    *ask

    Re: Save data in the named object dictionary

    11-20-2001 11:29 AM in reply to: killerxia
    1) You can write to the NOD whenever you please. If
    the user does not

    save the drawing - those changes won't be saved
    anyway. So, you don't

    have to worry about making changes and the user
    getting those if he does

    not save

    2) Are you sure you are not leaving the dictionary
    open for read somewhere yourself.


    style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
    I
    want to save some private data in the named object dictionary when the
    database is closed. Then I have two questions:

    1. Where should I put the codes?
       I think the proper
    place should be AcDbDatabase::saveAs(), but how do I replace
    "AcDbHostApplicationServices()->workingDatabase()" with this overridden
    class? In fact, I tried AsdkDataManager::documentToBeDestroyed() created by
    the appwizard and OnkUnloadDwgMsg(). But how can I know if the user want to
    save the database or just close it without saving any data?

    2. In the two function mentioned above, the following code

            AcDbDictionary*
    pNamedobjDict;
    Acad::ErrorStatus es =
    acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNamedobjDict,
    AcDb::kForWrite)
           return
    Acad::eWasOpenForRead, then I can not save any data to the dictionary. Even
    more, in "OnkUnloadDwgMsg()", CDocData (created by appwizard) is no longer
    valid, and the data it kept are inaccessible now.



    How can I do?
    Anyone help me?

    Please use plain text.
    Contributor
    Posts: 16
    Registered: ‎12-04-2001

    Re:

    11-20-2001 02:12 PM in reply to: killerxia
    Thank you for your reply! But:
    1. What's NOD? I've never heard of this, can you give me more detailed explaination?

    2. About the dictionary, now I know that if I just NEW a database, it will return eWasOpenForRead, but if I OPEN a database, it will return eOk. I'm quite sure that I've never made any modification on it.
    Please use plain text.
    *Müller, Andreas

    Re:

    12-22-2001 08:50 PM in reply to: killerxia
    >"killerxia" schrieb im Newsbeitrag
    news:f0993f1.2@WebX.maYIadrTaRb...
    >Thank you for your reply! But:
    >1. What's NOD? I've never heard of this, can you give me more detailed
    explaination?
    >2. About the dictionary, now I know that if I just NEW a database, it will
    return eWasOpenForRead, but if I OPEN a >database, it will return eOk. I'm
    quite sure that I've never made any modification on it.




    Hi,

    the NOD is the Named Object Dictionary. About question number 2: What are
    you doing? Are you working with AutoCAD, or a host application. I'm just
    asking, because I've never seen this aproach, exept when I want to open a
    database myself, which normally Acad does for me.

    O.K, here is an example of adding things to the NOD:
    //-------------------
    // Open the named object dictionary, check if there is
    // an entry with the key "ASDK_DICT". If not, create a
    // dictionary and add it.
    //
    AcDbDictionary *pNamedObj;
    AcDbDictionary *pNameList;

    // ... get the active Database
    AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();

    // ... get the NOD
    pDb->getNamedObjectsDictionary(pNamedObj, AcDb::kForWrite);

    // ... get the branch, you need
    if (pNamedObj->getAt("ASDK_DICT", (AcDbObject*&)pNameList,
    AcDb::kForWrite) == Acad::eKeyNotFound)
    {
    pNameList = new AcDbDictionary;
    AcDbObjectId DictId;
    pNamedObj->setAt("ASDK_DICT", pNameList, DictId);
    }
    pNamedObj->close();

    // ... Do someting with pNameList
    AsdkObjectToNotify *pObj = new SomeKindOfObject;

    // ... this will add the object into the NOD, in the ASDK_DICT branch
    // ... with the name "Name_of_the_entry"
    AcDbObjectId objId;
    if ((pNameList->getAt("Name_of_the_entry", objId))== Acad::eKeyNotFound)
    {
    pNameList->setAt("Name_of_the_entry", pObj, objId);
    pObj->close();
    }
    else
    {
    delete pObj;
    acutPrintf("object_to_notify_A already exists\n");
    }

    // ... never forget this:
    pNameList->close();
    //-------------------------------------------------

    This is taken from the "persreac" ARX sample, where an persisten Reactor is
    added to the NOD.

    I hope this helped you a bit, but it needs databases, that are in the
    "healthy" state. It is unsafe, or impossible to access a database e.g. from
    AcDbObject::dwgInFields(..).

    If you want to access a database in another context, like building you own
    db, I need to have more details, or even better some code pieces.

    Cheers,
    Andy
    Please use plain text.
    Contributor
    mihajlovic.milosh
    Posts: 11
    Registered: ‎11-07-2011

    Re: Save data in the named object dictionary

    04-10-2012 06:24 AM in reply to: killerxia

    Hello.

     

    I'm trying to define a reactor:

     

    class AcDbMyCustomObjectReactor : public AcDbObject {
    public:
    	ACRX_DECLARE_MEMBERS(AcDbMyCustomObjectReactor);
    	AcDbMyCustomObjectReactor() {};
    	void modified(const AcDbObject* dbObj) {
    		ads_printf(_T("123 :: Object was changed.\n"));
    		ads_name objName;
    		ErrorStatus err = acdbGetAdsName(objName, dbObj->objectId());
    		if (err != eOk)
    			return;
    		if (acdbEntUpd(objName) != RTNORM)
    			return;
    	}
    };

     

    and I keep getting this error:

     

    1>Insert.obj : error LNK2001: unresolved external symbol "public: virtual class AcRxClass * __thiscall AcDbMyCustomObjectReactor::isA(void)const " (?isA@AcDbMyCustomObjectReactor@@UBEPAVAcRxClass@@XZ)
    1>C:\Documents and Settings\Rajica\My Documents\Visual Studio 2005\Projects\CADCircle\Win32\Debug/123Shaft.arx : fatal error LNK1120: 1 unresolved externals

     

    could someone tell me what I might be doing wrong?

    Please use plain text.
    Contributor
    mihajlovic.milosh
    Posts: 11
    Registered: ‎11-07-2011

    Re: Save data in the named object dictionary

    04-10-2012 06:41 AM in reply to: mihajlovic.milosh

    Forget it, I solved it. It was something unrelated and stupid :smileyhappy:

    Please use plain text.