[MicroStation V8i SS3 VBA] Why the macro execution speed depends on the zoom in the drawing?

Hello, whenever I have a macro with a loop that scans the fence, when the zoom in the drawing is large, the program works slowly and when the zoom is small, the program works quickly?

same task:

time for big zoom

time for small zoom

Parents
  • I suspect that the circle used to define your fence is being stroked to a different number of points based on it's size in the view.

    Fence processing works on a set of convex clip planes, so when a fence is defined by curves and the fence has a view associated with it, it's stroked to a view based tolerance. Lots of clip planes means testing against the fence takes more time.

    If you want to use a fence for this, try creating it from a N-sided polygon (choose a reasonable number for N that doesn't take to long to process and is accurate enough for your use case). The approach Jan outlines is perfectly reasonable as well.

    HTH

    -B



  • I did the test and turned the circle into a polygon, the problem persisted

    code that creates a fence from a polygon

    Sub FencePolygon(origin As Point3d, radius As Double)
    
    
    Dim nVertices As Long
    nVertices = 1000
    Dim vertices() As Point3d
    ReDim vertices(0 To nVertices - 1)
    Dim n As Long
    Dim angle As Double
    For n = 0 To nVertices - 1
      angle = 2 * Pi * n / nVertices
      vertices(n).X = origin.X + radius * Cos(angle)
      vertices(n).Y = origin.Y + radius * Sin(angle)
      vertices(n).Z = 0#
    Next n
    
    Const View1 As Long = 1
    Dim oFence As Fence
    Set oFence = ActiveDesignFile.Fence
    oFence.DefineFromModelPoints View1, vertices
    
    End Sub

    I wrote a demo as if someone wanted to test. I do not understand the solution by Jan. :_(

    demo zoom problem.dgndemo.mvba

Reply
  • I did the test and turned the circle into a polygon, the problem persisted

    code that creates a fence from a polygon

    Sub FencePolygon(origin As Point3d, radius As Double)
    
    
    Dim nVertices As Long
    nVertices = 1000
    Dim vertices() As Point3d
    ReDim vertices(0 To nVertices - 1)
    Dim n As Long
    Dim angle As Double
    For n = 0 To nVertices - 1
      angle = 2 * Pi * n / nVertices
      vertices(n).X = origin.X + radius * Cos(angle)
      vertices(n).Y = origin.Y + radius * Sin(angle)
      vertices(n).Z = 0#
    Next n
    
    Const View1 As Long = 1
    Dim oFence As Fence
    Set oFence = ActiveDesignFile.Fence
    oFence.DefineFromModelPoints View1, vertices
    
    End Sub

    I wrote a demo as if someone wanted to test. I do not understand the solution by Jan. :_(

    demo zoom problem.dgndemo.mvba

Children