Execute2 function errors when attempting to regenerate iLogic rules

Execute2 function errors when attempting to regenerate iLogic rules

AlexFielder
Advisor Advisor
727 Views
11 Replies
Message 1 of 12

Execute2 function errors when attempting to regenerate iLogic rules

AlexFielder
Advisor
Advisor

We have this long-standing rule:

 

Sub Main()

Dummyvalue = Update

Dim controlDef As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.RegenAllRules")
controlDef.Execute2(True)

If Component.IsActive("LHC DOOR ASSY") = True Then
	Select Case vision_panel_type
	Case "VP 1"
	VP135LHC()
	Case "VP 2"
	VP135LHC()
	VP24LHC()
	Case "VP 3"
	VP135LHC()
	Case "VP 4"
	VP135LHC()
	VP24LHC()
	Case "VP 5"
	VP135LHC()
	Case "VP 6"
	VP67LHC()
	Case "VP 7"
	VP67LHC()
	End Select
End If

If Component.IsActive("RHC DOOR ASSY") = True Then
	Select Case vision_panel_type
	Case "VP 1"
	VP135RHC()
	Case "VP 2"
	VP135RHC()
	VP24RHC()
	Case "VP 3"
	VP135RHC()
	Case "VP 4"
	VP135RHC()
	VP24RHC()
	Case "VP 5"
	VP135RHC()
	Case "VP 6"
	VP67RHC()
	Case "VP 7"
	VP67RHC()
	End Select
End If

iLogicVb.RunRule("FINISH COLOUR")

iLogicVb.UpdateWhenDone = True

End Sub

Sub VP135LHC()
Dim VP135AssemblyNameLHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP135namepartsLHC As String() = VP135AssemblyNameLHC.Split(New Char() {"-"c})

Dim VP135NameLHC As String
If VP135namepartsLHC.Length = 1 Then
	VP135NameLHC = "LHC Vision Panel Type5 Assy.iam<ilogic>"
Else
	'Set LHC VP4 file name
	VP135NameLHC = VP135namepartsLHC(0)&"-LHC Vision Panel Type5 Assy-"&VP135namepartsLHC(2)&"-"&VP135namepartsLHC(3)&".iam<ilogic>"
End If
'Replace LHCVP4 with ilogic LoD
Component.Replace("LHC VP5 ASSY", VP135NameLHC, True)
End Sub

Sub VP135RHC()
Dim VP135AssemblyNameRHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP135namepartsRHC As String() = VP135AssemblyNameRHC.Split(New Char() {"-"c})

Dim VP135NameRHC As String
If VP135namepartsRHC.Length = 1 Then
	VP135NameRHC = "RHC Vision Panel Type5 Assy.iam<ilogic>"
Else
	'Set LHC VP4 file name
	VP135NameRHC = VP135namepartsRHC(0)&"-RHC Vision Panel Type5 Assy-"&VP135namepartsRHC(2)&"-"&VP135namepartsRHC(3)&".iam<ilogic>"
End If
'Replace LHCVP4 with ilogic LoD
Component.Replace("RHC VP5 ASSY", VP135NameRHC, True)
End Sub

Sub VP24LHC()
Dim VP24AssemblyNameLHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP24namepartsLHC As String() = VP24AssemblyNameLHC.Split(New Char() {"-"c})

Dim VP24NameLHC As String
If VP24namepartsLHC.Length = 1 Then
	VP24NameLHC = "LHC Vision Panel Type4 Assy.iam<ilogic>"
Else
	'Set LHC VP4 file name
	VP24NameLHC = VP24namepartsLHC(0)&"-LHC Vision Panel Type4 Assy-"&VP24namepartsLHC(2)&"-"&VP24namepartsLHC(3)&".iam<ilogic>"
End If
'Replace LHCVP4 with ilogic LoD
Component.Replace("LHC VP4 ASSY", VP24NameLHC, True)
End Sub

Sub VP24RHC()
Dim VP24AssemblyNameRHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP24namepartsRHC As String() = VP24AssemblyNameRHC.Split(New Char() {"-"c})

Dim VP24NameRHC As String
If VP24namepartsRHC.Length = 1 Then
	VP24NameRHC = "RHC Vision Panel Type4 Assy.iam<ilogic>"
Else
	'Set RHC VP4 file name
	VP24NameRHC = VP24namepartsRHC(0)&"-RHC Vision Panel Type4 Assy-"&VP24namepartsRHC(2)&"-"&VP24namepartsRHC(3)&".iam<ilogic>"
End If
'Replace RHCVP4 with ilogic LoD
Component.Replace("RHC VP4 ASSY", VP24NameRHC, True)
End Sub

Sub VP67LHC()
Dim VP67AssemblyNameLHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP67namepartsLHC As String() = VP67AssemblyNameLHC.Split(New Char() {"-"c})

Dim VP67NameLHC As String
If VP67namepartsLHC.Length = 1 Then
	VP67NameLHC = "LHC Vision Panel Type67 Assy"
Else
	'Set LHC VP4 file name
	VP67NameLHC = VP67namepartsLHC(0)&"-LHC Vision Panel Type67 Assy-"&VP67namepartsLHC(2)&"-"&VP67namepartsLHC(3)&".iam<ilogic>"
End If
'Replace LHCVP4 with ilogic LoD
Component.Replace("LHC VP 67 ASSY", VP67NameLHC, True)
End Sub

Sub VP67RHC()
Dim VP67AssemblyNameRHC As String = ThisDoc.FileName(False) 'without extension
' Split string based on spaces
Dim VP67namepartsRHC As String() = VP67AssemblyNameRHC.Split(New Char() {"-"c})

Dim VP67NameRHC As String
If VP67namepartsRHC.Length = 1 Then
	VP67NameRHC = "RHC Vision Panel Type67 Assy.iam<ilogic>"
