Docker redraw not working after sort

I'm working on a script to sort elements in the objects docker (and on the page as well of course) I've tried both Optimization and EventsEnabled and both work on the page BUT the property docker does not update unless I click on another drawing tab and then back again - or save the drawing and reload.

This is using CD ver 2019

Here's the code:(and this is pretty basic - I need to make a proper bubble sort)

Sub ShapeSort()
Dim i As Integer, j As Integer, k As Integer, m As Integer, One As Shape, Two As Shape
Dim sr As ShapeRange
Set sr = ActiveLayer.FindShapes       'all types
m = 10 * sr.Count
Optimization = True
For k = 1 To m
For i = 1 To sr.Count
For j = i + 1 To sr.Count
Set One = sr(i)
Set Two = sr(j)
If One.Type > Two.Type Then
Two.OrderForwardOne
End If
Next j
Next i
Next k
Optimization = False
ActiveWindow.Refresh
Application.Refresh
End Sub

Parents
No Data
Reply
  • Did you try DoEvents? Event working with EventsEnabled the form refreshing it may not be done without DoEvents...

    If you run code line by line (F8) without Optimization, do you see the docker window updated after each sort?

    See the next slightly adapted code:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    Sub ShapeSort()
    Dim i As Integer, j As Integer, k As Integer, m As Integer, One As Shape, Two As Shape
    Dim sr As ShapeRange
    Set sr = ActiveLayer.FindShapes       'all types
    m = 10 * sr.Count
    Optimization = True
    For k = 1 To m
    	For i = 1 To sr.Count
    		For j = i + 1 To sr.Count
    			Set One = sr(i)
    			Set Two = sr(j)
    			If One.Type > Two.Type Then
    				Two.OrderForwardOne
    			End If
    			DoEvents
    		Next j
    	Next i
    Next k
    
    Optimization = False
    ActiveWindow.Refresh
    Application.Refresh
    End Sub
    
Children
No Data