| 
 | 
沙发
 
 
 楼主 |
发表于 2025-5-18 20:35:39
|
只看该作者
 
 
 
请 
- //自定义对象.cpp
 
 - #include "stdafx.h"
 
 - #include "自定义对象.h"
 
 - #define VERSION_ZFFDWGSCALE 1
 
  
- ACRX_DXF_DEFINE_MEMBERS(自定义对象, AcDbObject,
 
 -         AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
 
 -         AcDbProxyObject::kNoOperation,
 
 -         ZFFDWGSCALE, ZffCustomObjectDB);
 
  
- 自定义对象::自定义对象()
 
 - {
 
 -         //{{AFX_ARX_DATA_INIT(ZffDwgScale)
 
 -         //}}AFX_ARX_DATA_INIT
 
  
-         m_infoScale = 0;
 
 -         m_lableScale = 0;
 
 - }
 
  
- 自定义对象::~自定义对象()
 
 - {
 
 -         // TODO: clean up.
 
  
- }
 
  
 
- Acad::ErrorStatus 自定义对象::dwgInFields(AcDbDwgFiler* pFiler)
 
 - {
 
 -         assertWriteEnabled();
 
 -         Acad::ErrorStatus es;
 
  
-         // Call dwgInFields from AcDbObject
 
 -         if ((es = AcDbObject::dwgInFields(pFiler)) != Acad::eOk) {
 
 -                 return es;
 
 -         }
 
  
-         // Read version number.
 
 -         Adesk::UInt16 version;
 
 -         pFiler->readItem(&version);
 
 -         if (version > VERSION_ZFFDWGSCALE)
 
 -                 return Acad::eMakeMeProxy;
 
  
-         // Read the data members.
 
 -         switch (version)
 
 -         {
 
 -         case (1):
 
 -                 // TODO: here you can file datamembers not
 
 -                 //       created by the ObjectARX Add-In.
 
 -                 pFiler->readItem(&m_infoScale);
 
 -                 pFiler->readItem(&m_lableScale);
 
  
-                 break;
 
 -         }
 
  
 
-         return pFiler->filerStatus();
 
 - }
 
  
- Acad::ErrorStatus 自定义对象::dwgOutFields(AcDbDwgFiler* pFiler) const
 
 - {
 
 -         assertReadEnabled();
 
 -         Acad::ErrorStatus es;
 
  
-         // Call dwgOutFields from AcDbObject
 
 -         if ((es = AcDbObject::dwgOutFields(pFiler)) != Acad::eOk) {
 
 -                 return es;
 
 -         }
 
  
-         // Write version number.
 
 -         pFiler->writeItem((Adesk::UInt16)VERSION_ZFFDWGSCALE);
 
  
-         // Write the data members.
 
 -         // TODO: here you can file datamembers not
 
 -         //       created by the ObjectARX Add-In.
 
 -         pFiler->writeItem(m_infoScale);
 
 -         pFiler->writeItem(m_lableScale);
 
  
-         return pFiler->filerStatus();
 
 - }
 
  
- Acad::ErrorStatus 自定义对象::dxfInFields(AcDbDxfFiler* pFiler)
 
 - {
 
 -         assertWriteEnabled();
 
 -         struct resbuf rb;
 
  
-         if ((AcDbObject::dxfInFields(pFiler) != Acad::eOk) ||
 
 -                 !pFiler->atSubclassData(L"ZffDwgScale"))
 
 -                 return pFiler->filerStatus();
 
  
-         // Read version number.
 
 -         pFiler->readItem(&rb);
 
 -         if (rb.restype != AcDb::kDxfInt16) {
 
 -                 pFiler->pushBackItem();
 
 -                 pFiler->setError(Acad::eInvalidDxfCode,
 
 -                         L"nError: expected object version group code %d",
 
 -                         AcDb::kDxfInt16);
 
 -                 return pFiler->filerStatus();
 
 -         }
 
 -         else {
 
 -                 Adesk::UInt16 version = rb.resval.rint;
 
 -                 if (version > VERSION_ZFFDWGSCALE)
 
 -                         return Acad::eMakeMeProxy;
 
 -         }
 
  
-         // 读取条件图比例
 
 -         pFiler->readItem(&rb);
 
 -         if (rb.restype != AcDb::kDxfInt32)
 
 -         {
 
 -                 pFiler->pushBackItem();
 
 -                 pFiler->setError(Acad::eInvalidDxfCode,
 
 -                         L"nError: expected object version group code %d",
 
 -                         AcDb::kDxfInt32);
 
 -                 return pFiler->filerStatus();
 
 -         }
 
 -         else
 
 -         {
 
 -                 m_infoScale = rb.resval.rlong;
 
 -         }
 
  
-         // 读取出图比例
 
 -         pFiler->readItem(&rb);
 
 -         if (rb.restype != AcDb::kDxfInt32)
 
 -         {
 
 -                 pFiler->pushBackItem();
 
 -                 pFiler->setError(Acad::eInvalidDxfCode,
 
 -                         L"nError: expected object version group code %d",
 
 -                         AcDb::kDxfInt32);
 
 -                 return pFiler->filerStatus();
 
 -         }
 
 -         else
 
 -         {
 
 -                 m_lableScale = rb.resval.rlong;
 
 -         }
 
  
-         return pFiler->filerStatus();
 
 - }
 
  
- Acad::ErrorStatus 自定义对象::dxfOutFields(AcDbDxfFiler* pFiler) const
 
 - {
 
 -         assertReadEnabled();
 
 -         Acad::ErrorStatus es;
 
  
-         if ((es = AcDbObject::dxfOutFields(pFiler)) != Acad::eOk)
 
 -                 return es;
 
  
-         // Write subclass marker.
 
 -         pFiler->writeItem(AcDb::kDxfSubclass, "ZffDwgScale");
 
  
-         // Write version number.
 
 -         pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16)VERSION_ZFFDWGSCALE);
 
  
-         // 写入两个成员变量
 
 -         pFiler->writeItem(AcDb::kDxfInt32, m_infoScale);
 
 -         pFiler->writeItem(AcDb::kDxfInt32, m_lableScale);
 
  
-         return es;
 
 - }
 
  
- void 自定义对象::Set(int infoScale, int lableScale)
 
 - {
 
 -         assertWriteEnabled();
 
  
-         m_infoScale = infoScale;
 
 -         m_lableScale = lableScale;
 
 - }
 
  
- int 自定义对象::GetInfoScale() const
 
 - {
 
 -         assertReadEnabled();
 
  
-         return m_infoScale;
 
 - }
 
  
- int 自定义对象::GetLabelScale() const
 
 - {
 
 -         AcDbObject* dx;
 
 -         dx->dxfOutFields(a);
 
 -         assertReadEnabled();
 
  
-         return m_lableScale;
 
 - }
 
  
 
  复制代码 
 
 |   
 
 
 
 |