Is there a quick way to add THOUSANDS of occurrences to an assembly?

Is there a quick way to add THOUSANDS of occurrences to an assembly?

bshbsh
Collaborator Collaborator
708 Views
11 Replies
Message 1 of 12

Is there a quick way to add THOUSANDS of occurrences to an assembly?

bshbsh
Collaborator
Collaborator

Hey,

I need to add a LOT of files from a folder structure and put them into an assembly. It doesn't matter how or where, they just need to be in it. 4-5000 individual files, and growing. Some are iam's, most are just ipt's.

Usually I do this by filtering the files needed in Total Commander, then drag'n'drop the list into an empty assembly. This works somewhat,m but it is super slow and clogs the entire machine (I guess it's way too much dde commands to interpret.) It runs the whole day and not even finishes... Also if there is any kind of error in any of the files, then the whole process so far is lost. I tried doing this by only adding 1000 files at once and saving after each succesful batch. This works somewhat better, but not really reliable and needs attention too.

So I wrote a macro that collects the file list and adds ever single one, one by one to the occurrences. This starts to work really quickly at the beginning, but slows down to a crawl really fast. I did try to put all kind of trickery to speed it up: defer updates, no screen updating, wrapping it up in a single "undo" transaction, saving the document after every 100 files, etc. None of these improved the speed much. It still runs the whole day - and once I got it to actually finish, only to be greeted by the "inventor has crashed" report... Also, tested this on a Win10 machine, and there it just grinds to a complete halt where I can't even ctrl+break and stop the macro running or do anything with inventor - but it just keeps running (I can see how it pulls the files from the server), it just stops responding..

 

So, is there any other way I could try?

 

IV2018.3

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

bradeneuropeArthur
Mentor
Mentor

place about 100 files

save the file during the process.

And close it.

Reopen it again and place another about 100 files

and Close...

And open...

And place...

 

this will release the Cash memory of inventor and works much faster.

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 3 of 12

bshbsh
Collaborator
Collaborator

This doesn't really work. I already have to do this from time to time, because it is so slow it doesn't finish til the end of day....

Just closing the assembly won't release the memory Inventor uses. After running for a while, having about 3k components added, memory usage is 12gb (of 32). Closing the document would only release about 1GB memory. The entire Inventor process has to be closed and restarted to release the rest. And after doing so, adding further occurrences is still painfully slow (takes minutes for each!)

 

0 Likes
Message 4 of 12

bradeneuropeArthur
Mentor
Mentor

Hi,

My experience is that if I close the document and release the memory I can load about 12000 ipts in about 5 or 10 minutes!!!

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 5 of 12

bshbsh
Collaborator
Collaborator

I can load the saved assembly as well. I just can't add anything new to it in a reasonable time.

Btw this is the macro I'm using. The first part (where it filters out components that are already added to the assy) has been specifically added to be able to continue from a saved state, because it is so **** slow.

Public Sub Open_LibFiles()
    Dim BGR As Object
    Set BGR = ThisApplication.ActiveDocument
    Set FCollection = New Collection
    SourcePath = "Z:\Libs\"
    Call RecursiveDir(FCollection, SourcePath, "*.i*", True)
    For n = FCollection.Count To 1 Step -1
        If (InStr(1, FCollection.Item(n), "OldVersions") > 0) Or (InStr(1, FCollection.Item(n), "-Filterthis") > 0) Then
            Call FCollection.Remove(n)
        End If
    Next
    For Each ComponentOccurrence In BGR.ComponentDefinition.Occurrences
        For n = FCollection.Count To 1 Step -1
            If FCollection.Item(n) = ComponentOccurrence.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName Then
                Call FCollection.Remove(n)
                Exit For
            End If
        Next
    Next
    i = 1
    n = FCollection.Count
    Dim Mtrx As Matrix
    Set Mtrx = ThisApplication.TransientGeometry.CreateMatrix()
    Dim Vt As Vector
    Set Vt = ThisApplication.TransientGeometry.CreateVector()
    Vt.X = BGR.ComponentDefinition.RangeBox.MaxPoint.X
    Vt.Y = BGR.ComponentDefinition.RangeBox.MaxPoint.Y
    Vt.Z = BGR.ComponentDefinition.RangeBox.MaxPoint.Z
    Call Mtrx.SetTranslation(Vt)
    ThisApplication.ScreenUpdating = False
    Dim oTrans As Transaction
    Set oTrans = ThisApplication.TransactionManager.StartTransaction(BGR, "Macro")
    ThisApplication.AssemblyOptions.DeferUpdate = True
    For Each Item In FCollection
        Vt.X = BGR.ComponentDefinition.RangeBox.MaxPoint.X
        Vt.Y = BGR.ComponentDefinition.RangeBox.MaxPoint.Y
        Vt.Z = BGR.ComponentDefinition.RangeBox.MaxPoint.Z
        Call Mtrx.SetTranslation(Vt)
        On Error Resume Next
        Set InvDoc = BGR.ComponentDefinition.Occurrences.Add(Item, Mtrx)
        On Error GoTo 0
        ThisApplication.StatusBarText = "(" & i & "/" & n & ") " & Item
        If i / 100 = Int(i / 100) Then
            ThisApplication.TransactionManager.SetCheckPoint
            Call BGR.Save2(False)
        End If
        i = i + 1
    Next
    oTrans.End
    ThisApplication.ScreenUpdating = True
    ThisApplication.AssemblyOptions.DeferUpdate = False
End Sub

 

0 Likes
Message 6 of 12

philip1009
Advisor
Advisor

I'm curious about the end goal of this method.  If you tell us what you're trying to do there may be a better method than dealing with these extreme operations.

Message 7 of 12

bshbsh
Collaborator
Collaborator

Basically I need to check the "consistency" of models we got from third parties. It also serves as a list of those, with new models added or removed as needed.

Best way would be to have them all in one assembly and have a BOM of it. The other way I used is simply open the files one by one (per macro), export all the metadata that is needed into an Excel list. This isn't that good though. It also needs some manual work and it doesn't show the "whole story" as I discovered recently. Some BOM rows merge or not merge without a know reason, which an excel list doesn't reveal.

Anyhow, this shouldn't be extreme, we have assemblies with way more unique models in them.

0 Likes
Message 8 of 12

philip1009
Advisor
Advisor

The only help I can provide at the moment is try and read a file's data without opening it in Inventor first.  The metadata in iProperties and filetypes/subtypes etc. can be read from a file without opening the file in Inventor.  I figured that while writing a code to filter out sheet metal parts, I can check the file subtype of IPTs to see if it's a sheet metal part and then check if they have a flat pattern without opening the file, I also know you can check Material and other data as well, it sped up my code a ton.  It's all dependant on the data you need and if you can filter through the data without making a BOM.

0 Likes
Message 9 of 12

bshbsh
Collaborator
Collaborator

Side question: I'm running this on a spare machine right now (so I can keep working on mine), which is better HW, but it has Windows10 on it. On my machine I can stop this macro any time with ctrl+break as usual. But on the W10 machine, I can not stop it, no matter what. It keeps running. Why is that? Is it a W10 thing? (I'm not familiar with w10)

0 Likes
Message 10 of 12

bradeneuropeArthur
Mentor
Mentor

are you using Vault?

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 11 of 12

bshbsh
Collaborator
Collaborator

no.

0 Likes
Message 12 of 12

philip1009
Advisor
Advisor

I'm not sure what you mean by ctrl+break, usually if I have a session that's locking up I just use Task Manager to stop Inventor from running.  I do have a method for adding a Cancel button to any rule., but it's not very stable and usually you'd want to do this through an Add-In so you can have a loading bar with a cancel button.

0 Likes