[iLogic] 'rebuild all' error

[iLogic] 'rebuild all' error

matroosoft
Advocate Advocate
3,624 Views
22 Replies
Message 1 of 23

[iLogic] 'rebuild all' error

matroosoft
Advocate
Advocate

Am trying to perform a 'rebuild all' on the active (assembly) document using iLogic, using:

 

ThisApplication.ActiveDocument.Rebuild()

 

It returns "incorrect parameter. Exception from HRESULT: 0x80070057 (E_INVALIDARG))". Also tried to use 'rebuild2', but that gave the same error. What am I doing wrong?

0 Likes
Accepted solutions (2)
3,625 Views
22 Replies
Replies (22)
Message 2 of 23

bradeneuropeArthur
Mentor
Mentor
What version of inventor are you using?

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

Message 3 of 23

matroosoft
Advocate
Advocate

Inventor 2015

0 Likes
Message 4 of 23

bradeneuropeArthur
Mentor
Mentor
what happens when you manually rebuild all?

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

Message 5 of 23

HermJan.Otterman
Advisor
Advisor

what happens if you try this:

 

 

 ThisDoc.Document.rebuild

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 6 of 23

matroosoft
Advocate
Advocate

If I manually click 'rebuild all' then the model rebuilds without any error.

0 Likes
Message 7 of 23

matroosoft
Advocate
Advocate

                what happens if you try this:

 

                [code]

 

It returns the same error if I use that.

0 Likes
Message 8 of 23

bradeneuropeArthur
Mentor
Mentor
could you please provide the complete coding?

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 9 of 23

matroosoft
Advocate
Advocate

This is the complete coding:

 

SyntaxEditor Code Snippet

Sub Main()
    Dim assDoc As AssemblyDocument = ThisDoc.Document

    'If assDoc.ComponentDefinition.Occurrences(2).Definition.Document.LevelOfDetailName = "Master" Then
    '    MsgBox("This logic only works if subassembly 2 is not set to Master Level of Detail")
    '    Exit Sub
    'End If

    If assDoc.ComponentDefinition.Occurrences(1).Suppressed=False Then

        Dim subAssDoc1 As AssemblyDocument = assDoc.ComponentDefinition.Occurrences(1).Definition.Document
        Dim noOfComponentsInSubAssembly1 As Integer = subAssDoc1.ComponentDefinition.Occurrences.Count

        For i = 1 To noOfComponentsInSubAssembly1
            For j = 2 To 25
                If Not assDoc.ComponentDefinition.Occurrences(j).Suppressed Then
                    If subAssDoc1.ComponentDefinition.Occurrences(i).Suppressed Then
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Suppress()
                    Else
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Unsuppress()
                    End If
                End If
            Next
        Next
        
    End If
    
    InventorVb.DocumentUpdate()
    
    If assDoc.ComponentDefinition.Occurrences(26).Suppressed=False Then

        Dim subAssDoc26 As AssemblyDocument = assDoc.ComponentDefinition.Occurrences(26).Definition.Document
        Dim noOfComponentsInSubAssembly26 As Integer = subAssDoc26.ComponentDefinition.Occurrences.Count

        For i = 1 To noOfComponentsInSubAssembly26
            For j = 27 To 50
                If Not assDoc.ComponentDefinition.Occurrences(j).Suppressed Then
                    If subAssDoc26.ComponentDefinition.Occurrences(i).Suppressed Then
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Suppress()
                    Else
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Unsuppress()
                    End If
                End If
            Next
        Next
        
    End If
    
    InventorVb.DocumentUpdate()

    If assDoc.ComponentDefinition.Occurrences(51).Suppressed=False Then

        Dim subAssDoc51 As AssemblyDocument = assDoc.ComponentDefinition.Occurrences(51).Definition.Document
        Dim noOfComponentsInSubAssembly51 As Integer = subAssDoc51.ComponentDefinition.Occurrences.Count

        For i = 1 To noOfComponentsInSubAssembly51
            For j = 52 To 75
                If Not assDoc.ComponentDefinition.Occurrences(j).Suppressed Then
                    If subAssDoc51.ComponentDefinition.Occurrences(i).Suppressed Then
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Suppress()
                    Else
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Unsuppress()
                    End If
                End If
            Next
        Next
        
    End If
    
    InventorVb.DocumentUpdate()

    If assDoc.ComponentDefinition.Occurrences(76).Suppressed=False Then

        Dim subAssDoc76 As AssemblyDocument = assDoc.ComponentDefinition.Occurrences(76).Definition.Document
        Dim noOfComponentsInSubAssembly76 As Integer = subAssDoc76.ComponentDefinition.Occurrences.Count

        For i = 1 To noOfComponentsInSubAssembly76
            For j = 77 To 100
                If Not assDoc.ComponentDefinition.Occurrences(j).Suppressed Then
                    If subAssDoc76.ComponentDefinition.Occurrences(i).Suppressed Then
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Suppress()
                    Else
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Unsuppress()
                    End If
                End If
            Next
        Next
        
    End If
    
    InventorVb.DocumentUpdate()

    If assDoc.ComponentDefinition.Occurrences(101).Suppressed=False Then

        Dim subAssDoc101 As AssemblyDocument = assDoc.ComponentDefinition.Occurrences(101).Definition.Document
        Dim noOfComponentsInSubAssembly101 As Integer = subAssDoc101.ComponentDefinition.Occurrences.Count

        For i = 1 To noOfComponentsInSubAssembly101
            For j = 102 To 125
                If Not assDoc.ComponentDefinition.Occurrences(j).Suppressed Then
                    If subAssDoc101.ComponentDefinition.Occurrences(i).Suppressed Then
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Suppress()
                    Else
                        assDoc.ComponentDefinition.Occurrences(j).Definition.Occurrences(i).Unsuppress()
                    End If
                End If
            Next
        Next
        
    End If

    ThisApplication.ActiveDocument.Rebuild()
    ThisApplication.ActiveDocument.Save2
    iLogicVb.UpdateWhenDone = True

