Read out error message of designdoctor

Read out error message of designdoctor

Anonymous
Not applicable
1,036 Views
13 Replies
Message 1 of 14

Read out error message of designdoctor

Anonymous
Not applicable

Hi all ,

 

I would like to read out the messeges txt whats given by designdoctor sign (for childs files of an assy).

 

I tried this  :

 

Dim em As ErrorManager = ThisApplication.ErrorManager
	
MessageBox.Show(em.AllMessages)

The all mMesseges should give me a xml file as string whith all messages i supose.
It returns me just : <ErrorsAndWarnings/> as a string (not content)

Can anyone help me with this please ?

Kind regards,

0 Likes
Accepted solutions (2)
1,037 Views
13 Replies
Replies (13)
Message 2 of 14

WCrihfield
Mentor
Mentor

Can you provide an example scenario and/or a non-confidential file to test possible solutions on?

When you use the ErrorManager.AllMessages, it will normally show you a series of error messages and warnings in a long string, separated into sections using XML tags.  But if there hasn't been any error messages and/or warnings prior to calling it, it will only show the one 'self contained' XML tag.

And unfortunately much of the Design Accelerator tools (contents of the Design tab while in an assembly), aren't fully accessible/functional through the API yet.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 14

Anonymous
Not applicable

@WCrihfield ,

 

 As you can see i want to capture the error message on a  :

 * Assembly level , like constrain problems as example. 

or

 * partlevel , the failed extrusion description (as example) 

 

see schreenshot as example

mizo303_0-1598276103950.png

I attached also the files with the rules

 

So at the end i would like to loop over all childs of an assembly and check if there is an error and add it to a list that i could read out (filename ; error)

 

Kind regards,

 

 

0 Likes
Message 4 of 14

JhoelForshav
Mentor
Mentor

Hi @Anonymous 

The ErrorManager only takes into account errors created by the same rule in which it's used. So no already existing errors will be in ErrorManager.AllMessages.

 

I did some testing creating a hole that has no effect with iLogic. Then I get information about the error with ErrorManager.AllMessages. If I left the error unattended and just ran a rule with the line:

MsgBox(ThisApplication.ErrorManager.AllMessages)

I got nothing, just like you...

 

There is an Idea requesting an object that handles existing errors here. But there are not many votes for it 😞

https://forums.autodesk.com/t5/inventor-ideas/new-property-for-existing-errors/idi-p/8868254

 

0 Likes
Message 5 of 14

Anonymous
Not applicable

@JhoelForshav  ,

 

i already reached a workarround that just give me a status  (true/false) of a child that obtains the error .

 

AssyError = ThisApplication.UserInterfaceManager.Ribbons.Item("Assembly").QuickAccessControls.Item("AppDesignDoctorCmd").ControlDefinition.Enabled
PartError = ThisApplication.UserInterfaceManager.Ribbons.Item("Part").QuickAccessControls.Item("AppDesignDoctorCmd").ControlDefinition.Enabled

But unfortunately no content desription as you wrote ?

 

Kind regards,

0 Likes
Message 6 of 14

JhoelForshav
Mentor
Mentor

@Anonymous 

What I tried to explain was that the ErrorManager only works if the code itself is the cause of the error.

If the error already exist prior to the code being run, It'll return nothing....

 

See attached ipt as an example. First run Rule1 and you'll get a correct error message. If you just leave the error there and then run Rule2 you'll not get any error message...

 

Message 7 of 14

Anonymous
Not applicable

@JhoelForshav ,

Could not open the file correct  , i work with inventor 2019.4.8 

It try to create a derived part ...

 

Otherwise Can you give me the 2 rules please ?

 

kind regards

0 Likes
Message 8 of 14

WCrihfield
Mentor
Mentor

Just demonstrating the already established fact that if an error is caused by your rule, while your rule us running, it will generate an error message that you can read with the above mentioned method.  But if the error existed before you ran the rule, and the error didn't happen as a result of the current rule, the above mentioned method, it will not retrieve that data.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 14

JhoelForshav
Mentor
Mentor

@mizo303 

See screencast below.

In the first rule, I create a hole that has no effect (This gives an error in Design Doctor). Then in the same rule i use ErrorManager.AllMessages - It returns error messages.

 

Then i Run the second rule, that only has one line:

MsgBox(ThisApplication.ErrorManager.AllMessages)

This returns no error messages. That is because ErrorManager can only "Record" errors caused by the same rule that it's being used in. That's just the way it is.

 

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Message 10 of 14

Anonymous
Not applicable

@JhoelForshav  ,

 

This is clear now for me , many thanks !

The error could only be captured when it's caused inside the rule itself. (recorded flow)

 

Another question  :

Sometimes i have a unexpected error in a rule , then it pops up a message box and it stops generating my model .

Can this message be logged ?

 

Example :

mizo303_0-1598356368933.jpeg

 

Kind regards,

 

 

 

 

0 Likes
Message 11 of 14

JhoelForshav
Mentor
Mentor

@Anonymous 

You can catch errors with a try-catch block. Run this rule as an example 🙂

 

Dim oError As String
Try
	ThisApplication.Documents.Open("THIS_IS_NOT_A_VALID_PATH")
Catch Ex As Exception
	oError = Ex.Message
End Try
MsgBox("Code continues...")
MsgBox(oError)
Message 12 of 14

JhoelForshav
Mentor
Mentor
Accepted solution

Or to catch multiple errors:

Sub Main
On Error GoTo ErrorHandling
	
Dim oErrors As String
ThisApplication.Documents.Open("THIS_IS_NOT_A_VALID_PATH")
Dim oDoc = ThisApplication.Documents.ItemByName("NO DOCUMENT")
MsgBox("Code continues...")
MsgBox(oErrors)
Exit Sub
ErrorHandling:
oErrors = oErrors &  Err.Description & vbCrLf & vbCrLf
Resume Next
End Sub
0 Likes
Message 13 of 14

WCrihfield
Mentor
Mentor

There are several ways to log error messages.

One of the newer ways (since Inventor 2019, I think) is to use the iLogic Log (it has its own tab beside Model tab & iLogic tab, to view logged messages, when used.).

Within the iLogic rule editor dialog > Snippets > System tab > Log Messages - contains example lines of code you can insert for using these.  There are several levels to which types of messages you want the log to keep track of, if any.

 

Another way, similar to the 'AllMessages' is this:

Dim oExLog As ExceptionsLog =  iLogicVb.Automation.RuleExceptionsLog

 There are others too, as Joel mentioned.  If you search "vb.net errors" you will find several ways to deal with them.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 14

Anonymous
Not applicable
Accepted solution

Hi All ,

 

Thanks a lot for all the possibilities  , it gives me a way to go on for now !

 

kind regards