Get Nearest Polygon

Dear All,

How to get the nearest Polygons which contains the selected elements (using VBA)?

In the attached screenshot, the Majenta color represents the selected elements and the corresponding nearest polygons was represented in Green color.

Parents
  • Unknown said:
    How to get the nearest polygons which contains the selected elements?

    1. Build a list of polygons (shape elements)
    2. Iterate your list of polygons
    3. For each polygon
      1. Create a fence
      2. Use the fence to find if a selected element is enclosed

     
    Regards, Jon Summers
    LA Solutions

  • Thanks Jon.

    I followed your suggestion with a slight change as given below(since the selected elements are polygon. we can use them as fence).

    CadInputQueue.SendKeyin "CHANGE VIEW CUSTOM ""Smooth"" 1"

    ''now create a fence - Type = Element,Mode = Overlap

    createPolygonasFence selectedElemnt

    Set elemntEnumerator = ActiveDesignFile.Fence.GetContents

    While elemntEnumerator.MoveNext

       Set fEl = elemntEnumerator.Current

       If fEl.ID.Low <> selectedElemnt.ID.Low Then And fEl.IsShapeElement Then

          ''other statements

       End If

    Wend

Reply
  • Thanks Jon.

    I followed your suggestion with a slight change as given below(since the selected elements are polygon. we can use them as fence).

    CadInputQueue.SendKeyin "CHANGE VIEW CUSTOM ""Smooth"" 1"

    ''now create a fence - Type = Element,Mode = Overlap

    createPolygonasFence selectedElemnt

    Set elemntEnumerator = ActiveDesignFile.Fence.GetContents

    While elemntEnumerator.MoveNext

       Set fEl = elemntEnumerator.Current

       If fEl.ID.Low <> selectedElemnt.ID.Low Then And fEl.IsShapeElement Then

          ''other statements

       End If

    Wend

Children