iLogic Subassembly (rule) doesn't update unless you open and re-run rule

iLogic Subassembly (rule) doesn't update unless you open and re-run rule

Anonymous
Not applicable
1,003 Views
1 Reply
Message 1 of 2

iLogic Subassembly (rule) doesn't update unless you open and re-run rule

Anonymous
Not applicable

I have an assembly compossed of several subassemblies.  

 

- "A" --> top level assembly

            - "C1" -->subassembly

            - "C2" -->subassembly

            - "C3" -->subassembly

 

These subassemblies (C1, C2, C3,.. etc) have iLogic code in a rule that performs component replaces (Component.Replace) based on certain user parameter(s).  These parameter(s) are referenced in my top "A" level assembly.  I know that the parameter(s) are linked properly because if I change the parameter(s) in the "A" level assembly it automatically updates the linked parameter(s) in the "C" level subassemblies.

 

My problem is that updating the parameter(s) in my "A" level top assembly does not update the assembly meaning it does not perform the component replace as it should.  The parameter(s) are updated but the rule either didn't run or didn't run correctly.  However if open up that "C" level subassembly and run the rule which contains the replace component code then it updates.  I have noticed that if I open up the form in the "A" level top assembly that I use to drive my parameter(s) and click over to the "C" level subassembly and change the form (parameters) then the subassembly updates correctly as it should.  So it seems like the subassembly doesn't update because it isn't the active window or whatever you call the current model you're looking at.

 

I tried document updates (InventorVb.DocumentUpdate()) and Rebuilding (ThisApplication.ActiveDocument.Rebuild2 (True)) and neither seem to make a difference.  I tried adding event triggers that run the rule when "Any Model Parameter Change" with no luck.

 

I came across this post which sounds very similar to my problem but I don't think my problem has anything to do with LOD.  😕

http://forums.autodesk.com/t5/inventor-customization/ilogic-subassemblies-won-t-update-unless-in-the...

 

This is the error that I get when I update the parameter(s) in the "A" level top assembly:

 

Error in rule: LAYOUT, in document: 10 FT.iam

Component: The component named "Nothing" was not found.

 

The "C" level subassembly is called "10 FT"

The rule in my "C" level subassmbly is called "LAYOUT"

 

'ROPE COMPENSATION HITCH component replace
Dim zAsmCompDef As AssemblyComponentDefinition
zAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim zOccurrence As ComponentOccurrence
Dim zName As String
For Each zOccurrence In zAsmCompDef.Occurrences
    zName = zOccurrence.Name
    If Left(zName,6)="C54598" Or Left(zname,6)="C54599" Then
    Existing_HITCH=zName
    End If
Next

Dim COMP_HITCH As String

Select Case ROPES
    Case "7":
        COMP_HITCH="C54598"
    Case "9":
        COMP_HITCH="C54599"
    End Select
    
Select Case WRG
    Case "36 IN"
        COMP_HITCH=COMP_HITCH+"001"
    Case "42 IN"
        COMP_HITCH=COMP_HITCH+"002"
    Case "48 IN"
        COMP_HITCH=COMP_HITCH+"003"
    Case "60 IN"
        COMP_HITCH=COMP_HITCH+"004"
    End Select

If Left(Existing_HITCH,9) <> COMP_HITCH Then
Component.Replace(Existing_HITCH, COMP_HITCH+".iam",True)
End If

ThisApplication.ActiveDocument.Rebuild2 (True)
InventorVb.DocumentUpdate()

I'm not sure where component named "Nothing" is coming from.  Maybe since there is an error in the rule it at least means that its attempting to run the rule but an error keeps occuring.

 

Help a young inexperienced engineer out here.  Any help would be awesome and very welcome.

0 Likes
1,004 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor

You might need to open the actual file and update there rather than just working with occurrences.

 

It could also be issues within the settings for how the iLogic rules run.

 

Just using the ActiveDocument.Update or whatever it is may not be enough. 

 

I know I've always run into issues with accessing occurrences regardless of what I'm trying to accomplish.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes