Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Inventor ErrorManager issue

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ServiceRRVWQ
186 Views, 5 Replies

Inventor ErrorManager issue

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:

ServiceRRVWQ_0-1714048396513.png

 

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: ServiceRRVWQ

Hi @ServiceRRVWQ.  You may be looking for this following method:

ErrorManager.Clear 

I assume you could use that at the very end of your code, on a line just before the 'End Sub'.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6
WCrihfield
in reply to: ServiceRRVWQ

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.

MessageSection.End 

There is also this method for clearing one message section:

MessageSection.ClearMessages 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 6
ServiceRRVWQ
in reply to: ServiceRRVWQ

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.

 

ServiceRRVWQ_0-1714059298328.png

 

 

Message 5 of 6
WCrihfield
in reply to: ServiceRRVWQ

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

EESignature

(Not an Autodesk Employee)

Message 6 of 6
ServiceRRVWQ
in reply to: WCrihfield

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report