|
- void GetRasterImageReferences(const ACHAR* strRasterImgName)
- {
- Acad::ErrorStatus es;
- AcDbObjectId dicoId;
- if((dicoId = AcDbRasterImageDef::imageDictionary(acdbCurDwg())) == AcDbObjectId::kNull)
- {
- acutPrintf(L"\nImage dictionary does not exist...");
- return;
- }
- AcDbDictionary* pDict;
- if((es = acdbOpenObject((AcDbObject*&)pDict, dicoId, AcDb::kForRead)) != Acad::eOk)
- {
- acutPrintf(L"\nCould not open image dictionary...");
- return;
- }
- AcDbRasterImageDef* pImageDef;
- if (!pDict->has(strRasterImgName))
- {
- acutPrintf(L"\nImage dictionary does not contain specified definition...");
- return;
- }
- es = pDict->getAt(strRasterImgName, (AcDbObject*&)pImageDef, AcDb::kForRead);
- pDict->close();
- AcDbObjectIdArray hardPointerIds;
- AcDbObjectIdArray softPointerIds;
- AcDbObjectIdArray hardOwnershipIds;
- AcDbObjectIdArray softOwnershipIds;
- asdkReferencesFiler filer;
- pImageDef->dwgOut(&filer);
- pImageDef->close();
- hardPointerIds = filer.m采用hardPointerIds;
- softPointerIds = filer.m采用softPointerIds;
- hardOwnershipIds = filer.m采用hardOwnershipIds;
- softOwnershipIds = filer.m采用softOwnershipIds;
- for (int i = 0; i < softPointerIds.length(); i++)
- {
- AcDbObject* pReference;
- if((es = acdbOpenObject((AcDbObject*&)pReference, softPointerIds<i>, AcDb::kForRead)) != Acad::eOk)
- {
- acutPrintf(L"\nCould not open object");
- continue;
- }
- //acutPrintf(L"\nReference type: %s", pReference->isA()->name());
- AcDbRasterImageDefReactor* pImgReactor = NULL;
- if ((pImgReactor = AcDbRasterImageDefReactor::cast(pReference)) != NULL )
- {
- AcDbRasterImage* pImgReference;
- if((es = acdbOpenObject((AcDbObject*&)pImgReference, pImgReactor->ownerId(), AcDb::kForRead)) != Acad::eOk)
- {
- acutPrintf(L"\nCould not open image ref...");
- }
- else
- {
- AcDbExtents extents;
- pImgReference->getGeomExtents(extents);
- acutPrintf(L"\nImage Reference position: [%f, %f, %f]", extents.minPoint().x, extents.minPoint().y, extents.minPoint().z);
- pImgReference->close();
- }
- }
- pReference->close();
- }
- }
复制代码 |
|