08-24-2018
04:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-24-2018
04:33 AM
Try below code in the main assembly to create new assembly. After that, two components are added. To add constraints, face entities are needed. Which can be done through adding attribute set to faces.
Dim path As String
path = "D:\Chandra\Autodesk Cases\Inventor\Aug-2018\14537574\"
Dim oList As ArrayList
oList = GoExcel.CellValues(path + "Assembly_List.xlsx", "Sheet1", "A1", "A7")
For Each name In oList
Dim oNewAssy As AssemblyDocument
oNewAssy = ThisApplication.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject)
Dim oMatrix As Matrix
oMatrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim componentA As ComponentOccurrence
componentA = oNewAssy.ComponentDefinition.Occurrences.Add("D:\Chandra\Autodesk Cases\Inventor\Aug-2018\14537574\NOZLC2-RF150-8-40-AUX\PIPES\PIPEC2-40-8.ipt", oMatrix)
componentA.Name = "Pipe"
Dim componentB As ComponentOccurrence
componentB = oNewAssy.ComponentDefinition.Occurrences.Add("D:\Chandra\Autodesk Cases\Inventor\Aug-2018\14537574\NOZLC2-RF150-8-40-AUX\FLANGES\RF150-2.ipt", oMatrix)
componentB.Name = "Flange"
Call oNewAssy.SaveAs(path + name, False)
Call oNewAssy.Close
Next
Before running this code, update the paths of excel file, RF150-2.ipt and PIPEC2-40-8.ipt
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
