Hi, this is my first post in the Forum. 😊
I have a problem with the Inventor Error Manager. With the example "DisplayErrorsInInventorDialog"
the messages are also displayed. However when I access the sub again another message is added.
This again and again. Now my question: How can I delete the messages in VB.Net? Thanks...
Sub DisplayErrorsInInventorDialog()
' Set a reference to the ErrorManager object
Dim oErrorMgr As ErrorManager
oErrorMgr = MCM_Application.ErrorManager
' Start a message section
Dim oMsgSection1 As MessageSection
oMsgSection1 = oErrorMgr.StartMessageSection
' Start another (nested) message section
Dim oMsgSection2 As MessageSection
oMsgSection2 = oErrorMgr.StartMessageSection
' Add a message
Call oErrorMgr.AddMessage("My third level error", True)
' Adopt the above message under a new message
Call oMsgSection2.AdoptMessages("My second level error", True)
' Adopt the above messages under the top level message
Call oMsgSection1.AdoptMessages("My first level error", True)
' Show the error dialog
Call oErrorMgr.Show("My errors", True, False)
End Sub
Screenshot:
Solved! Go to Solution.
Solved by ServiceRRVWQ. Go to Solution.
Hi @ServiceRRVWQ. You may be looking for this following method:
I assume you could use that at the very end of your code, on a line just before the 'End Sub'.
Wesley Crihfield
(Not an Autodesk Employee)
I just realized that you may need to 'End' those message sections you started, before it will let you 'Clear' them all, but I believe that when you use the MessageSection.AdoptMessages method, that seems to also work like ending that message section, so it may not be needed.
There is also this method for clearing one message section:
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for the feedback. I tried different orders and positions of .ClearMessage.
As soon as I use .ClearMessage I get this error message in VB.Net and the problem remains.
When inventor runs independently I don't get any errors, but the problem persists here too.
Hi @ServiceRRVWQ. I am honestly not super familiar with these, because I have very rarely used them, but am going mostly by what the documentation says about them.
I believe that if you are going to use MessageSection.ClearMessages, it must be used before you use either use MessageSection.AdoptMessages, or before you use MessageSection.End, because all 3 of these will effectively 'terminate' that MessageSection. And do not believe you can not clear the MessageSection once you have already adopted it or ended it, because it has already been terminated. I believe you would have to use the first one I mentioned (ErrorManager.Clear), if you want to clear that whole dialog. However, as the documentation for that 'Clear' method says, it will fail if there are still any 'active' MessageSections, indicated by the ErrorManager.IsMessageSectionActive property. So, if you have already use any of those other methods (AdoptMessages, ClearMessages, End) on every one of the MessageSections you started, they they will all be inactive, and this Clear method should work.
Wesley Crihfield
(Not an Autodesk Employee)
Hey WCrihfield and all other... 😊
Thanks again for your support. I found the error myself.
I have already defined the global, private variable oErrorMgr, oMsgSection1 and oMsgSection2 in the class.
So the .Clear() method didn´t know wich one should be deleted.
See the code:
Public Class Class_InventorErrorManager
'*******************************************************************************
' Handle the instance of Class_InventorErrorManager
'*******************************************************************************
Private Shared _instance As Class_InventorErrorManager
' Set a reference to the ErrorManager object
Private oErrorMgr As ErrorManager = MCM_Application.ErrorManager
' Start a message section
Private oMsgSection1 As MessageSection = oErrorMgr.StartMessageSection
' Start another (nested) message section
Private oMsgSection2 As MessageSection = oErrorMgr.StartMessageSection
...
Now it works without error messages and without duplicate entries. Thanks...
Sub DisplayErrorsInInventorDialog()
' Set a reference to the ErrorManager object
Dim oErrorMgr As ErrorManager
oErrorMgr = MCM_Application.ErrorManager
' Start a message section
Dim oMsgSection1 As MessageSection
oMsgSection1 = oErrorMgr.StartMessageSection
' Start another (nested) message section
Dim oMsgSection2 As MessageSection
oMsgSection2 = oErrorMgr.StartMessageSection
' Add a message
Call oErrorMgr.AddMessage("My third level error", True)
' Adopt the above message under a new message
Call oMsgSection2.AdoptMessages("My second level error", True)
' Adopt the above messages under the top level message
Call oMsgSection1.AdoptMessages("My first level error", True)
' Show the error dialog
Call oErrorMgr.Show("My errors", True, False)
oErrorMgr.Clear()
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.