Drive Constraint performance vs assembly update method

Drive Constraint performance vs assembly update method

Brett.G
Enthusiast Enthusiast
458 Views
5 Replies
Message 1 of 6

Drive Constraint performance vs assembly update method

Brett.G
Enthusiast
Enthusiast

Hello,

   I know this has been asked before (reference), but I have been unable to find an answer.  I'm trying to drive two Parameters by assigning Parameter.value to something and then update the assembly with Activedocument.update.   The assemblies I'm using tend to have many mates and the update method tends to take some time.  Comparing this to the Drive Constraint tool, the performance is much worse. 

 

Does anyone know what makes the Drive Constraint tool much faster than the Update method?  Alternately, is there any way to make the Update method faster or only update the Parameters that I'm modifying?  Any hints would be appreciated.  Thanks!

0 Likes
459 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor
The activedocument.update could be the problem.
Could you please upload your code as text file.

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 6

Brett.G
Enthusiast
Enthusiast

Thanks for the suggestion, the code is broken up into different subs with more details and error checking, but here is the gist:

 

  1. Disable user interaction
  2. Assign a value to the vertical parameter
  3. Assign a value to the horizontal parameter
  4. update the assembly
  5. when finished looping, reenable user interaction

 

the code to do that is as follows:

 

gInvApp.UserInterfaceManager.UserInteractionDisabled = True

VertName.Value = (gdblPosArray(gintCurrentIndex, 2) + CDbl(txtVertOffset.Text)) / 10
HorizName.Value = (gdblPosArray(gintCurrentIndex, 3) + CDbl(txtHorizOffset.Text)) / 10
'update model and ignore errors
gAssyDoc.Update2(True)

 

Previously, instead of gAssyDoc.Update2(True)  I was accessing the active document each time via gInvApp.ActiveDocument.Update2(True) which I thought may be slower based on your comment, so I assigned gAssyDoc =  gInvApp.ActiveDocument in the "New" sub so I wouldn't have to find it each time.  In an assembly with 180 constraints this did not seem to make much difference.  Driving one of my constraints is still faster than my addin that drives both or even when I only control one constraint with my addin. 


0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor

try this:

 

 

gInvApp.UserInterfaceManager.UserInteractionDisabled = True

gInvApp.screenupdating = false
VertName.Value = (gdblPosArray(gintCurrentIndex, 2) + CDbl(txtVertOffset.Text)) / 10 HorizName.Value = (gdblPosArray(gintCurrentIndex, 3) + CDbl(txtHorizOffset.Text)) / 10 'update model and ignore errors gAssyDoc.Update2(True)
InvApp.screenupdating = 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

0 Likes
Message 5 of 6

Brett.G
Enthusiast
Enthusiast

Hmm, I tried your suggestion and did not notice a difference.  I did have to place the screen update line before the AssyDoc.Update line to get the "animation"  but did not notice any significant change in the performance on the assembly I'm trying. 

 

I appreciate the suggestions, I've been thinking about this for awhile now and cannot seem to figure it out.  At this point any idea is appreciated.

0 Likes
Message 6 of 6

liminma8458
Collaborator
Collaborator

"ThisApplication.ActiveDocument.Rebuild" may work.

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes