Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
chandra.shekar.g
in reply to: DFitting

@DFitting,

 

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