- 积分
- 113
- 明经币
- 个
- 注册时间
- 2011-4-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
假设下面将数组idarr成功填充
for (pltr->start();!pltr->done();pltr->step())
{
AcDbEntity *nEntity ;
ErrorStatus es = pltr->getEntity(nEntity,AcDb::kForRead);
if (nEntity->layerId() == bulidLID || nEntity->layerId() == splitLID || nEntity->layerId() == bulidSymLID || nEntity->layerId() == splitSymLID)
{
idarr.append(nEntity->id());
AcDbLine *line = AcDbLine::cast(nEntity);
if (line != NULL)
{
x += line->startPoint().x;
x += line->endPoint().x;
y += line->startPoint().x;
y += line->endPoint().x;
i++;
}
}
nEntity->close();
}
那么本段代码
const ACHAR * filea= _T("Save");
resbuf *result = ads_newrb(RTSTR);
int iflags=ads_getfiled(filea, NULL, _T("dwg"), 33, result);
for (int i = 0 ;i<idarr.length();i++)
{
AcDbObject *DbObject;
ErrorStatus es = acdbOpenObject(DbObject,idarr.at(i),AcDb::kForWrite);
if (es != eOk)
AfxMessageBox(_T("XX"));
DbObject->close();
}
ACHAR *FileName;
if (iflags==RTNORM)
{
FileName = (ACHAR*)malloc(sizeof(result->resval.rstring));
StrCpy(FileName,result->resval.rstring);
AcDbDatabase * pdb;
AcGePoint3d pt3d(x / i,y / i,0);
if (idarr.isEmpty())
{
acedAlert(_T("实体数组中未包含任何实体!"));
return;
}
AcDbDatabase *db = acdbHostApplicationServices()->workingDatabase();
ErrorStatus es = db->wblock(pdb,idarr,pt3d); //执行到这里会报错
if (es != Acad::eOk)
{
acedAlert(_T("wblock操作失败!"));
return;
}
es = pdb->saveAs(FileName);
delete pdb;
//free(FileName);
}
这是怎么回事?
|
|