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: 

Defer Update When Changing BOM Structure

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mhumes
331 Views, 3 Replies

Defer Update When Changing BOM Structure

Hi everyone,

 

I have a script for one of my assemblies that changes the BOM Structure on supressed items so that my drawing BOMs show correct quanties for the current representation. The assembly I use this on is very large so the script takes a long time to run. To change the BOM structure I have to mark the part as active then change it and deativate it. I think I would gain a lot of speed if I could tell Inventor not to update the screen during this process. 

 

Does anyone know how to do this?

 

Thanks,

 

ThisApplication.StatusBarText = "BOMAudit "

Dim oDoc As Document = ThisDoc.Document
Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence
doc = ThisDoc.Document

For Each oCompOcc in oCompDef.Occurrences
	voCompOcc = Component.InventorComponent(oCompOcc.Name)

	If oCompOcc.Suppressed = True Then 'Check for suppressed files without Default BOM Structure
		Component.IsActive(oCompOcc.Name) = True
		oCompOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure
		Component.IsActive(oCompOcc.Name) = False
	Else			
		Component.IsActive(oCompOcc.Name) = True 'Turn on to allow for update
		oCompOcc.BOMStructure = BOMStructureEnum.kDefaultBOMStructure
	
	End If
Next

 

3 REPLIES 3
Message 2 of 4
adam.nagy
in reply to: mhumes

Hi there,

 

There are a few ways that you might be able to speed up your code, including:

StartGlobalTransaction, Application.ScreenUpdating, Application.AssemblyOptions.DeferUpdate

 

Here is Brian's class on this topic where you can find the above things too:

http://aucache.autodesk.com/au2012/sessionsFiles/3547/4363/handout_3547_CP3547-InventorAPIOddsAndEnd...

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 4
mhumes
in reply to: adam.nagy

Thanks Adam!

 

Using StartGlobalTransaction helped a ton. I combined that with stopping the screen from updating and I was able to take the average run time from 152.812s to 48.008s.

Message 4 of 4
ITIT1461
in reply to: mhumes

Hi,

You can also check:

 

InventorApp.UserInterfaceManager().UserInteractionDisabled.

 

I got very good results disabling user input together with the other options already mentioned in Adam post.

 

Regards

Fabio

 

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

Post to forums