天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 65|回复: 0

AcDbSpatialFilter的使用,由于使用较少,arx中找不到资料,记...

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
static void Test_Clip ()

{

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<<span style=”color: rgb(43, 145, 175);”>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) {

pRef->close();

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) {

pRef->close();

return;

}

//create the filter

AcDbSpatialFilter* pFilter = new AcDbSpatialFilter;

//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”));

pRef.object()->downgradeOpen();

}

if (pFilter->setDefinition(pts,normal,elev,

ACDB_INFINITE_XCLIP_DEPTH,-ACDB_INFINITE_XCLIP_DEPTH, true) !=Acad::eOk)

{

acutPrintf(L”Filter setDefinition failed.”);

//remove the filter if setDefinition fails.

pFilter->erase();



}

es = pFilter->erase();

pFilter->close();

pRef->close();



}

 

 

 

 

AcDbSpatialFilter的使用,由于使用较少,arx中找不到资料,记...
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 11:41 , Processed in 0.146617 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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