Acad::ErrorStatus DbValve::dxfInFields (AcDbDxfFiler *pFiler) { assertWriteEnabled () ; //----- Read parent class information first. Acad::ErrorStatus es =AcDbPolyline::dxfInFields (pFiler) ; if ( es != Acad::eOk || !pFiler->atSubclassData (_RXST("DbValve")) ) return (pFiler->filerStatus ()) ; //----- Object version number needs to be read first struct resbuf rb ; pFiler->readItem (&rb) ; if ( rb.restype != AcDb::kDxfInt32 ) { pFiler->pushBackItem () ; pFiler->setError (Acad::eInvalidDxfCode, _RXST("\nError: expected group code %d (version #)"), AcDb::kDxfInt32) ; return (pFiler->filerStatus ()) ; } Adesk::UInt32 version =(Adesk::UInt32)rb.resval.rlong ; if ( version > DbValve::kCurrentVersionNumber ) return (Acad::eMakeMeProxy) ; //- Uncomment the 2 following lines if your current object implementation cannot //- support previous version of that object. //if ( version < DbValve::kCurrentVersionNumber ) // return (Acad::eMakeMeProxy) ; //----- Read params in non order dependant manner while ( es == Acad::eOk && (es =pFiler->readResBuf (&rb)) == Acad::eOk ) { switch ( rb.restype ) { //----- Read params by looking at their DXF code (example below) //case AcDb::kDxfXCoord: // if ( version == 1 ) // cen3d =asPnt3d (rb.resval.rpoint) ; // else // cen2d =asPnt2d (rb.resval.rpoint) ; // break ; //..... case AcDb::kDxfXCoord: DbValve::m_center = asPnt2d (rb.resval.rpoint); break; case AcDb::kDxfInt16: DbValve::m_index = (Adesk::Int16)rb.resval.rint ; default: //----- An unrecognized group. Push it back so that the subclass can read it again. pFiler->pushBackItem () ; es =Acad::eEndOfFile ; break ; } } //----- At this point the es variable must contain eEndOfFile //----- - either from readResBuf() or from pushback. If not, //----- it indicates that an error happened and we should //----- return immediately. if ( es != Acad::eEndOfFile ) return (Acad::eInvalidResBuf) ; return (pFiler->filerStatus ()) ; }
Acad::ErrorStatus CPipeAttribute::dxfInFields (AcDbDxfFiler *pFiler) { assertWriteEnabled () ; //----- Read parent class information first. Acad::ErrorStatus es =AcDbObject::dxfInFields (pFiler) ; if ( es != Acad::eOk || !pFiler->atSubclassData (_RXST("CPipeAttribute")) ) return (pFiler->filerStatus ()) ; //----- Object version number needs to be read first struct resbuf rb ; pFiler->readItem (&rb) ; if ( rb.restype != AcDb::kDxfInt32 ) { pFiler->pushBackItem () ; pFiler->setError (Acad::eInvalidDxfCode, _RXST("\nError: expected group code %d (version #)"), AcDb::kDxfInt32) ; return (pFiler->filerStatus ()) ; } Adesk::UInt32 version =(Adesk::UInt32)rb.resval.rlong ; if ( version > CPipeAttribute::kCurrentVersionNumber ) return (Acad::eMakeMeProxy) ; while ( es == Acad::eOk && (es =pFiler->readResBuf (&rb)) == Acad::eOk ) { switch ( rb.restype ) { // 从DXF中读取数据 case AcDb::kDxfReal: m_dRadius =rb.resval.rreal ; break ; case AcDb::kDxfReal+1: m_dThickness =rb.resval.rreal ; break ; case AcDb::kDxfReal+2: m_dDeep =rb.resval.rreal ; break ; case AcDb::kDxfText: _tcscpy(m_cMaterial,rb.resval.rstring); break ; default: // pFiler->pushBackItem () ; es =Acad::eEndOfFile ; break ; } } if ( es != Acad::eEndOfFile ) return (Acad::eInvalidResBuf) ; return (pFiler->filerStatus ()) ; }
virtual void RegisterServerComponents () { //----- Self-register COM server upon loading. #ifdef _DEBUG ::DllUnregisterServer () ; #endif if ( FAILED(::DllRegisterServer ()) ) acutPrintf (_RXST("Failed to register COM server.\n")) ; }
//- Dxf Filing protocol Acad::ErrorStatus DbValve::dxfOutFields (AcDbDxfFiler *pFiler) const { assertReadEnabled () ; //----- Save parent class information first. Acad::ErrorStatus es =AcDbPolyline::dxfOutFields (pFiler) ; if ( es != Acad::eOk ) return (es) ; es =pFiler->writeItem (AcDb::kDxfSubclass, _RXST("DbValve")) ; if ( es != Acad::eOk ) return (es) ; //----- Object version number needs to be saved first if ( (es =pFiler->writeUInt32 (kDxfInt32, DbValve::kCurrentVersionNumber)) != Acad::eOk ) return (es) ; //----- Output params //..... if ( (es =pFiler->writePoint2d(kDxfXCoord, DbValve::m_center)) != Acad::eOk ) return (es); if ( (es =pFiler->writeInt16(kDxfInt16, DbValve::m_index)) != Acad::eOk ) return (es); return (pFiler->filerStatus ()) ; }
//- Dxf Filing protocol Acad::ErrorStatus CPipeAttribute::dxfOutFields (AcDbDxfFiler *pFiler) const { // 检查对象处于正确的打开状态 assertReadEnabled () ; //父类数据的重载 Acad::ErrorStatus es =AcDbObject::dxfOutFields (pFiler) ; if ( es != Acad::eOk ) return (es) ; es =pFiler->writeItem (AcDb::kDxfSubclass, _RXST("CPipeAttribute")) ; if ( es != Acad::eOk ) return (es) ; //----- Object version number needs to be saved first if ( (es =pFiler->writeUInt32 (kDxfInt32, CPipeAttribute::kCurrentVersionNumber)) != Acad::eOk ) return (es) ; ////写入数据开始 pFiler->writeItem(AcDb::kDxfReal , m_dRadius); pFiler->writeItem(AcDb::kDxfReal+1 , m_dThickness); pFiler->writeItem(AcDb::kDxfReal+2 , m_dDeep); pFiler->writeItem(AcDb::kDxfText ,m_cMaterial); ////写入数据结束 return (pFiler->filerStatus ()) ; }