[ARX]派生于AcDbObject的定制类实体加入到对象字典的问题??
我自己写了一个类要加入字典中,但调不通,请高手指点。。。下面是代码:
// ScaleClass.h: interface for the CScaleClass class.<BR>//<BR>//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_)<BR>#define AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_
#if _MSC_VER > 1000<BR>#pragma once<BR>#endif // _MSC_VER > 1000
class CScaleClass : public AcDbObject <BR>{<BR>public:<BR> void setvScale(double vs);<BR> void sethScale(double hs);<BR> void getvScale(double hv);<BR> void gethScale(double hs);<BR> double vScale;<BR> double hScale;<BR> CScaleClass();<BR> virtual ~CScaleClass();
};
#endif // !defined(AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_)<BR>
// ScaleClass.cpp: implementation of the CScaleClass class.<BR>//<BR>//////////////////////////////////////////////////////////////////////
#include "stdafx.h"<BR>#include "resource.h"<BR>#include "ScaleClass.h"
#ifdef _DEBUG<BR>#undef THIS_FILE<BR>static char THIS_FILE[]=__FILE__;<BR>#define new DEBUG_NEW<BR>#endif
//////////////////////////////////////////////////////////////////////<BR>// Construction/Destruction<BR>//////////////////////////////////////////////////////////////////////
CScaleClass::CScaleClass()<BR>{<BR>CScaleClass::rxInit(); <BR>}
CScaleClass::~CScaleClass()<BR>{
}
void CScaleClass::gethScale(double hs)<BR>{<BR>hs=hScale;<BR>return;<BR>}
void CScaleClass::getvScale(double hv)<BR>{<BR>hv=vScale;<BR>return;<BR>}
void CScaleClass::sethScale(double hs)<BR>{<BR>hScale=hs;<BR>return;<BR>}
void CScaleClass::setvScale(double vs)<BR>{<BR>vScale=vs;<BR>return;<BR>}<BR>
下面是加入程序
void GeoMapFun::createDictionary(double hs, double vs)<BR>{<BR> AcDbDictionary *pNamedobj;<BR> acdbHostApplicationServices()->workingDatabase()-><BR> getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);
// Check to see if the dictionary we want to create is<BR> // already present. If not, create it and add<BR> // it to the named object dictionary.<BR> //<BR> AcDbDictionary *pDict;<BR> if (pNamedobj->getAt("SCALE_DICT", (AcDbObject*&) pDict,<BR> AcDb::kForWrite) == Acad::eKeyNotFound)<BR> {<BR> pDict = new AcDbDictionary;<BR> AcDbObjectId DictId;<BR> pNamedobj->setAt("ASDK_DICT", pDict, DictId);<BR> }<BR> pNamedobj->close();<BR> if (pDict) {
// Create new objects to add to the new dictionary,<BR> // add them, then close them.<BR> //<BR> CScaleClass *pObj1 = new CScaleClass();<BR> pObj1->sethScale(hs);<BR> pObj1->setvScale(vs);<BR> AcDbObjectId rId1;<BR> pDict->setAt("OBJ1", pObj1, rId1);<BR> pObj1->close();<BR> pDict->close();<BR> }
}
void GeoMapFun::iterateDictionary(double hs, double vs)<BR>{<BR> AcDbDictionary *pNamedobj;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
// Get a pointer to the ASDK_DICT dictionary.<BR> //<BR> AcDbDictionary *pDict;<BR> pNamedobj->getAt("SCALE_DICT", (AcDbObject*&)pDict,<BR> AcDb::kForRead);<BR> pNamedobj->close();
// Get an iterator for the ASDK_DICT dictionary.<BR> //<BR> AcDbDictionaryIterator* pDictIter= pDict->newIterator();<BR> CScaleClass *pMyCl;<BR> <BR> for (; !pDictIter->done(); pDictIter->next()) {
// Get the current record, open it for read, and<BR> // print its data.<BR> //<BR> pDictIter->getObject((AcDbObject*&)pMyCl,<BR> AcDb::kForRead);<BR> pMyCl->gethScale(hs);<BR> pMyCl->getvScale(vs);<BR> pMyCl->close();<BR> acutPrintf("\nintval is: %d", hs);<BR> }<BR> delete pDictIter;<BR> pDict->close();
}
请高手指点,谢谢!! <p>我也出现了相同的问题,请问是怎么解决的呢?</p> 顶起,希望在4楼。
页:
[1]