CAD工具之家's Archivers

From boitboy on 2014-03-07 10:55:29

选择集过滤

示例代码:禁止选中任何直线 下载代码 //AcEdSSGetFilterEx.h #pragma once class AcEdSSGetFilterEx:public AcEdSSGetFilter { virtual void ssgetAddFilter( int ssgetFlags, AcEdSelectionSetService &service, const AcDbObjectIdArray& selectionSet, const AcDbObjectIdArray& subSelectionSet); virtual void endSSGet( Acad::PromptStatus returnStatus, int ssgetFlags, AcEdSelectionSetService &service, const AcDbObjectIdArray& selectionSet); virtual void endEntsel( Acad::PromptStatus       returnStatus, const AcDbObjectId&      pickedEntity, const AcGePoint3d&       pickedPoint, AcEdSelectionSetService& service); //是否可以选中 virtual bool CanBeSelect(AcDbObjectId id); //是否可以选中 virtual bool CanBeSelect(AcDbEntity* pEnt); }; //AcEdSSGetFilterEx.cpp #include "StdAfx.h" #include "AcEdSSGetFilterEx.h" void AcEdSSGetFilterEx::ssgetAddFilter( int ssgetFlags, AcEdSelectionSetService &service, const AcDbObjectIdArray& selectionSet, const AcDbObjectIdArray& subSelectionSet) { acutPrintf(_T("\r\nAcEdSSGetFilterEx::ssgetAddFilter\r\n")); for(int i=subSelectionSet.logicalLength()-1;i>=0;i--) { if(CanBeSelect(subSelectionSet.at(i))) { continue; } service.remove(i); } } void AcEdSSGetFilterEx::endSSGet( Acad::PromptStatus returnStatus, int ssgetFlags, AcEdSelectionSetService &service, const AcDbObjectIdArray& selectionSet) { acutPrintf(_T("\r\nAcEdSSGetFilterEx::endSSGet\r\n")); for(int i=selectionSet.logicalLength()-1;i>=0;i--) { if(CanBeSelect(selectionSet.at(i))) { continue; } service.remove(i); } } void AcEdSSGetFilterEx::endEntsel( Acad::PromptStatus       returnStatus, const AcDbObjectId&      pickedEntity, const AcGePoint3d&       pickedPoint, AcEdSelectionSetService& service) { acutPrintf(_T("\r\nAcEdSSGetFilterEx::endEntsel\r\n")); if(CanBeSelect(pickedEntity)) { return; } service.remove(0); } //是否可以选中 bool AcEdSSGetFilterEx::CanBeSelect(AcDbObjectId id) { AcDbEntity* pEnt=NULL; Acad::ErrorStatus es=acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead); if(es!=Acad::eOk) { return false; } bool rc=CanBeSelect(pEnt); pEnt->close(); return rc; } //是否可以选中 bool AcEdSSGetFilterEx::CanBeSelect(AcDbEntity* pEnt) { return true; } //MySSGetFilter.h #pragma once #include "AcEdSSGetFilterEx.h" class MySSGetFilter: public AcEdSSGetFilterEx { public: //是否可以选中 virtual bool CanBeSelect(AcDbEntity* pEnt); }; //MySSGetFilter.cpp #include "StdAfx.h" #include "MySSGetFilter.h" //是否可以选中 bool MySSGetFilter::CanBeSelect(AcDbEntity* pEnt) { if(pEnt->isKindOf(AcDbLine::desc())) { return false; } else { return true; } } //acrxEntryPoint.cpp #include "StdAfx.h" #include "resource.h" #include "MySSGetFilter.h" MySSGetFilter m_filter; //----------------------------------------------------------------------------- #define szRDS _RXST("") //----------------------------------------------------------------------------- //----- ObjectARX EntryPoint class CSSGetFilterTestApp : public AcRxArxApp { public: CSSGetFilterTestApp () : AcRxArxApp () {} virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) { // TODO: Load dependencies here // You *must* call On_kInitAppMsg here AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ; addSSgetFilterInputContextReactor(curDoc(), &m_filter); // TODO: Add your initialization code here return (retCode) ; } virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) { // TODO: Add your code here // You *must* call On_kUnloadAppMsg here AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ; removeSSgetFilterInputContextReactor(curDoc(), &m_filter); // TODO: Unload dependencies here return (retCode) ; } virtual void RegisterServerComponents () { } } ; //----------------------------------------------------------------------------- IMPLEMENT_ARX_ENTRYPOINT(CSSGetFilterTestApp)

查看完整版本: 选择集过滤

Tags: 过滤, 选择集


©CAD工具之家
创办于:2013年5月24日