iLogic Rule with particular condition not updating the model in factory asset

iLogic Rule with particular condition not updating the model in factory asset

Lokesh-BAE
Contributor Contributor
524 Views
7 Replies
Message 1 of 8

iLogic Rule with particular condition not updating the model in factory asset

Lokesh-BAE
Contributor
Contributor

Hello team,

 

By using Inventor 2021 I'm creating some factory assets. 

 

Created an asset by using the attached assembly model.

In factory layout file, model is not updating properly. Specifically when I enter the "LengthOfTrack" parameter between the 2401 to 2999. 

 

Please refer below code used in iLogic rule "Rule-LengthOfTrack"

ElseIf LengthOfTrack > 2400 And LengthOfTrack < 3000 Then
Parameter("Straight Power And Free Conveyor-PF80 - Chain1:1", "LengthOfTrack") = 1800
Parameter("Straight Power And Free Conveyor-PF80-Chain2:1", "LengthOfTrack") = LengthOfTrack - 1800
Component.IsActive("Straight Power And Free Conveyor-PF80-Chain2:1") = True
Plane_Offset = LengthOfTrack

"Straight Power And Free Conveyor-PF80-Chain2" part length is not updating in assembly. 

 

It would be great help if you can suggest some solution.

Thanks in advance.

 

0 Likes
Accepted solutions (1)
525 Views
7 Replies
Replies (7)
Message 2 of 8

Lokesh-BAE
Contributor
Contributor

Hello team,

 

Please ignore earlier attached files. (My bad..)

And consider the new files attached here for your suggestions.

0 Likes
Message 3 of 8

A.Acheson
Mentor
Mentor

Maybe try using Parameter("LengthOfTrack") instead of LengthOfTrack. You are doing some multiplying with the local parameter and it may not update untill the rule is run twice. Can you check the output after each calculation is what you expect? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 8

Lokesh-BAE
Contributor
Contributor
Hi,
Using Parameter("LengthOfTrack") instead of LengthOfTrack is not working.
There is no any multiplication in the rule. Only divide and minus math functions are there in the rule. All math functions working perfectly except the one mentioned.
Yes. You are correct. If I run the rule again this function too works. Since I'm using this asset in creation of chain assets, I don't want to open all the files and run the rule again manually.
Please extend your suggestion.
0 Likes
Message 5 of 8

A.Acheson
Mentor
Mentor

Ok it sounds like the sub assembly document is not updating. Can you check that value is calculating?

 

Also try these snippets.

First  at the start of the rule to set parameter updating condition.

'Update parameters controlled by parameter function. 
Parameter
.UpdateAfterChange = True

 

 At end of rule. 

'perform some updates on documents and local variables
RuleParametersOutput
() InventorVb.DocumentUpdate()

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 8

Lokesh-BAE
Contributor
Contributor

Hello,

 

Thanks for the suggestions.

These suggestions didn't solved the problem. 

I found a work around. Which solved my issue. 

Wrote a new rule (as below) to rerun the "LengthOfTrack" rule for the condition to which model was not updating. 

If LengthOfTrack > 2400 And LengthOfTrack < 3000 Then
iLogicVb.RunRule("Rule-LengthOfTrack")
End If

Of course updating the parameter's and document update will help.

 

Thanks..

0 Likes
Message 7 of 8

A.Acheson
Mentor
Mentor
Accepted solution

Did you manage to figure out if it is the parameter of the occurrence not updating? I have found that there is a limit to the ilogic access when parameters are too deep / in a sub assembly. The alternate way would be to via the API loop through the occurrences, get occurrence by name then get occurrence definition then parameter and change directly in the document. This article here

and here should have the receipe. Sample below.

 

' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument

    ' Get the assembly component definition.
    Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition

    ' Get all of the leaf occurrences of the assembly.
    Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences

    ' Iterate through the occurrences and print the name.
    Dim oOcc As ComponentOccurrence
    For Each oOcc In oLeafOccs
        If  oOcc.Name = "Name" Then
           
            Dim param As [Parameter] = oOcc.ComponentDefinition.Parameters.Item("Length")
          MessageBox.Show(param.Value)
         End If
    Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 8 of 8

Lokesh-BAE
Contributor
Contributor
Hi,

Parameter of the occurrence is updating.
As I don't know anything about API, I didn't tried the method suggested by you.
It might solve the issue.

Thanks again.
0 Likes