- 积分
- 767
- 明经币
- 个
- 注册时间
- 2004-11-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我自己写了一个类要加入字典中,但调不通,请高手指点。。。
下面是代码:
// ScaleClass.h: interface for the CScaleClass class. // //////////////////////////////////////////////////////////////////////
#if !defined(AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_) #define AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_
#if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000
class CScaleClass : public AcDbObject { public: void setvScale(double vs); void sethScale(double hs); void getvScale(double hv); void gethScale(double hs); double vScale; double hScale; CScaleClass(); virtual ~CScaleClass();
};
#endif // !defined(AFX_SCALECLASS_H__EA5D03B9_CC89_40B1_8BB4_48EB14A3EF04__INCLUDED_)
// ScaleClass.cpp: implementation of the CScaleClass class. // //////////////////////////////////////////////////////////////////////
#include "stdafx.h" #include "resource.h" #include "ScaleClass.h"
#ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif
////////////////////////////////////////////////////////////////////// // Construction/Destruction //////////////////////////////////////////////////////////////////////
CScaleClass::CScaleClass() { CScaleClass::rxInit(); }
CScaleClass::~CScaleClass() {
}
void CScaleClass::gethScale(double hs) { hs=hScale; return; }
void CScaleClass::getvScale(double hv) { hv=vScale; return; }
void CScaleClass::sethScale(double hs) { hScale=hs; return; }
void CScaleClass::setvScale(double vs) { vScale=vs; return; }
下面是加入程序
void GeoMapFun::createDictionary(double hs, double vs) { AcDbDictionary *pNamedobj; acdbHostApplicationServices()->workingDatabase()-> getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);
// Check to see if the dictionary we want to create is // already present. If not, create it and add // it to the named object dictionary. // AcDbDictionary *pDict; if (pNamedobj->getAt("SCALE_DICT", (AcDbObject*&) pDict, AcDb::kForWrite) == Acad::eKeyNotFound) { pDict = new AcDbDictionary; AcDbObjectId DictId; pNamedobj->setAt("ASDK_DICT", pDict, DictId); } pNamedobj->close(); if (pDict) {
// Create new objects to add to the new dictionary, // add them, then close them. // CScaleClass *pObj1 = new CScaleClass(); pObj1->sethScale(hs); pObj1->setvScale(vs); AcDbObjectId rId1; pDict->setAt("OBJ1", pObj1, rId1); pObj1->close(); pDict->close(); }
}
void GeoMapFun::iterateDictionary(double hs, double vs) { AcDbDictionary *pNamedobj; acdbHostApplicationServices()->workingDatabase() ->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
// Get a pointer to the ASDK_DICT dictionary. // AcDbDictionary *pDict; pNamedobj->getAt("SCALE_DICT", (AcDbObject*&)pDict, AcDb::kForRead); pNamedobj->close();
// Get an iterator for the ASDK_DICT dictionary. // AcDbDictionaryIterator* pDictIter= pDict->newIterator(); CScaleClass *pMyCl; for (; !pDictIter->done(); pDictIter->next()) {
// Get the current record, open it for read, and // print its data. // pDictIter->getObject((AcDbObject*&)pMyCl, AcDb::kForRead); pMyCl->gethScale(hs); pMyCl->getvScale(vs); pMyCl->close(); acutPrintf("\nintval is: %d", hs); } delete pDictIter; pDict->close();
}
请高手指点,谢谢!! |
|