save command can't invoke dwgOutFields of custom object

save command can't invoke dwgOutFields of custom object

Anonymous
Not applicable
854 Views
4 Replies
Message 1 of 5

save command can't invoke dwgOutFields of custom object

Anonymous
Not applicable

in the arx sdk's examples ,there is one called "persreac_dg" in the folder of "samples\reactors".

I compiled it and run the command "ALINES", it works well and creates two lines and two reactors . I debuged the code, the first time I save the two lines into a dwg, I found the fuction "dwgOutFields " is invoked, then I closed this dwg and opened it again, I move one of the lines , then save the dwg again , but this time the fuction AsdkObjectToNotify::dwgOutFields is not invoked.

   I want the AsdkObjectToNotify::dwgOutFields to be invoked each time the dwg is closed, because I have added the some other info the AsdkObjectToNotify, and the info has been changed in the AsdkObjectToNotify::modified(const AcDbObject* pObj), so I want to save this extro  when the dwg is closed.

0 Likes
855 Views
4 Replies
Replies (4)
Message 2 of 5

owenwengerd
Advisor
Advisor

What exactly do you mean by "info has been changed"? You modified the object without calling assertWriteEnabled() to let AutoCAD know?

--
Owen Wengerd
ManuSoft
0 Likes
Message 3 of 5

artc2
Autodesk
Autodesk

It could be that you've got the Acad ISAVEPERCENT system variable set to something other than 0 (the default is 50), so that partial saves are enabled.  In that case,  if the AsdkObjectToNotify isn't modified, it won't be resaved.

Message 4 of 5

Anonymous
Not applicable

thanks for your reply, I set ISAVEPERCENT to 0, and it works.

 

I modified the sdk example, added some extra info,

 

    class CData
    {
    public:
        AcDbObjectIdArray idArr;
        Adesk::Int16 nVersion;
        AcGePoint2d pt2d;
    };

    class AsdkObjectToNotify : public AcDbObject
    {
    public:
        ACRX_DECLARE_MEMBERS(AsdkObjectToNotify);
        AsdkObjectToNotify();
        // 设置一些关联的属性
        void eLinkage(const AcDbObjectIdArray& idArr);
        void SetOldPos(const AcGePoint2d& pt2d);
        void              modified(const AcDbObject*);
        void modifiedGraphics(const AcDbEntity* dbEnt);
        Acad::ErrorStatus dwgInFields(AcDbDwgFiler*);
        Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
        Acad::ErrorStatus dxfInFields(AcDbDxfFiler*);
        Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
    private:
        boost::shared_ptr<CData> m_data;
    };

 

in void AsdkObjectToNotify::modified(const AcDbObject* pObj) , I changed the info in m_data, in this function(modified()), I cannot call "this->upgradeOpen();assertWriteEnabled();", this will crash.  but what should I do in function "AsdkObjectToNotify::modified" to let AutoCAD know this  sdkObjectToNotify object has been changed and should be saved?

0 Likes
Message 5 of 5

owenwengerd
Advisor
Advisor

You need to call assertWriteEnabled() before you modify any persistent object data. You can't do that from modified(). Depending on your requirements, updating your data in subClose() while the object is still open kForWrite may work for you.

--
Owen Wengerd
ManuSoft
0 Likes