去评论
距米网-精简版

使用iLogic在装配体中增加零部件

JUMU
2021/06/17 22:06:08
  1. Dim sExcelFileName As String = "Pippo.xlsx"
  2. Dim oPath As String
  3. Dim Row2 As String '= Row
  4. Dim Rowchange2 As String '= Rowchange
  5. Dim text2 As String = x1
  6. Dim text3 As String = x1
  7. 'file path to use
  8. oPath = ThisDoc.Path & ""
  9. 'file to use
  10. oFile = "40050457.ipt"
  11. ' set a reference to the assembly component definintion.
  12. ' This assumes an assembly document is open.
  13. Dim oAsmCompDef As AssemblyComponentDefinition
  14. oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
  15. ' These four lines create a matrix, which has default values scale 1 and pos 0,0,0
  16. Dim oTG As TransientGeometry
  17. oTG = ThisApplication.TransientGeometry
  18. Dim oMatrix As Matrix
  19. oMatrix = oTG.CreateMatrix
  20. 'Iterate through all of the occurrences
  21. Dim oOccurrence As ComponentOccurrence

  22. Dim i As Integer
  23. For i = 2 To 6
  24.    ' Form the cell address
  25.    text2="C" + String.Format(i,"#")
  26.        oFile = GoExcel.CellValue(sExcelFileName, "Sheet1",text2)
  27.   'place an instance of the component
  28.   'in this case at 0,0,0
  29.   oOccurrence = oAsmCompDef.Occurrences.Add(oPath & oFile, oMatrix)
  30.   oOccurrence.Grounded = False
  31. Next