There is a topic on the change processor concept in the programming help.
I've also attached a VB 6 project I wrote a while ago that demonstrates an
implementation of the change processor.
There is another way to get a similar boost in speed. A change processor
should still be slightly faster, but not by much. I was hesitant to mention
this since it's a hidden, unsupported API. The reason that it's hidden is
that it's easy to get environment into a bad state if you don't use this
correctly. This uses transactions. You wrap the set of calls with a
transaction. Instead of using the standard
TransactionManager.CreateTransaction you use the CreateGlobalTransaction
instead. The risk in using this is if you don't do Transaction.End for the
global transaction. This leaves Inventor in a strange state and can lead to
problems later. Here's a version of your program that uses this. Notice
that uses error handling to make sure the transaction is closed even if an
error occurrs. You also want to be careful during development when you're
debugging your program. It's very easy then to have started the transaction
and then stop the execution of the program before the transaction is closed.
Closing and reopening Inventor will reset everything.
Private m_Doc As AssemblyDocument
Private m_TG As TransientGeometry
Private m_CompDef As AssemblyComponentDefinition
Private m_OccMarker As ComponentOccurrence
Private m_oMatrix As Matrix
Public Sub TestInsertPart()
On Error GoTo ErrorFound
Dim i As Integer
Dim j As Integer
Call InitVariables
Dim oTrans As Transaction
Set oTrans =
ThisApplication.TransactionManager.StartGlobalTransaction(m_Doc, "Time
Test")
For i = 0 To 40
For j = 0 To 40
Call InsertMyPart(i * 5, j * 5, 0)
Next
Next
oTrans.End
Exit Sub
ErrorFound:
If Not oTrans Is Nothing Then
oTrans.End
End If
End Sub
Private Sub InsertMyPart(ByVal x As Integer, ByVal y As Integer, ByVal z As
Integer)
Call m_oMatrix.SetTranslation(m_TG.CreateVector(x, y, z), True)
Set m_OccMarker = m_CompDef.Occurrences.Add("C:\Temp\PartR10.ipt",
m_oMatrix)
End Sub
Private Sub InitVariables()
'set a reference to the active document
Set m_Doc = ThisApplication.ActiveDocument
'set a reference to the transient geometry object
Set m_TG = ThisApplication.TransientGeometry
'set a reference to the assembly component definintion
Set m_CompDef = m_Doc.ComponentDefinition
'create an identity matrix (rotation and translation values = 0)
Set m_oMatrix = m_TG.CreateMatrix
End Sub