找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 163|回复: 0

[每日一码] 如何从一个image定义得到所有引用它的raster image

[复制链接]

0

主题

0

回帖

26

积分

管理员

积分
26
发表于 2024-2-26 10:34:38 | 显示全部楼层 |阅读模式
  1. void GetRasterImageReferences(const ACHAR* strRasterImgName)
  2. {
  3. Acad::ErrorStatus es;
  4. AcDbObjectId dicoId;
  5. if((dicoId = AcDbRasterImageDef::imageDictionary(acdbCurDwg())) == AcDbObjectId::kNull)
  6. {
  7.   acutPrintf(L"\nImage dictionary does not exist...");
  8.   return;
  9. }
  10. AcDbDictionary* pDict;
  11. if((es = acdbOpenObject((AcDbObject*&)pDict, dicoId, AcDb::kForRead)) != Acad::eOk)
  12. {
  13.   acutPrintf(L"\nCould not open image dictionary...");
  14.   return;
  15. }
  16. AcDbRasterImageDef* pImageDef;
  17. if (!pDict->has(strRasterImgName))
  18. {
  19.   acutPrintf(L"\nImage dictionary does not contain specified definition...");
  20.   return;
  21. }
  22. es = pDict->getAt(strRasterImgName, (AcDbObject*&)pImageDef, AcDb::kForRead);
  23. pDict->close();
  24. AcDbObjectIdArray hardPointerIds;
  25. AcDbObjectIdArray softPointerIds;
  26. AcDbObjectIdArray hardOwnershipIds;
  27. AcDbObjectIdArray softOwnershipIds;
  28.     asdkReferencesFiler filer;
  29. pImageDef->dwgOut(&filer);
  30.     pImageDef->close();
  31.     hardPointerIds   = filer.m采用hardPointerIds;
  32.     softPointerIds   = filer.m采用softPointerIds;
  33.     hardOwnershipIds = filer.m采用hardOwnershipIds;
  34.     softOwnershipIds = filer.m采用softOwnershipIds;
  35. for (int i = 0; i < softPointerIds.length(); i++)
  36. {
  37.   AcDbObject* pReference;
  38.   if((es = acdbOpenObject((AcDbObject*&)pReference, softPointerIds<i>, AcDb::kForRead)) != Acad::eOk)
  39.   {
  40.    acutPrintf(L"\nCould not open object");
  41.    continue;
  42.   }
  43.   //acutPrintf(L"\nReference type: %s", pReference->isA()->name());
  44.   AcDbRasterImageDefReactor* pImgReactor = NULL;
  45.   if ((pImgReactor = AcDbRasterImageDefReactor::cast(pReference)) != NULL )
  46.   {
  47.    AcDbRasterImage* pImgReference;
  48.    if((es = acdbOpenObject((AcDbObject*&)pImgReference, pImgReactor->ownerId(), AcDb::kForRead)) != Acad::eOk)
  49.    {
  50.     acutPrintf(L"\nCould not open image ref...");
  51.    }
  52.    else
  53.    {
  54.     AcDbExtents extents;
  55.     pImgReference->getGeomExtents(extents);
  56.     acutPrintf(L"\nImage Reference position: [%f, %f, %f]", extents.minPoint().x, extents.minPoint().y, extents.minPoint().z);
  57.     pImgReference->close();
  58.    }
  59.   }
  60.   pReference->close();
  61. }
  62. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-28 14:06 , Processed in 0.129904 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表