找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[每日一码] XCLIP xrefs using ObjectARX

[复制链接]

1

主题

0

回帖

33

积分

管理员

积分
33
发表于 2024-3-14 20:52:30 | 显示全部楼层 |阅读模式
  1. static void MyTestApp采用MyClip()
  2. {
  3.     ads采用point pt1,pt2;
  4.     ads采用name ent;
  5.     if (acedEntSel(采用T("Select xref:"),ent,pt1)!=RTNORM)
  6.         return;
  7.     AcDbObjectId idXref;
  8.     if (acdbGetObjectId(idXref,ent)!=Acad::eOk)
  9.         return;
  10.     AcDbObjectPointer<AcDbBlockReference> pRef(idXref,AcDb::kForRead);
  11.     if (pRef.openStatus()!=Acad::eOk)
  12.     {
  13.         acutPrintf(采用T("Not an xref!\n"));
  14.         return;
  15.     }
  16.     AcGePoint2dArray pts;
  17.     if (acedGetPoint(NULL,采用T("First point:"),pt1)!=RTNORM)
  18.         return;
  19.     //the ECS of the vertices must be defined in the
  20.     //coordinate system of the 采用block采用 so let's calculate
  21.     //transform all points to that coordinate system
  22.     AcGeMatrix3d mat(pRef->blockTransform());
  23.     mat.invert();
  24.     AcGePoint3d pt3d(asPnt3d(pt1));
  25.     pt3d.transformBy(mat);
  26.     pts.append(AcGePoint2d(pt3d.x,pt3d.y));
  27.     while (acedGetPoint(pt1,采用T("Next point:"),pt2)==RTNORM)
  28.     {
  29.         acedGrDraw(pt1,pt2,1,1);
  30.         pt3d = asPnt3d(pt2);
  31.         pt3d.transformBy(mat);
  32.         pts.append(AcGePoint2d(pt3d.x,pt3d.y));
  33.         memcpy(pt1,pt2,sizeof(ads采用point));
  34.     }
  35.     acedRedraw(NULL,0);
  36.     AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
  37.     AcGeVector3d normal;
  38.     double elev;
  39.     if (pDb->tilemode())
  40.     {
  41.         normal = pDb->ucsxdir().crossProduct(pDb->ucsydir());
  42.         elev = pDb->elevation();
  43.     }
  44.     else
  45.     {
  46.         normal = pDb->pucsxdir().crossProduct(pDb->pucsydir());
  47.         elev = pDb->pelevation();
  48.     }
  49.     normal.normalize();
  50.     Acad::ErrorStatus es = pRef.object()->upgradeOpen();
  51.     if (es !=Acad::eOk)
  52.         return;
  53.     //create the filter
  54.     AcDbSpatialFilter* pFilter = new AcDbSpatialFilter;
  55.     if (pFilter->setDefinition(pts,normal,elev,
  56.         ACDB采用INFINITE采用XCLIP采用DEPTH,-ACDB采用INFINITE采用XCLIP采用DEPTH,true)!=Acad::eOk)
  57.     {
  58.         delete pFilter;
  59.         return;
  60.     }
  61.     //add it to the extension dictionary of the block reference
  62.     //the AcDbIndexFilterManger class provides convenient utility functions
  63.     if (AcDbIndexFilterManager::addFilter(pRef.object(),pFilter)!=Acad::eOk)
  64.         delete pFilter;
  65.     else
  66.     {
  67.         acutPrintf(采用T("Filter has been succesfully added!\n"));
  68.         pFilter->close();
  69.     }
  70. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-12-29 21:29 , Processed in 0.149999 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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