Fence in 2D

Hi everybody ,

There is any way to do a fence only in 2D with VBA ???.

I know that I could do it with Range3D like this  :

ElementScanCriteria.IncludeOnlyWithinRange VariableRange3D

But only in 2D ???.

Thanks for your help , best regards !!

  • Hi Xavi,

    can you explain what do you mean by "only in 2D"?

    If you are working in 2D model, all Z values are ignored automatically. And if your model is 3D, you have to define Z values somehow.

    With regards,

    Jan
  • Hi Jan , thanks for the response. I explain you , When I say in 2 dimensions , does it minds that ignore the Z , that only returns the elements in fence correspondence to the fence in X and Y , not looking what Z have.

    The problem that I have , is that if I do fhe fence in 2d using this method is very slow :

    Dim oFenceContents As ElementEnumerator
    Set oFenceContents = oFence.GetContents
    Do While oFenceContents.MoveNext
      Dim oElement As Element
      Set oElement = oFenceContents.Current
      ActiveModelReference.SelectElement oElement
    Loop

    But if I do with this method is very more fast , but I only can use it in 3D :

        Dim searchedArea As Range3d
        With searchedArea
            .Low.X = pnt.X - 0.005
            .Low.Y = pnt.Y - 0.005
            .Low.Z = 0
            .High.X = pnt.X + 0.005
            .High.Y = pnt.Y + 0.005
            .High.Z = 0
        End With
    
        esc.IncludeOnlyWithinRange searchedArea

    I hope that I have been explained better , thanks for your help !!
  • Hi Xavi,

    in my fence operation cannot be replaced by element scan criteria with the range condition. They are different tools working in a different way and as such providing different results:

    Fence is 2D object defined in a context of particular view. Fence provides exact results (real intersections are calculated) based on used fence mode. Because it is 2D object, I guess everything in fence Z range is processed.

    Range3d in element scan criteria tests element's range only, so it provides information if ranges (3D boxes) intersects, which does not mean elements have to intersect. Using ranges is the fastest topology filter in MicroStation, because ranges are stored as a part of element structure, so no element analysis is required and to comapre range coordinates is simple operation. It should be used as a general first filter. To ignore Z if the range is used required to set "infinity value" for low and high Z value. I recommend to check Range3DInit method, because it sets all values to oposite extreme values, so e.g. low X is set to maximum coordinate value and vice versa.

    I hope it explain why fence operation can be slow and range scanning is really fast. They cannot be mixed as they are different, but if rough selection is enough for you, you should use element scan criteria with range.

    But be aware the scanning is always done in master coordinates, so it's not possible to filter elements accordingly to e.g. rotated view. It's something that fence does automatically, becaues it calculates everything exactly.

    With regards,

     Jan

  • Thanks for the explanation Jan , I will test it with scan criteria with a range ... thanks again !!