Are there any existing Macros to find any and all live Dynamic Dimensions and turn them off? I work for a sign company that requires I work with multiple pages with multiple elevations at multiple scales. I have my dimensions set to be automatically off (not dynamic) after I use them, so when a client requires an increase in the size of the sign all I have to do is turn them back on, increase the size and then turn them back off. This system works most of the time, however mistakes happen and sometimes I forget to turn the Dynamic Dimensions off and thus when I change the global scale on a separate elevation that one dimension would then be wrong.
This is why I would love a macro that could check my entire document, and flag all the still live dynamic dimensions. Another option would be a macro that automatically turns of all dynamic dimensions when pressed. I would then use this system page by page. I understand there are similar macros that will automatically break dimensions apart, however if at all possible I would love to just keep them live but still in the off position.
Obviously the perfect solution would be for Corel to let users set the scale per page, but seeing how people have been asking for this for 7+ years... I don't even get my hopes up for that anymore.
For stability I use X6, However I do use and have access to CorelDraw 18 as well.
This is my first time posting on the forum, so thank you to everyone who has helped me solve a problem in the past!
This way of doing it is sort of ugly, but in my limited testing, it seems to work. I have it excluding individually locked objects and objects on locked layers:
Sub set_dims_non_dynamic() Dim srDynamic As ShapeRange Dim s As Shape On Error GoTo ErrHandler Set srDynamic = ActivePage.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True' and @com.locked = 'False' and @com.layer.editable = 'True'") For Each s In srDynamic s.CreateSelection Application.FrameWork.Automation.InvokeItem "fdaf006a-eeb2-38bb-409b-40b9c7abac44" Next s srDynamic.CreateSelection MsgBox "Number of dimensions changed to non-dynamic: " & srDynamic.Count ExitSub: Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "set_dims_non_dynamic()", vbCritical Resume ExitSub End Sub
Here is one that uses the same criteria for finding objects, but doesn't change them; just selects them.
Sub select_dynamic_dims() Dim srDynamic As ShapeRange On Error GoTo ErrHandler Set srDynamic = ActivePage.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True' and @com.locked = 'False' and @com.layer.editable = 'True'") If srDynamic.Count > 0 Then srDynamic.CreateSelection Else MsgBox "No selectable dynamic dimensions were found." End If ExitSub: Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "select_dynamic_dims()", vbCritical Resume ExitSub End Sub
Here's a link to a .zip file that contains a .GMS file with those two subs in it:
JQ_dynamic_dims_2019_08_23_1636.zip
.
Instead of changing my first post, I'll add this as a new one. As before, I have it excluding individually locked objects and objects on locked layers: This version has three subs in it:
JQ_dynamic_dims_2019_08_23_1804.zip
The code looks like this now:
Option Explicit Sub select_dynamic_dims() Dim srDynamic As ShapeRange On Error GoTo ErrHandler If Not ActiveDocument Is Nothing Then Set srDynamic = ActivePage.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True' and @com.locked = 'False' and @com.layer.editable = 'True'") If srDynamic.Count > 0 Then srDynamic.CreateSelection Else ActiveDocument.ClearSelection MsgBox "No selectable dynamic dimensions were found." End If Else MsgBox "No document is active." End If ExitSub: Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "select_dynamic_dims()", vbCritical Resume ExitSub End Sub Sub set_dims_non_dynamic_current_page() Dim lngChangedCount As Long On Error GoTo ErrHandler If Not ActiveDocument Is Nothing Then set_dims_non_dynamic_page ActivePage, lngChangedCount MsgBox "Number dimensions changed to non-dynamic: " & lngChangedCount Else MsgBox "No document is active." End If ExitSub: Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "set_dims_non_dynamic()", vbCritical Resume ExitSub End Sub Sub set_dims_non_dynamic_all_pages() Dim pageRemembered As Page Dim pageThis As Page Dim lngChangedCountPage As Long Dim lngChangedCountTotal As Long On Error GoTo ErrHandler If Not ActiveDocument Is Nothing Then Set pageRemembered = ActivePage For Each pageThis In ActiveDocument.Pages set_dims_non_dynamic_page pageThis, lngChangedCountPage lngChangedCountTotal = lngChangedCountTotal + lngChangedCountPage Next pageThis pageRemembered.Activate MsgBox "Total number of dimensions changed to non-dynamic (all pages): " & lngChangedCountTotal Else MsgBox "No document is active." End If ExitSub: Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "set_dims_non_dynamic_all_pages()", vbCritical Resume ExitSub End Sub Sub set_dims_non_dynamic_page(ByRef Page As Page, Optional ByRef ChangedCount As Long) Dim srDynamic As ShapeRange Dim s As Shape On Error GoTo ErrHandler Page.Activate Set srDynamic = ActivePage.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True' and @com.locked = 'False' and @com.layer.editable = 'True'") For Each s In srDynamic s.CreateSelection Application.FrameWork.Automation.InvokeItem "fdaf006a-eeb2-38bb-409b-40b9c7abac44" Next s ChangedCount = srDynamic.Count ExitSub: Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "set_dims_non_dynamic_page()", vbCritical Resume ExitSub End Sub
I like Mek's use of .SetProperties as a more elegant workaround than what I had used (using InvokeItem to "press the button" to toggle the status of selected dynamic text). Doing it with .SetProperties lets me use a CommandGroup so that multiple operations performed by the macro show up as a single entry in the Undo list.
I reworked my code to use the .SetProperties approach, and put it into a function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Function set_dim_dynamic_status(ByRef DimensionShape As Shape, ByVal DynamicStatus As Boolean) As Long On Error GoTo ErrHandler If Not DimensionShape.Dimension.DynamicText = DynamicStatus Then 'try to set the status DimensionShape.Style.GetProperty("dimension").SetProperty "dynamicText", DynamicStatus 'check the status If DimensionShape.Dimension.DynamicText = DynamicStatus Then 'successful set_dim_dynamic_status = 1 Else 'not successful set_dim_dynamic_status = -1 End If Else 'property already has the desired status set_dim_dynamic_status = -2 End If ExitFunc: Exit Function ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "set_dim_dynamic_status()", vbCritical Resume ExitFunc End Function
Here's a link to my latest offering for this:
JQ_dynamic_dims_2019_08_24_2145.zip.
I've added some subs to cover things more comprehensively. Any of those subs can be put on a toolbar or menu, or have a keyboard shortcut assigned to it, by using regular CorelDRAW workspace customization.
For the sort of work you describe, I would guess that the three subs I highlighted in that screenshot would be the most useful.
The sub to make all dimensions dynamic on all pages is one that you might never want to use!
Eskimo! In Corel 2018 this is everything I ever wanted and more. I certainly can see my self having shortcut keys for all of the options you highlighted, as well as select dynamic dim. I could hot key select dynamic dims before I leave a page or change scale and the peace of mind of the "no dynamic dimensions were found" message would be perfect. Then if it did find a dynamic dimension, I would simply hot key them off and boom! I'm on my way!
The only problem I ran into when testing, is that I don't think this is compatible with the X6 version of corel. Unfortunately due to stability, I do the majority of my work on X6. If there is any way you have an X6 version of your latest list of subs I would be forever grateful!
EvanEBunn said:The only problem I ran into when testing, is that I don't think this is compatible with the X6 version of corel.
By "incompatible", do you mean that you don't see the subs at all when you install the .GMS file for X6? Or do you see the subs in the Macro Manager, but they don't function the way that they do in 2018?
I just didn't see the subs anywhere when I went to set hotkeys and drag the macro to my toolbar. Maybe I am looking in the wrong place?
EvanEBunn said:I just didn't see the subs anywhere when I went to set hotkeys and drag the macro to my toolbar. Maybe I am looking in the wrong place?
Thank you. The .GMS file was saved from X7, and that may be the problem.
You can try this version: JQ_dynamic_dims_from_X5_2019_08_26_1131.zip.
I can't test your exact situation, because I have X5 and X7, but not X6. I know that some things changed between X5 and X7, but I don't know exactly when they changed.
What's really ugly here is that some of the "old ways" of working with dimensions don't work in more recent versions of CorelDRAW. In many cases, bringing code forward to newer versions is painless, but this is an exception.
When you have a chance to try this, please let me know:
Your X5 version works perfectly! I can not thank you enough for all of your help!
Super! I'm glad to hear that it works in X6.
For the sake of any X5 user who finds this thread, I'll point out that the code in that "X5" version of the macro did not actually work when I tried it in X5!
I only used X5 as a way of getting the code into a .GMS file that you could use in X6.