- 积分
- 15842
- 明经币
- 个
- 注册时间
- 2007-3-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
为什么我用Lisp(vlax-ldata-put "Userdict" "BYSCALE" 1)
用arx读,返回pRb为Null呢?
double GetNameDictDouble(ACHAR* dict,ACHAR* key) //(vlax-ldata-get "Userdict" "BYSCALE")
{
ZffCHAP5AddNameDict();
ZffCHAP5ViewNameDict();
Acad::ErrorStatus es;
struct resbuf *pRb;
AcDbObjectId xrecObjId;
double ret;
// 获得有名对象字典,向其中添加指定的字典项
AcDbDictionary *pNameObjDict, *pDict;
acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNameObjDict,AcDb::kForWrite);
// 检查所要添加的字典项是否已经存在
AcDbObjectId dictObjId;
es=pNameObjDict->getAt(dict, (AcDbObject*&)pDict,AcDb::kForWrite);
if ( es== Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
pNameObjDict->setAt(dict, pDict, dictObjId);
pDict->close();
pNameObjDict->close();
// 向新建的字典中添加一个扩展记录
AcDbXrecord *pXrec = new AcDbXrecord;
acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
pDict->setAt(key, pXrec, xrecObjId);
pDict->close();
pRb = acutBuildList(AcDb::kDxfReal, 1, //把BYSCALE设为1
0);
pXrec->setFromRbChain(*pRb);
pXrec->close();
acutRelRb(pRb);
return 1;
//pRb->resval.rreal
}
pNameObjDict->close();
// 获得指定的对象字典
AcDbXrecord *pXrec;
es=pDict->getAt(key, (AcDbObject*&)pXrec, AcDb::kForWrite);
if ( es== Acad::eKeyNotFound)
{
//pDict->close();
//es=pDict->getAt(key, (AcDbObject*&)pXrec, AcDb::kForWrite);
pDict->setAt(key, pXrec, xrecObjId);
pDict->close();
pRb = acutBuildList(AcDb::kDxfReal, 1, //把BYSCALE设为1
0);
pXrec->setFromRbChain(*pRb);
pXrec->close();
acutRelRb(pRb);
}
pDict->close();
// 获得扩展记录的数据链表并关闭扩展数据对象
es=pXrec->rbChain(&pRb);
pXrec->close();
if (pRb != NULL)
{
ret= pRb->resval.rreal;
acutRelRb(pRb);
return ret;
}
else
return 1;
}
同样,我在arx中设置的MyDict,XRecord在Lisp里同样读不出来
void ZffCHAP5AddNameDict()
{
// 要在扩展记录中保存的字符串
char entType[] = {"直线"};
struct resbuf *pRb;
// 获得有名对象字典,向其中添加指定的字典项
AcDbDictionary *pNameObjDict, *pDict;
acdbHostApplicationServices()->workingDatabase()
->getNamedObjectsDictionary(pNameObjDict,
AcDb::kForWrite);
// 检查所要添加的字典项是否已经存在
AcDbObjectId dictObjId;
if (pNameObjDict->getAt(L"MyDict", (AcDbObject*&)pDict,
AcDb::kForWrite) == Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
pNameObjDict->setAt(L"MyDict", pDict, dictObjId);
pDict->close();
}
pNameObjDict->close();
// 向新建的字典中添加一个扩展记录
AcDbObjectId xrecObjId;
AcDbXrecord *pXrec = new AcDbXrecord;
acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
pDict->setAt(L"XRecord", pXrec, xrecObjId);
pDict->close();
// 设置扩展记录的内容
ads_point pt;
pt[X] = 100;
pt[Y] = 100;
pt[Z] = 0;
pRb = acutBuildList(AcDb::kDxfText, entType,
AcDb::kDxfInt32, 12,
AcDb::kDxfReal, 3.14,
AcDb::kDxfXCoord, pt,
RTNONE);
pXrec->setFromRbChain(*pRb);
pXrec->close();
acutRelRb(pRb);
}
|
|