Community
So, the documentation for AcDbOle2Frame::setOleObject says:
I took this to mean that OLE items couldn't be created in ObjectARX and added to my DWG. Admittedly, I never actually tried it until now. However, something like this does actually work:
Acad::ErrorStatus es = Acad::eOk;
CADManager.StartTransaction(__FUNCTION__);
AcDbOle2Frame* pNewFrame = new AcDbOle2Frame();
pNewFrame->setDatabaseDefaults();
AcDbDatabase* db = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTable* blockTable;
es = db->getBlockTable(blockTable, AcDb::kForRead);
AcDbBlockTableRecord* modelSpace;
es = blockTable->getAt(ACDB_MODEL_SPACE, modelSpace, AcDb::kForWrite);
es = modelSpace->appendAcDbEntity(pNewFrame);
es = acdbTransactionManager->addNewlyCreatedDBRObject(pNewFrame);
AcApDocument* pActiveDoc = acDocManager->mdiActiveDocument();
COleDocument* pDoc = (COleDocument *)pActiveDoc->cDoc();
COleClientItem* pItem = new COleClientItem(pDoc);
if (pItem->CreateFromFile(sReportFile))
{
es = pNewFrame->setOleClientItem(pItem);
}
AcGePoint3d point3d;
point3d.x = -3220;
point3d.y = 5230;
pNewFrame->setLocation(point3d);
CRectangle3d rect3d;
rect3d.lowLeft.x = -3220;
rect3d.lowLeft.y = 5230;
rect3d.lowLeft.z = 0;
rect3d.lowRight.x = -3120;
rect3d.lowRight.y = 5230;
rect3d.lowRight.z = 0;
rect3d.upLeft.x = -3220;
rect3d.upLeft.y = 5330;
rect3d.upLeft.z = 0;
rect3d.upRight.x = -3120;
rect3d.upRight.y = 5330;
rect3d.upRight.z = 0;
pNewFrame->setPosition(rect3d);
pNewFrame->setScaleHeight(100);
pNewFrame->setScaleWidth(100);
// Clean up
es = pNewFrame->close();
es = modelSpace->close();
es = blockTable->close();
CADManager.EndTransaction(__FUNCTION__);
So my question is - is it supposed to work? Am I going to run into problems if I use code like this?
never used Ole, there's also a AcDbHostApplicationServices::getNewOleClientItem
Can't find what you're looking for? Ask the community or share your knowledge.