Else
	'Set LHC VP4 file name
	VP67NameRHC = VP67namepartsRHC(0)&"-RHC Vision Panel Type67 Assy-"&VP67namepartsRHC(2)&"-"&VP67namepartsRHC(3)&".iam<ilogic>"
End If
'Replace LHCVP4 with ilogic LoD
Component.Replace("RHC VP 67 ASSY", VP67NameRHC, True)
End Sub

that runs normally when you manually activate it, but the following line (in red) fails when the update parameter is changed either manually or as the result of the addin that's designed to automate the assembly from my other recent thread here.

 

Dim controlDef as ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.RegenAllRules")
controlDef.Execute2(True)

This appears to be a bug or some other error because the error that Inventor gives is thus:

(See screencast)

 

Thoughts?

 

0 Likes
728 Views
11 Replies
Replies (11)
Message 2 of 12

AlexFielder
Advisor
Advisor

Stupid "Insert" button is stupid.

 

 

Why doesn't this work straight away!? ARRRRRGGGGHHHH!

 

https://knowledge.autodesk.com/community/screencast/e3310ca4-5b72-488c-a642-176e8dc6b321

 

Smiley Frustrated

0 Likes
Message 3 of 12

bradeneuropeArthur
Mentor
Mentor

what if you use:

 

controlDef.Execute

 

or

 

controlDef.Execute2(false)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 12

AlexFielder
Advisor
Advisor

In news that will come as no surprise to anyone watching...

 

Of course it runs when you use:

controlDef.Execute2(False)

As well as:

controlDef.Execute

I'm not sure what/why it needed to be there at all as the code I'm working with isn't documented.

 

Ho hum.

0 Likes
Message 5 of 12

AlexFielder
Advisor
Advisor

After experimenting with just using

controlDef.Execute2(False)

it doesn't work as the rules are "regenerated" out of the usually expected order. In the context of our solution, this means that a doorset which usually has 4 vision panels (two on each door) we end up instead with only 3 (two on one, one on the other).

 

?

0 Likes
Message 6 of 12

chandra.shekar.g
Autodesk Support
Autodesk Support

@AlexFielder ,

 

Please provide dataset to reproduce the error and make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 12

YuhanZhang
Autodesk
Autodesk

Hi Alex,

 

The error happens in your iLogic rule but not the ControlDefinition.Execute, the Execute will just run all the iLogic rules embedded in your document, from the error dialog seems it is the iLogic rule "REGEN RULES" in the document "Configuration Top Level Assembly.iam" raised the error. So you can run the rule directly to see the error, and from the More Info tab you can see detailed info about the error and you need to fix it.

 

Hope this clears.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 8 of 12

AlexFielder
Advisor
Advisor

These are the dialogues I see:

 

2019-01-31 09_18_32-Error in rule_ REGEN RULES, in document_ Configuration Top Level Assembly.iam.png2019-01-31 09_18_10-Parameters.png

 

I have no idea how to fix "unspecified error". Attached is an assembly that this happens in.

 

Steps to reproduce:

1. Unzip assembly

2. Set active project to included .ipj

3. Open Door_Assembly_Example.iam

4. Edit/change Rating Parameter to one of the other options.

5. Scratch head when error appears.

6. Exclaim "that's not supposed to happen".

 

 

 

 

0 Likes
Message 9 of 12

YuhanZhang
Autodesk
Autodesk

I can reproduce the problem, when just run the rule "REGENRULES" in the Door_Assembly_Example.iam no problem, but change the parameter Rating will cause the error. And in the rule "REGENRULES" you just re-gerenate all the rules, I think it may cause to re-generate the rule itself and so lead endless cycle.  Seems you just want to run the rules "ChangeRating" & "ChangeWallThickness" when the parameters change, if so how about you place the rules to the Event Triggers like below and suppress the "REGENRULES":

 

EventTrigger.png



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 10 of 12

JaneFan
Autodesk
Autodesk

Hi @AlexFielder , 

 

There is an iLogic issue here that the rule with Execute "regenerate all rule commands" fails when the rule is triggered by iLogic event trigger, or triggered by parameter change in current document, even though it can run pass directly without event trigger.  We'll get it tracked. 

Dim controlDef As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.RegenAllRules")
controlDef.Execute2(true)

Meanwhile, I see from your model(Door_Skeleton.ipt) that there is a rule named as "REGEN RULES", too, which can work well anytime the model parameter is changed by parameter in assembly level. 

If you suppress the rule REGENRULES in top assembly level, and do steps to change parameter as you mentioned in top assembly, we can see the REGEN RULES (in Door_Skeleton.ipt) is triggered and executed successfully. 

I got log information like this: 

TRACE|Entering rule: ChangeRating (in Door_Assembly_Example.iam)
TRACE|Trigger: Rating (Door_Assembly_Example.iam) = 30 ul
TRACE|Exiting rule: ChangeRating (in Door_Assembly_Example.iam)
TRACE|Entering rule: REGEN RULES (in Door_Skeleton.ipt)
TRACE|Trigger: FireRating (Door_Skeleton.ipt) = 30 ul
DEBUG|controlDef.Execute fired
TRACE|Exiting rule: REGEN RULES (in Door_Skeleton.ipt)

 

Can this be a possible work around for you? 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 11 of 12

AlexFielder
Advisor
Advisor

I await details of the bug ticket.

 

I have found a workaround of my own that we'll be testing over the weekend.

0 Likes
Message 12 of 12

JaneFan
Autodesk
Autodesk

Hi @AlexFielder ,

 

The issue ID is INVGEN-25825 in the system with mentioninng this topic.




Jane Fan
Inventor/Fusion QA Engineer
0 Likes