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 ShapeDim sr As ShapeRangeSet sr = ActiveLayer.FindShapes 'all typesm = 10 * sr.CountOptimization = TrueFor k = 1 To mFor i = 1 To sr.CountFor j = i + 1 To sr.CountSet One = sr(i)Set Two = sr(j)If One.Type > Two.Type ThenTwo.OrderForwardOneEnd IfNext jNext iNext kOptimization = FalseActiveWindow.RefreshApplication.RefreshEnd Sub
I am seeing this behavior in 2019 with my VBA macros, too.
The macros do their job, but the changes aren't immediately shown in the Objects docker. This is not good!
If I close / open the Objects docker, then it updates to show the changes.
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:
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
Optimization = False