Assembly and Nest Generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code below currently generates parts with dimensions driven by a spreadsheet selected by the user. The goal is for the parts to eventually be inserted into the nesting environment automatically, either directly or through an assembly first. First and Foremost I would like to know if this is even possible.
Regardless, I would like to be able to create an assembly and place the generated parts (To be nested manually). Further, I would like for the assembly to be opened and shown to the user.
If anyone has some advice on how to approach this, I would be more than grateful.
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Select File For Data"
fd.Filter = "All Files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then strFileName = fd.FileName
GoExcel.Open(strFileName, "Acrylic Cutting Schedule")
If strFileName = fd.FileName
MessageBox.Show("Select Save Location")
Else
MessageBox.Show("Excel data import FAILED. Check File.")
End If
Dim dlgFolder = New FolderBrowserDialog
'Set Root Path from where to start from
dlgFolder.SelectedPath = "C:\Temp"
dlgFolder.ShowDialog
Dim absolutePath As String = dlgFolder.SelectedPath & "\"
'Dim msg As MsgBoxResult = MessageBox.Show(absolutePath, "Is This Correct?", MessageBoxButtons.OKCancel)
Dim sFilePath As String = ThisDoc.Path & "\"
Dim sNewName As String
Dim doc As Document = ThisDoc.Document
Dim xDoc As Document
Dim List As New ArrayList
List = GoExcel.CellValues(strFileName, "Acrylic Cutting Schedule", "B14", "B1000000")
'MessageBox.Show(List.Count, "Title")
'j = List.Count
j = 5
For i = 14 To j
sNewName = GoExcel.CellValue("B" & i)
doc.SaveAs(absolutePath & GoExcel.CellValue("C4") & " " & sNewName & ".ipt", True)
xDoc = ThisApplication.Documents.Open(absolutePath & GoExcel.CellValue("C4") & " " & sNewName & ".ipt")
Dim oPars As UserParameters = xDoc.ComponentDefinition.Parameters.UserParameters
oPars.Item("width").Expression = "isolate(" & GoExcel.CellValue("D" & i) & ";in;in)"
oPars.Item("height").Expression = "isolate(" & GoExcel.CellValue("I" & i) & ";in;in)"
oPars.Item("thk").Expression = "isolate(" & GoExcel.CellValue("C" & i) & ";in;in)"
xDoc.Save
xDoc.Close(True)
Next i
GoExcel.Close
iLogicVb.UpdateWhenDone = True