Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can i speed up adding parts to an assembly?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mitcham_boy
1785 Views, 3 Replies

How can i speed up adding parts to an assembly?

Hi

 

I have a VB code that gets an instance of inventor.  It creates a new assembly and then starts adding parts to it.  The code works fine and is reliable but I am suprised by how slow the process is.. the process is as follows

 

'psuedo code...

 

do

 

myAssembly.ComponentDefinition.Occurrences.Add(my_component_file, my_position)  'add my next occurrence to the assembly

 

myOccurrence.Transformation = my_position ' move the occurrence to a new position in assembly space.

 

With myOccurrence.Definition  'go thru the occurrence and change its dimensions

   ForEach p In.Parameters

      If p.Name = my_parameter_name Then p.Value = my_parameter_value

 

   Next

 

EndWith

 

loop until my_last_component

 

 

...I notice that the green progress bar is frequently on with messages in the Inventor statusbar such as "Executing update component" and "Executing change component position".

 

I wonder is Inventor performing many read/write operations which is causing the slow performance?  Perhaps it is updating files after each of my 3 operations in the loop... and if so is there a way i can achieve this faster such as delaying read/write until after all three operations have been performed or until all occurrences have been added??

 

Any tips appreciated.

Thanks.

Dan

(Belfast, Inventor 2013)

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: mitcham_boy

 

The following VBA code demonstrates some of the ways you can optimize your Inventor plugins:

 

 

Sub PerformanceIncrease()

    Dim Invapp As Inventor.Application
    Set Invapp = ThisApplication

    '' Turn off user interaction so that inventor can focus on your API calls exclusively
    Invapp.UserInterfaceManager.UserInteractionDisabled = True
    
    '' Turn off screenupdating to speed up performance
    Invapp.ScreenUpdating = False
    
    '' Set Defer updates to true and force an update when you're finished with your API commands
    '' This can be done on drawings and sketches as well
    Invapp.AssemblyOptions.DeferUpdate = True
    
    '' Create the document invisible
    Dim oAssDoc As Inventor.AssemblyDocument
    Set oAssDoc = Invapp.Documents.Add( _
        Inventor.DocumentTypeEnum.kAssemblyDocumentObject, , True)
        
    ''Wrap your command into a global transaction so only one undo point is created.
    Dim oTrans As Inventor.Transaction
    
    Set oTrans = Invapp.TransactionManager.StartGlobalTransaction(oAssDoc, _
        "My API Calls")
        
    '' perform your functions here
    
    '' Be sure to end a global transaction when you are finished
    oTrans.End
        
    '' Wrap up
    Invapp.ScreenUpdating = True
    Invapp.UserInterfaceManager.UserInteractionDisabled = False
    
    '' Make the assembly document visible
    Call oAssDoc.Views.Add
    Call oAssDoc.Update
    Invapp.AssemblyOptions.DeferUpdate = False
    
End Sub

 

 

 

Message 3 of 4
mitcham_boy
in reply to: Anonymous

Robert thanks for these tips - some of them i have in place already like the invisible document and screenupdating - i'm going to add the others and see what happens !
Message 4 of 4
maxim.teleguz
in reply to: Anonymous

here is one for the books that works for some reason really well in 2022 you dont need to set it to false either. 

Imports System.Windows.Forms
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System
AddReference "System.Drawing.dll"

ThisApplication.AssemblyOptions.EnableAssemblyExpress = True
ThisApplication.ScreenUpdating = True

SendKeys.SendWait("{ESC}")
AppActivate(ThisApplication.Caption)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report