iLogic to add parts to an assembly

Top  Previous  Next

Here you go, follow the comments...

 

Dim sExcelFileName As String = "Pippo.xlsx"

Dim oPath As String

Dim Row2 As String '= Row

Dim Rowchange2 As String '= Rowchange

Dim text2 As String = x1

Dim text3 As String = x1

 

 

'file path to use

oPath = ThisDoc.Path & "\"

'file to use

oFile = "40050457.ipt"

 

' set a reference to the assembly component definintion.

' This assumes an assembly document is open.

Dim oAsmCompDef As AssemblyComponentDefinition

oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

 

' These four lines create a matrix, which has default values scale 1 and pos 0,0,0

Dim oTG As TransientGeometry

oTG = ThisApplication.TransientGeometry

Dim oMatrix As Matrix

oMatrix = oTG.CreateMatrix

 

'Iterate through all of the occurrences

Dim oOccurrence As ComponentOccurrence

 

 

Dim i As Integer

 

For i = 2 To 6

   ' Form the cell address

   text2="C" + String.Format(i,"#")

       oFile = GoExcel.CellValue(sExcelFileName, "Sheet1",text2)

       

   'place an instance of the component

   'in this case at 0,0,0

 

   oOccurrence = oAsmCompDef.Occurrences.Add(oPath & oFile, oMatrix)

   oOccurrence.Grounded = False

 

Next

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)