I'm attempting to write a tool to select closed elements. DgnRegionElementTool seems a likely candidate. I want to verify that the perimeter elements picked by the user are suitable. My problem is that _OnPostLocate and _AcceptClosedElement are never called...
DgnRegionElementTool
_OnPostLocate
_AcceptClosedElement
struct PickRegionTool : DgnRegionElementTool { private: RegionParams regionParams_; protected: /// PickRegionTool constructor. PickRegionTool (int toolId) : DgnRegionElementTool () {SetCmdName (toolId, 0);} /// Show valid flood region under the cursor without waiting for accept point. virtual bool _WantFloodDynamicArea () override {return true;} /// Return true if the tool wants to process the original elements that were directly involved in creating the result region. virtual bool _WantProcessOriginals () override {return false;} /// Return true to allow physically closed open paths as boundary candidates. virtual bool _AllowPhysicallyClosed () override {return false;} /// Called from _OnPostLocate and _FilterAgendaEntries to reject invalid boundary candidates. virtual bool _AcceptClosedElement (ElementHandleCR eh, WStringR cantAcceptReason); /// Create region using _GetRegionParams. virtual RegionCreateMode _GetRegionCreateMode () override {return REGION_CREATE_ByParams;} /// Setup region params to create region by flood (or boolean). virtual RegionParams const& _GetRegionParams () override; /// Process a region element created by this tool. virtual BentleyStatus _OnProcessRegionResult (EditElementHandleR eeh) override; /// Check for valid boundary candidates. virtual bool _OnPostLocate (HitPathCP path, WStringR cantAcceptReason) override; /// Test whether candidate shape is suitable for this tool. bool Acceptable (ElementHandleCR candidate) const; virtual void _OnRestartTool () override; // pure virtual method, sub-class must override! public: static void InstallNewInstance (int toolId); };
What switch do I need to flip to ensure that _OnPostLocate and _AcceptClosedElement are called?
_OnPostLocate is specific to locating elements, you've specified that you want to find closed areas using flood, which loads all the "curve" geometry displayed in the view into a graph in order to locate closed areas by interior points, it doesn't use the normal locate mechanism as the flood region boundary can be comprised of curves from multiple elements and is always closed by definition.
If your goal is only to accept existing closed elements, I don't recommend using DgnRegionElementTool/flood as building that graph is a huge expense if you aren't interested in finding closed area from open boundary candidates.
Answer Verified By: Jon Summers