End Sub
0 Likes
Message 10 of 23

bradeneuropeArthur
Mentor
Mentor
try this:
ThisApplication.ActiveDocument.Save
'And then:
ThisApplication.ActiveDocument.Rebuild()

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

Message 11 of 23

matroosoft
Advocate
Advocate

Already tried that, but that didn't make any difference unfortunately.

0 Likes
Message 12 of 23

bradeneuropeArthur
Mentor
Mentor
Your assembly is only containing subassemblies?????????

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

Message 13 of 23

bradeneuropeArthur
Mentor
Mentor

Change to this:

assDoc.Update
assDoc.Save
iLogicVb.UpdateWhenDone = True

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

Message 14 of 23

matroosoft
Advocate
Advocate

               Your assembly is only containing subassemblies?????????

 

 

Yes and one of them is patterned using a component pattern.

 

 

                Change to this:

 

                [code]

 

 

The 'update' part doesn't perform a rebuild on the model or am I wrong?

0 Likes
Message 15 of 23

bradeneuropeArthur
Mentor
Mentor
For me it worked.
I have not the same assembly as you have, but this works at least.

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

Message 16 of 23

matroosoft
Advocate
Advocate

For me it doesn't work. Have tried using a save command, which rebuilds the model as well, but saving the assembly is undesirable. I thought if there is a method 'rebuild' or 'rebuild2' at least one of them should work. Anyone else who can point out why it isn't working?

0 Likes
Message 17 of 23

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Can you please check the following:

 

put this piece of code in your assembly file in I logic:

 

ThisApplication.ActiveDocument.Rebuild()

then put this piece of code in your assembly file in VBA:

 

ThisApplication.ActiveDocument.Rebuild()

then please provide me the information if it works in both environments or not 

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

Message 18 of 23

matroosoft
Advocate
Advocate

I've just tested that in VBA, but didn't know how to write the surrounding code. The single line didn't work, it gave me a compile error.

 

I've found something interesting though: I tested the line in a iLogic rule when I opened the concerning assembly without changing anything, and then it worked. Then I tried the same rule after running a configurator plugin (which we use for this assembly). This configurator changes a few parameters of my assembly to default values if I run it. I ran the configurator, then the same iLogic rule didn't work anymore (it gave the aforementioned error).


Is there something known which would prevent running the 'rebuild' method?

 

Edit: found that it has something to do with the complete iLogic rule that I've posted earlier. After running that iLogic rule the rebuild method gives an error. The complete iLogic rule is also triggered by the configurator plugin we use so that's why the rebuild method wouldn't run after running the configurator either.

 

Edit 2: Found the problem:

 

SyntaxEditor Code Snippet

    ThisApplication.ActiveDocument.Save
    ThisApplication.ActiveDocument.Rebuild()

This combination doesn't work. Save2 method neither. Don't ask me why, but removing the line which saves the document, solves the problem. In this case that line isn't necessary so as far as I am concerned it is solved. But this behaviour seem to me as unintended? Maybe a little bug?

0 Likes
Message 19 of 23

bradeneuropeArthur
Mentor
Mentor

For VBA place this in a new module:

 

Public Sub reb()

Call ThisApplication.ActiveDocument.Rebuild
End Sub

please let me know the outcome...

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

Message 20 of 23

matroosoft
Advocate
Advocate

Thanks, tried it but gave the same results as in iLogic code. In a fresh started assembly it does work, but after using the iLogic code to save the document, the same VBA code doesn't run (it gave a invalid argument error).

 

Edit: I've also tested if I could manually click 'rebuild all' after using the iLogic save method, but then Inventor freezes (and doesn't come back to life).

 

Another edit: After the configurator plugin has suppressed/unsuppressed a few items and changed some values the rebuild method again doesn't work. Even with the line with the save method removed. Manually clicking 'rebuild all' does it's job, though it first asks if I want to save the document.

 

Edit 3: weird stuff happening. After manually rebuilding, the iLogic rule runs again without any error. Until I use the save method or the configurator changes a few things. Then the iLogic rule will give an error again.

0 Likes