TA的每日心情 | 开心 半小时前 |
---|
签到天数: 20 天 [LV.4]偶尔看看III
管理员
- 积分
- 1393
|
- static void MyTestApp采用MyClip()
- {
- ads采用point pt1,pt2;
- ads采用name ent;
- if (acedEntSel(采用T("Select xref:"),ent,pt1)!=RTNORM)
- return;
- AcDbObjectId idXref;
- if (acdbGetObjectId(idXref,ent)!=Acad::eOk)
- return;
- AcDbObjectPointer<AcDbBlockReference> pRef(idXref,AcDb::kForRead);
- if (pRef.openStatus()!=Acad::eOk)
- {
- acutPrintf(采用T("Not an xref!\n"));
- return;
- }
- AcGePoint2dArray pts;
- if (acedGetPoint(NULL,采用T("First point:"),pt1)!=RTNORM)
- return;
- //the ECS of the vertices must be defined in the
- //coordinate system of the 采用block采用 so let's calculate
- //transform all points to that coordinate system
- AcGeMatrix3d mat(pRef->blockTransform());
- mat.invert();
- AcGePoint3d pt3d(asPnt3d(pt1));
- pt3d.transformBy(mat);
- pts.append(AcGePoint2d(pt3d.x,pt3d.y));
- while (acedGetPoint(pt1,采用T("Next point:"),pt2)==RTNORM)
- {
- acedGrDraw(pt1,pt2,1,1);
- pt3d = asPnt3d(pt2);
- pt3d.transformBy(mat);
- pts.append(AcGePoint2d(pt3d.x,pt3d.y));
- memcpy(pt1,pt2,sizeof(ads采用point));
- }
- acedRedraw(NULL,0);
- AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
- AcGeVector3d normal;
- double elev;
- if (pDb->tilemode())
- {
- normal = pDb->ucsxdir().crossProduct(pDb->ucsydir());
- elev = pDb->elevation();
- }
- else
- {
- normal = pDb->pucsxdir().crossProduct(pDb->pucsydir());
- elev = pDb->pelevation();
- }
- normal.normalize();
- Acad::ErrorStatus es = pRef.object()->upgradeOpen();
- if (es !=Acad::eOk)
- return;
- //create the filter
- AcDbSpatialFilter* pFilter = new AcDbSpatialFilter;
- if (pFilter->setDefinition(pts,normal,elev,
- ACDB采用INFINITE采用XCLIP采用DEPTH,-ACDB采用INFINITE采用XCLIP采用DEPTH,true)!=Acad::eOk)
- {
- delete pFilter;
- return;
- }
- //add it to the extension dictionary of the block reference
- //the AcDbIndexFilterManger class provides convenient utility functions
- if (AcDbIndexFilterManager::addFilter(pRef.object(),pFilter)!=Acad::eOk)
- delete pFilter;
- else
- {
- acutPrintf(采用T("Filter has been succesfully added!\n"));
- pFilter->close();
- }
- }
复制代码 |
|