I just want to see if anyone else has this issue or if anyone knows if this is normal before I submit a real bug report.
I try and check drawings for errors before exporting them with a script but my function never catches drawings with errors. I just did a little test and found a weird behavior. I took a dimensioned drawing and moved a dimension off the part and accepted the warning that the dimension was unattached to geometry. Then I ran the line of code shown below in the VBA editor Immediate window and it returned True. I then switched to another open part and then back to the drawing with the unattached dimension. The code below now returns False. The design doctor icon is still a red cross and the error is still present but the errormanager api has apparently been reset and won't show any warnings.
debug.Print ThisApplication.ErrorManager.HasWarnings
The error manager also will not report errors when a drawing is opened and already has an error. It apparently only returns errors when the error occurs while the drawing is open and the drawing has been active since the error occurred.
Solved! Go to Solution.
Solved by pball. Go to Solution.
Solved by CattabianiI. Go to Solution.
Hi @pball, I know, it is an old thread, but I got the same problem.
The ErrorManager seems only to record errors who occured inside a transaction in your own add-in (or VBA).
The property we need does not exist yet.
You can support this idea if you like: https://forums.autodesk.com/t5/inventor-ideas/new-property-for-existing-errors/idi-p/8868254
I got the same problem and I came up with this workaround:
For Each cc As CommandControl In ThisApplication.UserInterfaceManager.Ribbons.Item("Drawing").QuickAccessControls
If cc.DisplayName.ToUpperInvariant = "DESIGN DOCTOR" Then
Return cc.ControlDefinition.Enabled
End If
Next
Clearly InternalName is better than DisplayName and I didn't test if it works when the red cross is not visible.
Let me know if there are some drawbacks.
Implementation of your Idea would be the better solution.
Haven't implemented this yet in any of my printing or exporting scripts yet but my initial testing looked good. It doesn't matter if the design doctor is shown or not in the quick access controls. I also played around to shorten up the code some more.
ThisApplication.UserInterfaceManager.Ribbons.Item("Drawing").QuickAccessControls.Item("AppDesignDoctorCmd").ControlDefinition.Enabled
Thanks @CattabianiI for finding and sharing this.
ThisApplication.CommandManager.ControlDefinitions.Item("AppDesignDoctorCmd").Enabled = True ' or False