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: 

Run twice

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
123 Views, 0 Replies

Run twice

To All,

Why can't this code be runned twice?
Part and assembly with code can be found in IVCF.
Open the Test.iam and run the "Module1.DeTest" macro.

I can't see what's wrong...

Thanks,

Teun

-Code-
Option Explicit
Public sFilePath As String

Sub DeTestVariables()

Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

sFilePath = Left(oDoc.FullFileName, (Len(oDoc.FullFileName) -
Len(oDoc.DisplayName)))

Set oDoc = Nothing

End Sub


Sub DeTest()
DeTestVariables

'Open Basis, verander userparameter "BaffleNr", sla op als plaat X
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Open(sFilePath & "Basis.ipt", True)

Dim i As Long
For i = 1 To 5
oPartDoc.ComponentDefinition.Parameters.Item("BaffleNr").Expression = i
oPartDoc.Update
If Dir(sFilePath & "Plaat " & i & ".ipt") <> "" Then Kill (sFilePath &
"Plaat " & i & ".ipt")
Call oPartDoc.SaveAs(sFilePath & "Plaat " & i & ".ipt", True)
Next i

oPartDoc.Close (True)

' Get the component definition of the currently open assembly
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Create a new matrix object. It will be initialized to an identity matrix
Dim oMatrix As Matrix
Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix

' Place the support ring assembly
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Add(sFilePath & "Plaat 1.ipt", oMatrix)

For i = 2 To 5
Set oOcc = oAsmCompDef.Occurrences.Add(sFilePath & "Plaat " & i &
".ipt", oMatrix)
Next i

Set oPartDoc = Nothing
Set oAsmCompDef = Nothing
Set oMatrix = Nothing
Set oOcc = Nothing

End Sub
0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report