- UID
- 764513
- 积分
- 5
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2016-10-26
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在dwg文件中插入图片的代码如下,可是运行到
Acad::ErrorStatus es = pDict->setAt(dictName, pImageDef, objId);语句的时候提示Acad::eNoClassId错误。
哪位高手有时间麻烦看一下,代码有什么错误。代码贴出来如下:
void SignalSimulate::createPicture(CString name, AcGePoint3d point1, AcGePoint3d point2){
//CString dictName = TEXT("simulate");
CString dictName = TEXT("testSimulate");
//CString fileName = UtilCom::getArxPath(name);
CString fileName = name;
loadModule();
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
AcDbRasterImageDef* pImageDef = new AcDbRasterImageDef();
if(pImageDef->setSourceFileName(fileName) != Acad::eOk)
{
delete pImageDef;
return;
}
Acad::ErrorStatus es = pImageDef->load();
AcDbObjectId dictId = AcDbRasterImageDef::imageDictionary(pDb);
//AcDbObjectId dictId = AcDbObjectId::kNull;
if(AcDbRasterImageDef::createImageDictionary(pDb, dictId) != Acad::eOk)
{
delete pImageDef;
acutPrintf(TEXT("Could not create dictionary.\n"));
return;
}
AcDbDictionary* pDict = NULL;
if(acdbOpenObject(pDict, dictId, AcDb::kForWrite) != Acad::eOk)
{
delete pImageDef;
acutPrintf(TEXT("Could not open dictionary.\n"));
return;
}
AcDbObjectId objId;
if (pDict->has(dictName))
{
Acad::ErrorStatus es = pDict->getAt(dictName, (AcDbObject*&) pImageDef, AcDb::kForWrite);
objId = pImageDef->objectId();
}
else
{
Acad::ErrorStatus es = pDict->setAt(dictName, pImageDef, objId);
acutPrintf(TEXT("%d"),es);
}
// close Dictionary and Definition.
pDict->close();
pImageDef->close();
#if 0
ads_point pt1, pt2;
if (acedGetPoint(NULL, TEXT("仿真边界起点:\n"), pt1) != RTNORM) {
return;
}
if (acedGetCorner(pt1, TEXT("仿真边界终点:\n"), pt2) != RTNORM) {
return;
}
AcGePoint3d point1 = asPnt3d(pt1), point2 = asPnt3d(pt2);
#endif
AcDbRasterImage* pImage = new AcDbRasterImage();
if (pImage->setImageDefId(objId) != Acad::eOk)
{
delete pImage;
return;
}
AcDbObjectId modelId = acdbSymUtil()->blockModelSpaceId(pDb);
AcDbBlockTableRecord *pBTRecord;
acdbOpenAcDbObject((AcDbObject*&) pBTRecord, modelId, AcDb::kForWrite);
es = pBTRecord->appendAcDbEntity(pImage);
pBTRecord->close();
AcDbObjectId imgId = pImage->objectId();
AcGePoint3d org;
org.x = point1.x < point2.x ? point1.x : point2.x;
org.y = point1.y < point2.y ? point1.y : point2.y;
AcGePoint3d ptw(fabs(point1.x - point2.x), 0, 0), pth(0, fabs(point1.y - point2.y), 0);
if (pImage->setOrientation(org, ptw.asVector(), pth.asVector()) != Adesk::kTrue) {
acutPrintf(TEXT("Set Orientation failed.\n"));
pImage->close();
return;
}
pImage->setDisplayOpt(AcDbRasterImage::kShow, Adesk::kTrue);
pImage->setDisplayOpt(AcDbRasterImage::kTransparent, Adesk::kTrue);
pImage->close();
}
|
|