Bug with checking ErrorManager with VBA?

Bug with checking ErrorManager with VBA?

pball
Mentor Mentor
1,378 Views
9 Replies
Message 1 of 10

Bug with checking ErrorManager with VBA?

pball
Mentor
Mentor

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.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Accepted solutions (2)
1,379 Views
9 Replies
Replies (9)
Message 2 of 10

skyngu
Collaborator
Collaborator
yes, it happened on me. I am not sure if it is a bug.
Autodesk Inventor Professional 2019
0 Likes
Message 3 of 10

Anonymous
Not applicable

ErrorManager is for recorded errors / warnings.

0 Likes
Message 4 of 10

pball
Mentor
Mentor
I don't understand what you are trying to say. Shouldn't an existing error be recorded?
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 5 of 10

thom-g
Advocate
Advocate

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

Message 6 of 10

CattabianiI
Collaborator
Collaborator
Accepted solution

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.

@pball 

Message 7 of 10

greg_fletcher
Participant
Participant

ignore me

0 Likes
Message 8 of 10

pball
Mentor
Mentor
Accepted 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.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 9 of 10

thom-g
Advocate
Advocate

@pball  & @CattabianiI: Nice work arround! It also works with .Net add-ins. Thanks for sharing a solution.

0 Likes
Message 10 of 10

maxim.teleguz
Advocate
Advocate
ThisApplication.CommandManager.ControlDefinitions.Item("AppDesignDoctorCmd").Enabled = True ' or False
0 Likes