改变显示顺序的代码
本帖最后由 LoveArx 于 2017-1-27 12:54 编辑Acad::ErrorStatus changeDrawOrder(AcDbObjectId parent, AcDbObjectIdArray &childArray, AcEdDrawOrderCmdType variant)
{
if (childArray.isEmpty()) return Acad::eInvalidInput;
Acad::ErrorStatus es = Acad::eOk;
AcDbSortentsTable *pSortTab = NULL;
AcDbObjectId spaceId = AcDbObjectId::kNull;
AcDbEntityPointer pEnt(childArray.first(),AcDb::kForRead);
if (pEnt.openStatus() == Acad::eOk)
{
spaceId = pEnt->ownerId();
pEnt->close();
}
if (!spaceId.isNull())
{
AcDbBlockTableRecordPointer pBTR(spaceId,AcDb::kForRead);
if (pBTR.openStatus() == Acad::eOk)
{
if (pBTR->getSortentsTable(pSortTab, AcDb::kForWrite, true) == Acad::eOk)
{
switch (variant)
{
case kDrawOrderBottom:
es = pSortTab->moveToBottom(childArray);
break;
case kDrawOrderTop:
es = pSortTab->moveToTop(childArray);
break;
case kDrawOrderBelow:
es = pSortTab->moveBelow(childArray,parent);
break;
case kDrawOrderAbove:
es = pSortTab->moveAbove(childArray,parent);
break;
}
pSortTab->close();
}
}
}
return es;
}
下面是具体调用的实例
**** Hidden Message *****
另一个用法例子:
ads_name entName;
ads_point entpoint;
if (acedEntSel(_T("\nlayer:"),entName,entpoint)!=RTNORM)
{
return;
}
AcDbObjectId layerId;
acdbGetObjectId(layerId,entName);
AcDbEntity *pEnt;
acdbOpenObject(pEnt,layerId,AcDb::kForWrite);
TCHAR *layerName=pEnt->layer();
pEnt->close();
struct resbuf *rb;
ads_name ssname;
rb=acutBuildList(8,layerName,RTNONE);
int rc=acedSSGet(_T("X"),NULL,NULL,rb,ssname);
AcDbObjectIdArray objIds;
if (rc!=RTNORM)
{
acutRelRb(rb);
return;
}
long length;
acedSSLength(ssname,&length);
acutPrintf(_T("\nlayer%sall%d个"),layerName,length);
for (int i=0;i<length;i++)
{
ads_name ent;
acedSSName(ssname,i,ent);
AcDbObjectId objId;
acdbGetObjectId(objId,ent);
objIds.append(objId);
}
changeDrawOrder(NULL,objIds,kDrawOrderTop);
//acedDrawOrderInherit(NULL,objIds,::kDrawOrderTop);
acedSSFree(ssname);
acutDelString(layerName);
if (rb!=NULL)
{
acutRelRb(rb);
}
改变选择的实体显示顺序到最下
static void MoveToBottom(void)
{
ads_point p;
ads_name en;
Acad::ErrorStatus es;
if (acedEntSel(L"\nSelect entity: ",en,p) == RTNORM) {
AcDbObjectId id; acdbGetObjectId(id,en);
AcDbSortentsTable *pSortTab = NULL;
AcDbObjectId spaceId = acdbCurDwg()->currentSpaceId();
AcDbObjectPointer<AcDbBlockTableRecord> pBTR(spaceId,AcDb::kForRead);
if ((es = pBTR.openStatus()) == Acad::eOk) {
if ((es = pBTR->getSortentsTable(pSortTab, AcDb::kForWrite, true)) == Acad::eOk) {
AcDbObjectIdArray ar; ar.append(id);
pSortTab->moveToBottom(ar);
pSortTab->close();
} else {
acutPrintf(L"\nError open AcDbSortentsTable: %s",acadErrorStatusText(es));
}
} else {
acutPrintf(L"\nError open AcDbBlockTableRecord: %s",acadErrorStatusText(es));
}
}
}
谢谢提供,祝新年快乐 看起来不错啊。。 谢谢提供,学习一下了!!! 谢谢提供,祝新年快乐 谢谢分享。 学习!!!!!!!!!!!
谢谢 学习学习 谢谢
过来学习学习
谢谢分享!! 啥也不说了,感谢楼主分享哇! 谢谢楼主分享 我也来学习学习,
回复学习