Community
The following code was given to me to use. Doesnt work 😕
I don't know how to make it work, as this is not my department. Any help will be appreciated with a smile 🙂
Sub CreateDerivedPartFromAssembly() 'Set a reference to the current assembly document. Dim AsmDoc As AssemblyDocument Set AsmDoc = ThisApplication.ActiveDocument 'Create the name of the new part Dim PartFileName As String PartFileName = Left(AsmDoc.FullDocumentName, Len(AsmDoc.FullDocumentName) - 4) & ".ipt" 'Make a new part file Dim oPartDoc As PartDocument Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) 'Create a derived part feature Dim oDerivedAsmDef As DerivedAssemblyDefinition Set oDerivedAsmDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AsmDoc.FullDocumentName) Call oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef) 'Break the link to the assembly oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Item(1).BreakLinkToFile 'Copy the iProperties from the assembly to the part Dim Text As String oPartDoc.PropertySets.Item("Design Tracking Properties").Item("Description").value = _ AsmDoc.PropertySets.Item("Design Tracking Properties").Item("Description").value oPartDoc.PropertySets.Item("Summary Information").Item("Comments").value = _ AsmDoc.PropertySets.Item("Summary Information").Item("Comments").value 'Save the part On Error GoTo ErrorHandler: oPartDoc.SaveAs PartFileName, False On Error GoTo 0 AsmDoc.Close oPartDoc.Activate Exit Sub ErrorHandler: MsgBox ("A file with the same name already exists." & Chr(13) & "You may want to delete the existing file and re-do this process.") oPartDoc.Close (True) Exit Sub End Sub
TY!
(using inventor 2010)
Hi m.teleguz1,
See this link:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/How-to-Execute-Code/m-p/3820532#M43118
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com