diff --git a/HLCt/Parts/START.SLDPRT b/HLCt/Parts/START.SLDPRT index 496d049..d35b9e1 100644 Binary files a/HLCt/Parts/START.SLDPRT and b/HLCt/Parts/START.SLDPRT differ diff --git a/Wardrobe/GUI/AppForm.vb b/Wardrobe/GUI/AppForm.vb index a0f575a..67c90c9 100644 --- a/Wardrobe/GUI/AppForm.vb +++ b/Wardrobe/GUI/AppForm.vb @@ -3,27 +3,44 @@ Imports System.Environment Public Class AppForm Public Shared fillMode As Boolean + Public Shared appDataPath As String Sub AppForm_Load() Handles MyBase.Load Dim appData As String = GetFolderPath(SpecialFolder.ApplicationData) Dim appDataDir As New IO.DirectoryInfo(appData & "\Floor Grating Configurator") + appDataPath = appDataDir.FullName If Not appDataDir.Exists Then - System.IO.Directory.CreateDirectory(appDataDir.FullName) - System.IO.File.Create(appDataDir.FullName & "\SavedData.txt").Dispose() + System.IO.Directory.CreateDirectory(appDataPath) + System.IO.File.Create(appDataPath & "\SavedData.txt").Dispose() End If - Dim savedData As String() = System.IO.File.ReadAllLines(appDataDir.FullName & "\SavedData.txt") + Dim savedData As String() = System.IO.File.ReadAllLines(appDataPath & "\SavedData.txt") + For i = 0 To savedData.Length - 1 + If savedData(i) = "Export Folder Path" Then + Settings.exportFolder = savedData(i + 1) + Main_Menu.Button_Order.Enabled = True + Main_Menu.Label_FilePathError.Visible = False + End If + Next - Dim dir As New IO.DirectoryInfo("C:\Users\Anton\Documents\Exjobb") - If dir.Exists Then - Individual.filepath = "C:\Users\Anton\Documents\Exjobb" - Else - Individual.filepath = "C:\Users\xperd\Documents" - End If + Dim appDir As String = Application.StartupPath + Dim appDirArray As String() = appDir.Split("\") + For i = 0 To appDirArray.Length - 5 + If i = appDirArray.Length - 5 Then + Settings.filesFolder += appDirArray(i) + Else + Settings.filesFolder += appDirArray(i) & "\" + End If + Next + For i = 0 To appDirArray.Length - 4 + If i = appDirArray.Length - 4 Then + Settings.HLCtFolder += appDirArray(i) + Else + Settings.HLCtFolder += appDirArray(i) & "\" + End If + Next - Settings.filesFolder = Individual.filepath - Settings.HLCtFolder = Individual.filepath & "\X2021" Me.Width = 1400 Me.Height = 800 diff --git a/Wardrobe/GUI/Individual.vb b/Wardrobe/GUI/Individual.vb index 34c1155..0b254b1 100644 --- a/Wardrobe/GUI/Individual.vb +++ b/Wardrobe/GUI/Individual.vb @@ -1,6 +1,5 @@  Public Class Individual - Public Shared filepath As String Sub Load_GUI() ' Initialize GUI diff --git a/Wardrobe/GUI/Main_Menu.Designer.vb b/Wardrobe/GUI/Main_Menu.Designer.vb index f5eab12..4d0fe9d 100644 --- a/Wardrobe/GUI/Main_Menu.Designer.vb +++ b/Wardrobe/GUI/Main_Menu.Designer.vb @@ -27,14 +27,15 @@ Partial Class Main_Menu Me.Button_Individual = New System.Windows.Forms.Button() Me.Button_FilePath = New System.Windows.Forms.Button() Me.Button_Order = New System.Windows.Forms.Button() + Me.Label_FilePathError = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'Button_Settings ' - Me.Button_Settings.Location = New System.Drawing.Point(68, 59) - Me.Button_Settings.Margin = New System.Windows.Forms.Padding(2) + Me.Button_Settings.Location = New System.Drawing.Point(91, 73) + Me.Button_Settings.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2) Me.Button_Settings.Name = "Button_Settings" - Me.Button_Settings.Size = New System.Drawing.Size(127, 41) + Me.Button_Settings.Size = New System.Drawing.Size(169, 50) Me.Button_Settings.TabIndex = 5 Me.Button_Settings.Text = "Settings" Me.Button_Settings.UseVisualStyleBackColor = True @@ -42,9 +43,10 @@ Partial Class Main_Menu 'Button_Multiple ' Me.Button_Multiple.Enabled = False - Me.Button_Multiple.Location = New System.Drawing.Point(734, 439) + Me.Button_Multiple.Location = New System.Drawing.Point(979, 540) + Me.Button_Multiple.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button_Multiple.Name = "Button_Multiple" - Me.Button_Multiple.Size = New System.Drawing.Size(117, 93) + Me.Button_Multiple.Size = New System.Drawing.Size(156, 114) Me.Button_Multiple.TabIndex = 4 Me.Button_Multiple.Text = "Multiple" Me.Button_Multiple.UseVisualStyleBackColor = True @@ -52,46 +54,63 @@ Partial Class Main_Menu 'Button_Individual ' Me.Button_Individual.Enabled = False - Me.Button_Individual.Location = New System.Drawing.Point(734, 302) + Me.Button_Individual.Location = New System.Drawing.Point(979, 372) + Me.Button_Individual.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button_Individual.Name = "Button_Individual" - Me.Button_Individual.Size = New System.Drawing.Size(117, 93) + Me.Button_Individual.Size = New System.Drawing.Size(156, 114) Me.Button_Individual.TabIndex = 3 Me.Button_Individual.Text = "Individual" Me.Button_Individual.UseVisualStyleBackColor = True ' 'Button_FilePath ' - Me.Button_FilePath.Location = New System.Drawing.Point(240, 59) + Me.Button_FilePath.Location = New System.Drawing.Point(320, 73) + Me.Button_FilePath.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button_FilePath.Name = "Button_FilePath" - Me.Button_FilePath.Size = New System.Drawing.Size(123, 41) + Me.Button_FilePath.Size = New System.Drawing.Size(164, 50) Me.Button_FilePath.TabIndex = 6 - Me.Button_FilePath.Text = "Filepath" + Me.Button_FilePath.Text = "File path" Me.Button_FilePath.UseVisualStyleBackColor = True ' 'Button_Order ' - Me.Button_Order.Location = New System.Drawing.Point(194, 353) + Me.Button_Order.Enabled = False + Me.Button_Order.Location = New System.Drawing.Point(259, 434) + Me.Button_Order.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button_Order.Name = "Button_Order" - Me.Button_Order.Size = New System.Drawing.Size(117, 65) + Me.Button_Order.Size = New System.Drawing.Size(156, 80) Me.Button_Order.TabIndex = 7 Me.Button_Order.Text = "Create Order" Me.Button_Order.UseVisualStyleBackColor = True ' + 'Label_FilePathError + ' + Me.Label_FilePathError.AutoSize = True + Me.Label_FilePathError.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label_FilePathError.ForeColor = System.Drawing.Color.Red + Me.Label_FilePathError.Location = New System.Drawing.Point(504, 87) + Me.Label_FilePathError.Name = "Label_FilePathError" + Me.Label_FilePathError.Size = New System.Drawing.Size(184, 20) + Me.Label_FilePathError.TabIndex = 8 + Me.Label_FilePathError.Text = "Please update file path!" + ' 'Main_Menu ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(1046, 627) + Me.ClientSize = New System.Drawing.Size(1395, 772) + Me.Controls.Add(Me.Label_FilePathError) Me.Controls.Add(Me.Button_Order) Me.Controls.Add(Me.Button_FilePath) Me.Controls.Add(Me.Button_Settings) Me.Controls.Add(Me.Button_Multiple) Me.Controls.Add(Me.Button_Individual) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None - Me.Margin = New System.Windows.Forms.Padding(2) + Me.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2) Me.Name = "Main_Menu" Me.Text = "Main_Menu" Me.ResumeLayout(False) + Me.PerformLayout() End Sub @@ -100,4 +119,5 @@ Partial Class Main_Menu Friend WithEvents Button_Individual As Button Friend WithEvents Button_FilePath As Button Friend WithEvents Button_Order As Button + Friend WithEvents Label_FilePathError As Label End Class diff --git a/Wardrobe/GUI/Main_Menu.vb b/Wardrobe/GUI/Main_Menu.vb index ac7ed06..91b90b0 100644 --- a/Wardrobe/GUI/Main_Menu.vb +++ b/Wardrobe/GUI/Main_Menu.vb @@ -92,6 +92,32 @@ Public Class Main_Menu Dim ofd As FolderBrowserDialog = New FolderBrowserDialog If ofd.ShowDialog() <> DialogResult.Cancel Then Settings.exportFolder = ofd.SelectedPath + + Dim appData As String() = System.IO.File.ReadAllLines(AppForm.appDataPath & "\SavedData.txt") + Dim appDataList As New List(Of String) + For i = 0 To appData.Length - 1 + appDataList.Add(appData(i)) + Next + + Dim pathUpdated As Boolean = False + For i = 0 To appDataList.Count - 1 + If appDataList(i) = "Export Folder Path" Then + appDataList(i + 1) = ofd.SelectedPath + pathUpdated = True + Exit For + End If + Next + + If pathUpdated = False Then + appDataList.Add("") + appDataList.Add("Export Folder Path") + appDataList.Add(ofd.SelectedPath) + End If + + System.IO.File.WriteAllLines(AppForm.appDataPath & "\SavedData.txt", appDataList.ToArray()) + + Button_Order.Enabled = True + Label_FilePathError.Visible = False End If End Sub diff --git a/Wardrobe/Quote_Export/GUI_Export.vb b/Wardrobe/Quote_Export/GUI_Export.vb index b7b290f..2cd163a 100644 --- a/Wardrobe/Quote_Export/GUI_Export.vb +++ b/Wardrobe/Quote_Export/GUI_Export.vb @@ -39,7 +39,7 @@ Public Class GUI_Export headerTable = doc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range. Tables.Add(doc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range, 1, 2) - headerTable.Cell(1, 1).Range.InlineShapes.AddPicture(Individual.filepath & "\X2021\Files Needed\Weland_Logo.png") + headerTable.Cell(1, 1).Range.InlineShapes.AddPicture(Settings.HLCtFolder & "\Files Needed\Weland_Logo.png") headerTable.Cell(1, 1).Range.InlineShapes(1).ScaleHeight = 50 headerTable.Cell(1, 1).Range.InlineShapes(1).ScaleWidth = 50 diff --git a/Wardrobe/SolidWorks/Drawing.vb b/Wardrobe/SolidWorks/Drawing.vb index b5265f7..e2bf96b 100644 --- a/Wardrobe/SolidWorks/Drawing.vb +++ b/Wardrobe/SolidWorks/Drawing.vb @@ -160,7 +160,7 @@ Public Class Drawing Dim swSheet As Sheet swSheet = iDrawing.GetCurrentSheet() swSheet.SetProperties2(12, 12, 1, 1, False, swSheetWidth, swSheetHeight, True) - swSheet.SetTemplateName(Individual.filepath & "\X2021\Files Needed\A3 Part.slddrt") + swSheet.SetTemplateName(Settings.HLCtFolder & "\Files Needed\A3 Part.slddrt") swSheet.ReloadTemplate(True) Dim layMgr As LayerMgr diff --git a/Wardrobe/SolidWorks/Individual_Frame_Drawing.vb b/Wardrobe/SolidWorks/Individual_Frame_Drawing.vb index e54df52..08729d4 100644 --- a/Wardrobe/SolidWorks/Individual_Frame_Drawing.vb +++ b/Wardrobe/SolidWorks/Individual_Frame_Drawing.vb @@ -22,15 +22,15 @@ Public Class Individual_Frame_Drawing compNames(j) = Settings.filesFolder & "\Files\CADStart\" & frameComponents(frameID)("partName") & ".SLDPRT" coordNames(j) = "" Next - compNames(compNames.Count - 1) = Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw_support") & "\frame_l_end_piece" & i + 1 & ".SLDPRT" + compNames(compNames.Count - 1) = Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw_support") & "\FRAME_L_END_PIECE" & i + 1 & ".SLDPRT" coordNames(coordNames.Count - 1) = "" Dim assemComps As Object assemComps = assembly.AddComponents3((compNames), (transMatrix), (coordNames)) - longstatus = model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\frame_assembly" & i + 1 & ".SLDASM", 0, 0) + longstatus = model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw") & "\FRAME_ASSEMBLY" & i + 1 & ".SLDASM", 0, 0) - swApp.CloseDoc(Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw_support") & "\frame_assembly" & i + 1 & ".SLDASM") + swApp.CloseDoc(Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw") & "\FRAME_ASSEMBLY" & i + 1 & ".SLDASM") Next End Sub @@ -50,7 +50,7 @@ Public Class Individual_Frame_Drawing Dim swSheet As Sheet swSheet = iDrawing.GetCurrentSheet() swSheet.SetProperties2(12, 12, 1, 1, False, swSheetWidth, swSheetHeight, True) - swSheet.SetTemplateName(Individual.filepath & "\X2021\Files Needed\A3 Part.slddrt") + swSheet.SetTemplateName(Settings.HLCtFolder & "\Files Needed\A3 Part.slddrt") swSheet.ReloadTemplate(True) swSheet.SetScale(1, 10, False, False) swSheet.SetName("Frame 1") @@ -60,14 +60,14 @@ Public Class Individual_Frame_Drawing For i = 0 To Individual_Frame_3D.cuttingList.Count - 1 If i > 0 Then - status = iDrawing.NewSheet3("Frame" & i + 1, 12, 12, 1, 10, False, Individual.filepath & "\X2021\Files Needed\A3 Part.slddrt", + status = iDrawing.NewSheet3("Frame" & i + 1, 12, 12, 1, 10, False, Settings.HLCtFolder & "\Files Needed\A3 Part.slddrt", swSheetWidth, swSheetHeight, "Same as sheet specified in Document Properties") End If status = layMgr.SetCurrentLayer("Svenska") Dim myView As View - myView = iDrawing.CreateDrawViewFromModelView3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw_support") & "\frame_assembly" & i + 1 & ".SLDASM", + myView = iDrawing.CreateDrawViewFromModelView3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_frames_sw") & "\FRAME_ASSEMBLY" & i + 1 & ".SLDASM", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0) myView.UseSheetScale() = True myView.SetDisplayTangentEdges2(2) diff --git a/Wardrobe/SolidWorks/Model_3D.vb b/Wardrobe/SolidWorks/Model_3D.vb index 92e924f..58e1f32 100644 --- a/Wardrobe/SolidWorks/Model_3D.vb +++ b/Wardrobe/SolidWorks/Model_3D.vb @@ -58,11 +58,42 @@ Public Class Model_3D Dim swApp As SldWorks.SldWorks swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks) - Dim status As Boolean + Dim status As Integer - Dim Assembly As ModelDoc2 = swApp.ActiveDoc() - status = Assembly.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw") & "\grating_assembly.SLDASM", 0, 4) - Dim a = 1 + Dim sourcePath, destPath As String + Dim childrenSourcePaths As New List(Of String) + Dim childrenDestPaths As New List(Of String) + + sourcePath = Settings.filesFolder & "\Files\CADStart\" & designName & ".SLDASM" + destPath = Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw") & "\GRATING_ASSEMBLY.SLDASM" + + childrenSourcePaths.Add(Settings.HLCtFolder & "\HLCt\Parts\START.SLDPRT") + childrenDestPaths.Add(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\MASTER.SLDPRT") + + Dim instanceCounter As New Dictionary(Of String, Integer) + For i = 0 To partDT.Rows.Count - 1 + childrenSourcePaths.Add(Settings.filesFolder & "\Files\CADStart\" & partDT.Rows(i)("partName") & ".SLDPRT") + + Dim partName As String = partDT.Rows(i)("partName") + Dim partNameArray As String() = partName.Split("_") + + Dim newName As String = "" + For j = 0 To partNameArray.Length - 4 + newName += partNameArray(j) & "_" + Next + + Try + instanceCounter(newName.Substring(0, newName.Length - 1)) += 1 + Catch ex As Exception + instanceCounter.Add(newName.Substring(0, newName.Length - 1), 1) + End Try + + childrenDestPaths.Add(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw") & "\" & newName & + instanceCounter(newName.Substring(0, newName.Length - 1)) & ".SLDPRT") + Next + + swApp.CloseAllDocuments(True) + status = swApp.CopyDocument(sourcePath, destPath, childrenSourcePaths.ToArray(), childrenDestPaths.ToArray(), 2) End Sub Private Shared Sub Inst_Recesses(parentID As Integer, gratingParameters As DataRow, recessDR As DataRow)