Inventor VBA macro - Save Assembly as part

Inventor VBA macro - Save Assembly as part

isocam
Collaborator Collaborator
780 Views
1 Reply
Message 1 of 2

Inventor VBA macro - Save Assembly as part

isocam
Collaborator
Collaborator

Can anybody help???

 

Is it possible, using a AutoDesk Inventor VBA macro (NOTILOGIC), to automatically save an assembly (iam) as a part (ipt)?

 

Many thanks in advance

 

Darren

0 Likes
781 Views
1 Reply
Reply (1)
Message 2 of 2

cmbronder
Alumni
Alumni

Hi Darren,

Did you want something like a derived part? If so, try this VBA:

Sub DerivedAssembly()
' Open the assembly to be saved as a derived part
' Get the path for the current Assembly
Dim strAsmPath As String
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
strAsmPath = oAsmDoc.FullFileName

' Create a new part to derive the assembly into.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

' Create a derived definition for the assembly.
Dim oDerivedAsmDef As DerivedAssemblyDefinition
Set oDerivedAsmDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(strAsmPath)

' Create the derived part from the assembly.
Call oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef)

' Save the new part
ThisApplication.SilentOperation = True
Call oPartDoc.SaveAs("c:/Temp/DerivedPart.ipt", False)
ThisApplication.SilentOperation = False
End Sub

 

FYI,

Clare