Nevron Open Vision Documentation
Finding Shapes in Page

NOV Diagram lets you easily find shapes in a page using shape filters. Shape filters are classes that implement the INFilter<NShape> interface.

Commonly Used Shape Filters

The most commonly used filters are placed in the static class NDiagramFilters:

To find shapes in a page, use the GetShapes method of the page passing a shape filter like the ones mentioned above or an instance of any class that implements the INFilter<NShape> interface. For example to get all 2D shapes in the active page of a drawing use the following piece of code:

Get all 2D shapes in the active page of a drawing
Copy Code
bool includeGroupedShapes = true;
NList<NShape> shapes = drawingView.ActivePage.GetShapes(includeGroupedShapes, NDiagramFilters.ShapeType2D);
Included Shape Filter Classes

You can also use the following filter classes included in NOV Diagram:

For example to find all shapes whose text is equal to "My Shape", use the following piece of code:

Get all 2D shapes in the active page of a drawing
Copy Code
bool includeGroupedShapes = true;
NList<NShape> shapes = drawingView.ActivePage.GetShapes(includeGroupedShapes, new NShapeTextFilter("My Shape"));
Custom Shape Filters
You can easily create a class that implements the INFilter<NShape> interface to make a custom search on the shapes in a page. For example, the class ShapeFillFilter below will find all shapes that are filled with a given color:
Shape fill filter
Copy Code
class ShapeFillFilter : INFilter<NShape>
{
    public ShapeFillFilter(NColor color)
    {
        m_Color = color;
    }

    public bool Filter(NShape shape)
    {
        if (shape.GeometryNoCreate == null)
            return false;

        NColorFill colorFill = shape.GeometryNoCreate.Fill as NColorFill;
        if (colorFill == null)
            return false;

        return colorFill.Color == m_Color;
    }

    private NColor m_Color;
}

To find all shapes filled with red, use the class above in the following way:

Find all shapes filled with red
Copy Code
bool includeGroupedShapes = true;
NList<NShape> shapes = drawingView.ActivePage.GetShapes(includeGroupedShapes, new ShapeFillFilter(NColor.Red));
See Also

DataStructures

Send Feedback