iLogic Rule Error

iLogic Rule Error

ethan_howardMMXXV
Collaborator Collaborator
3,270 Views
15 Replies
Message 1 of 16

iLogic Rule Error

ethan_howardMMXXV
Collaborator
Collaborator

Hello everyone,

I've been using this Rule for about a month now and haven't run into any problems until now. Is there a reason that this same rule works in one part but not another?

Capture2.PNG

Capture3.PNG

 Sorry I can't share this file.

Autodesk Inventor Professional 2020
64-Bit Edition
Build: 373, Release: 2020.3.4 - Date: Fri 10/30/2020

0 Likes
Accepted solutions (1)
3,271 Views
15 Replies
Replies (15)
Message 2 of 16

andrewiv
Advisor
Advisor

Without seeing the rule it's impossible to tell what the problem might be.

Andrew In’t Veld
Designer / CAD Administrator

Message 3 of 16

ethan_howardMMXXV
Collaborator
Collaborator

@andrewiv See the attachments. Or I'll copy it here:

"

Error in rule: Wetted_Surfaces, in document: 17041FF3.ipt

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"

and

"System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.Face.get_Appearance()
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)"

0 Likes
Message 4 of 16

ethan_howardMMXXV
Collaborator
Collaborator

Also, here is the Rule:

'code to get the area of each face based on its color
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

Dim oFaces As Faces
oFaces = oPartDoc.ComponentDefinition.SurfaceBodies(1).Faces
    
Dim Colors As Object
Colors = CreateObject("Scripting.Dictionary")
        
Dim oFace As Face
For Each oFace In oFaces
    Colors(oFace.Appearance.DisplayName) = Colors(oFace.Appearance.DisplayName) + oFace.Evaluator.Area
Next
    
For Each Item In Colors
  MessageBox.Show("Color: " & Item & vbLf & "Area: " &Colors(Item) & "cm^2", "Surface Area by Color")
Next

0 Likes
Message 5 of 16

mcgyvr
Consultant
Consultant
Accepted solution

Try this.. Tell us the last "Part X" message you see before getting the errror..

Likely makes it to part 3 but lets see..

Probably something bad about one of the faces.. Hard to tell without seeing the file...

 

You can also throw this at the beginning and see how it does and if there is a face it seems to miss reporting on or whatever. 

On Error Resume Next

 

 

 

'code to get the area of each face based on its color
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

MessageBox.Show("Part 1", "Made it")

Dim oFaces As Faces
oFaces = oPartDoc.ComponentDefinition.SurfaceBodies(1).Faces

MessageBox.Show("Part 2", "Made it")
    
Dim Colors As Object
Colors = CreateObject("Scripting.Dictionary")

MessageBox.Show("Part 3", "Made it")
        
Dim oFace As Face
For Each oFace In oFaces
    Colors(oFace.Appearance.DisplayName) = Colors(oFace.Appearance.DisplayName) + oFace.Evaluator.Area
Next
MessageBox.Show("Part 4", "Made it")
    
For Each Item In Colors
  MessageBox.Show("Color: " & Item & vbLf & "Area: " &Colors(Item) & "cm^2", "Surface Area by Color")
Next

 

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 6 of 16

ethan_howardMMXXV
Collaborator
Collaborator

Part 3 was the last file before the Error.

"

Error in rule: mcfyvr, in document: 17041FF3.ipt

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

"

and

"

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.Face.get_Appearance()
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

"

0 Likes
Message 7 of 16

ethan_howardMMXXV
Collaborator
Collaborator

Capture4.PNG

0 Likes
Message 8 of 16

ethan_howardMMXXV
Collaborator
Collaborator

This is the file structure. Are you leaning towards one of the ipt files being the culprit?

Capture5.PNG

0 Likes
Message 9 of 16

ethan_howardMMXXV
Collaborator
Collaborator

There are no "Recovery" errors in the file:

Capture6.PNG

0 Likes
Message 10 of 16

johnsonshiue
Community Manager
Community Manager

Hi Ethan,

 

The "oFaces" expression needs to be rewritten as the following.

 

oFaces = oPartDoc.ComponentDefinition.WorkSurfaces.Item(1).SurfaceBodies.Item(1).Faces

Many thanks! 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 11 of 16

ethan_howardMMXXV
Collaborator
Collaborator

On "Error Resume Next" worked!!! I tried that for both "Rules". It ran "Part 4" and ran the correct "Surface Area by Color". Very cool! I'm adding that line to my Rule. Thanks man!

0 Likes
Message 12 of 16

ethan_howardMMXXV
Collaborator
Collaborator

@johnsonshiue that did not work. I ran into the same error so I added "On Error Resume Next". It must have run because I didn't receive an error but it didn't display a menu (report).

0 Likes
Message 13 of 16

ethan_howardMMXXV
Collaborator
Collaborator

@johnsonshiue 

Here is your rule with the added text in front:

 

On Error Resume Next
'code to get the area of each face based on its color
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

Dim oFaces As Faces
oFaces = oPartDoc.ComponentDefinition.WorkSurfaces.Item(1).SurfaceBodies(1).Faces
    
Dim Colors As Object
Colors = CreateObject("Scripting.Dictionary")
        
Dim oFace As Face
For Each oFace In oFaces
    Colors(oFace.Appearance.DisplayName) = Colors(oFace.Appearance.DisplayName) + oFace.Evaluator.Area
Next
    
For Each Item In Colors
  MessageBox.Show("Color: " & Item & vbLf & "Area: " &Colors(Item) & "cm^2""Surface Area by Color")
Next 
0 Likes
Message 14 of 16

ethan_howardMMXXV
Collaborator
Collaborator

@johnsonshiue I am willing to try other fixes.

0 Likes
Message 15 of 16

mcgyvr
Consultant
Consultant

@ethan_howardMMXXV wrote:

On "Error Resume Next" worked!!! I tried that for both "Rules". It ran "Part 4" and ran the correct "Surface Area by Color". Very cool! I'm adding that line to my Rule. Thanks man!


@ethan_howardMMXXV  WARNING.... All thats doing is hiding the error and letting the rule continue to run.

Its highly likely that one or more faces are erroring out and being excluded from your final results.

 

You should be able to now see which color isn't being shown in your result messages and then see which faces have that color assigned as potentially give a clue into whats going on with those. 

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 16 of 16

ethan_howardMMXXV
Collaborator
Collaborator

@mcgyvr there are only two colors and both are showing results. Is there a rule to diagnose the surface causing the error? Or can you only diagnose at the part level? We've narrowed it down to "Part 4" as being the problem. I would think that that is the last part in the history tree.

0 Likes