- UID
- 6238
- 积分
- 291
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-6-9
- 最后登录
- 1970-1-1
|
发表于 2003-1-24 09:56:42
|
显示全部楼层
这里有段代码,可参考!
void RectWindow::addXtnDict()
{
AcDbXrecord *pXrec = new AcDbXrecord;
AcDbObject *pObj;
AcDbObjectId dictObjId, xrecObjId, entId;
AcDbDictionary *pNamedObjD, *pDict;
char windotype[] = {"Rect"};
ads_name ename;
struct resbuf* prbXtn;
AcDbHandle handEnt;
char strHandle[17];
AcGePoint2d sp(getWindowStartPoint());
ads_point lwrleft;
lwrleft[X] = sp.x;
lwrleft[Y] = sp.y;
lwrleft[Z] = 0.0;
acdbCurDwg()->getNamedObjectsDictionary(pNamedObjD, AcDb::kForWrite);
// Check to see if the dictionary we want to create is
// already present if it's not, then create it and add
// it to the named object dictionary.
//
if (pNamedObjD->getAt("WINDO_INFO", (AcDbObject*&) pDict,
AcDb::kForWrite) == Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
pNamedObjD->setAt("WINDO_INFO", pDict, dictObjId);
}
pNamedObjD->close();
// Get the last entity
ads_entlast(ename);
// Get the entity object ID
acdbGetObjectId(entId, ename);
// Open the enity for a read operation
acdbOpenObject(pObj, entId, AcDb::kForRead);
pObj->getAcDbHandle(handEnt);
handEnt.getIntoAsciiBuffer(strHandle);
pObj->close();
acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
pDict->setAt(strHandle, pXrec, xrecObjId);
pDict->close();
prbXtn = ads_buildlist(AcDb::kDxfText, windotype,
AcDb::kDxfInt32, getWindowRows(),
AcDb::kDxfInt32, getWindowCols(),
AcDb::kDxfReal, getWindowLength(),
AcDb::kDxfReal, getWindowHeight(),
AcDb::kDxfXCoord, lwrleft,
RTNONE);
// Add the data list to the Xrecord. Notice that this
// member function takes a reference to resbuf *NOT* a
// pointer to resbuf, so you must dereference the
// pointer before sending it.
//
pXrec->setFromRbChain(*prbXtn);
pXrec->close();
ads_relrb(prbXtn);
} |
|