Hi - I've seen other entries in this forum mention using ScanCriteria to obtain the graphic elements that are visible in a view window. I've experimented successfully with the same using the following code (although the scan I set up does return some elements that are fully outside the view window extent that I've specified to ScanCriteria):
public StatusInt ScanElements(Element element, DgnModelRef mr) { ... } Viewport viewPort = Session.GetActiveViewport(); DPoint3d ll, ur; viewPort.GetViewCorners(out ll, out ur); DPoint3d[] viewCorners = new DPoint3d[2] { ll, ur }; DPoint3d[] worldCorners = viewPort.ViewToActive(viewCorners); ScanRange scanRange = new ScanRange(); scanRange.m_xlowlim = (long)(worldCorners[0].X + .5); scanRange.m_ylowlim = (long)(worldCorners[0].Y + .5); scanRange.m_xhighlim = (long)(worldCorners[1].X + .5); scanRange.m_yhighlim = (long)(worldCorners[1].Y + .5); ScanCriteria scanCriteria = new ScanCriteria(); scanCriteria.SetModelRef(Session.Instance.GetActiveDgnModel()); scanCriteria.SetRangeTest(scanRange); scanCriteria.SetDrawnElements(); StatusInt si = scanCriteria.Scan(ScanElements);
However, I want to confirm that this is the only/recommended way to do this as opposed to some direct way to achieve this on the viewport by asking the viewport what's currently shown in its view (I studied its methods but nothing jumped out at me).
Thanks,
Martin
Hi Martin Tyberg ,
MicroStation Elements and Views have ranges (2d/3d maximum boundary extents). Likewise, the scan criteria can be set to contrain the range of a given Element or View. Another (range) boundary construct is a Fence. A fence provides the ability to process not only a given range, but provide additional boolean facilities (FenceClipMode) to handle providing Inside/Outside (trimmed) objects if for instance the end goal is to (boolean) cut elements by the bounding shape/area defined. Take a look at this post to see if it may help.
Also, there is a MicroStation SDK Example: ..\Elements\ManagedFenceExample; that may also help.
HTH,Bob
Hi Bob,
Ok thanks.