Added generic drawing dimensions

This commit is contained in:
Mans 2021-02-09 16:35:59 +01:00
parent cd1fa017c5
commit 105a342d95
5 changed files with 183 additions and 102 deletions

153
Wardrobe/GUI.Designer.vb generated
View File

@ -25,6 +25,8 @@ Partial Class GUI
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(GUI))
Me.DrawingPanel = New System.Windows.Forms.Panel()
Me.Label10 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
@ -47,17 +49,38 @@ Partial Class GUI
Me.Label_Material = New System.Windows.Forms.Label()
Me.CheckBox_WholeMeshWidths = New System.Windows.Forms.CheckBox()
Me.TextBox_Length = New System.Windows.Forms.TextBox()
Me.DrawingPanel.SuspendLayout()
Me.SuspendLayout()
'
'DrawingPanel
'
Me.DrawingPanel.BackColor = System.Drawing.SystemColors.Window
Me.DrawingPanel.Location = New System.Drawing.Point(320, 178)
Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.DrawingPanel.Controls.Add(Me.Label10)
Me.DrawingPanel.Controls.Add(Me.Label8)
Me.DrawingPanel.Location = New System.Drawing.Point(240, 145)
Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(2)
Me.DrawingPanel.Name = "DrawingPanel"
Me.DrawingPanel.Size = New System.Drawing.Size(1507, 689)
Me.DrawingPanel.Size = New System.Drawing.Size(1130, 560)
Me.DrawingPanel.TabIndex = 0
'
'Label10
'
Me.Label10.AutoSize = True
Me.Label10.Location = New System.Drawing.Point(13, 482)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(18, 13)
Me.Label10.TabIndex = 1
Me.Label10.Text = "W"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(66, 533)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(13, 13)
Me.Label8.TabIndex = 0
Me.Label8.Text = "L"
'
'ContextMenuStrip1
'
Me.ContextMenuStrip1.ImageScalingSize = New System.Drawing.Size(20, 20)
@ -68,10 +91,9 @@ Partial Class GUI
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(60, 492)
Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label1.Location = New System.Drawing.Point(45, 400)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(52, 20)
Me.Label1.Size = New System.Drawing.Size(44, 17)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Width"
'
@ -79,40 +101,39 @@ Partial Class GUI
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(45, 566)
Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label2.Location = New System.Drawing.Point(34, 460)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(60, 20)
Me.Label2.Size = New System.Drawing.Size(52, 17)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Length"
'
'ExportSWButton
'
Me.ExportSWButton.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.ExportSWButton.Location = New System.Drawing.Point(1708, 882)
Me.ExportSWButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ExportSWButton.Location = New System.Drawing.Point(1281, 717)
Me.ExportSWButton.Margin = New System.Windows.Forms.Padding(2)
Me.ExportSWButton.Name = "ExportSWButton"
Me.ExportSWButton.Size = New System.Drawing.Size(123, 41)
Me.ExportSWButton.Size = New System.Drawing.Size(92, 33)
Me.ExportSWButton.TabIndex = 6
Me.ExportSWButton.Text = "Export"
Me.ExportSWButton.UseVisualStyleBackColor = False
'
'AngleButton
'
Me.AngleButton.Location = New System.Drawing.Point(781, 68)
Me.AngleButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.AngleButton.Location = New System.Drawing.Point(586, 55)
Me.AngleButton.Margin = New System.Windows.Forms.Padding(2)
Me.AngleButton.Name = "AngleButton"
Me.AngleButton.Size = New System.Drawing.Size(123, 34)
Me.AngleButton.Size = New System.Drawing.Size(92, 28)
Me.AngleButton.TabIndex = 7
Me.AngleButton.Text = "Add Angle"
Me.AngleButton.UseVisualStyleBackColor = True
'
'SettingsButton
'
Me.SettingsButton.Location = New System.Drawing.Point(15, 873)
Me.SettingsButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.SettingsButton.Location = New System.Drawing.Point(11, 709)
Me.SettingsButton.Margin = New System.Windows.Forms.Padding(2)
Me.SettingsButton.Name = "SettingsButton"
Me.SettingsButton.Size = New System.Drawing.Size(80, 50)
Me.SettingsButton.Size = New System.Drawing.Size(60, 41)
Me.SettingsButton.TabIndex = 12
Me.SettingsButton.Text = "Settings"
Me.SettingsButton.UseVisualStyleBackColor = True
@ -122,10 +143,10 @@ Partial Class GUI
Me.ComboBox_TypeChooser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox_TypeChooser.FormattingEnabled = True
Me.ComboBox_TypeChooser.Items.AddRange(New Object() {"Pressure Welded", "Type A"})
Me.ComboBox_TypeChooser.Location = New System.Drawing.Point(121, 57)
Me.ComboBox_TypeChooser.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_TypeChooser.Location = New System.Drawing.Point(91, 46)
Me.ComboBox_TypeChooser.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_TypeChooser.Name = "ComboBox_TypeChooser"
Me.ComboBox_TypeChooser.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_TypeChooser.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_TypeChooser.TabIndex = 13
Me.ComboBox_TypeChooser.Tag = ""
'
@ -135,10 +156,10 @@ Partial Class GUI
Me.ComboBox_MeshSize.Enabled = False
Me.ComboBox_MeshSize.FormattingEnabled = True
Me.ComboBox_MeshSize.Items.AddRange(New Object() {"12x100 (B9)", "25x50 (F4)", "34x37 (H3)"})
Me.ComboBox_MeshSize.Location = New System.Drawing.Point(121, 241)
Me.ComboBox_MeshSize.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_MeshSize.Location = New System.Drawing.Point(91, 196)
Me.ComboBox_MeshSize.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_MeshSize.Name = "ComboBox_MeshSize"
Me.ComboBox_MeshSize.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_MeshSize.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_MeshSize.TabIndex = 14
'
'ComboBox_Thickness
@ -147,10 +168,10 @@ Partial Class GUI
Me.ComboBox_Thickness.Enabled = False
Me.ComboBox_Thickness.FormattingEnabled = True
Me.ComboBox_Thickness.Items.AddRange(New Object() {"2", "3", "4"})
Me.ComboBox_Thickness.Location = New System.Drawing.Point(121, 375)
Me.ComboBox_Thickness.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Thickness.Location = New System.Drawing.Point(91, 305)
Me.ComboBox_Thickness.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Thickness.Name = "ComboBox_Thickness"
Me.ComboBox_Thickness.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Thickness.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Thickness.TabIndex = 15
'
'ComboBox_Height
@ -159,20 +180,19 @@ Partial Class GUI
Me.ComboBox_Height.Enabled = False
Me.ComboBox_Height.FormattingEnabled = True
Me.ComboBox_Height.Items.AddRange(New Object() {"20", "25", "30"})
Me.ComboBox_Height.Location = New System.Drawing.Point(121, 325)
Me.ComboBox_Height.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Height.Location = New System.Drawing.Point(91, 264)
Me.ComboBox_Height.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Height.Name = "ComboBox_Height"
Me.ComboBox_Height.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Height.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Height.TabIndex = 16
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(61, 55)
Me.Label3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label3.Location = New System.Drawing.Point(46, 45)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(45, 20)
Me.Label3.Size = New System.Drawing.Size(40, 17)
Me.Label3.TabIndex = 17
Me.Label3.Text = "Type"
'
@ -180,10 +200,9 @@ Partial Class GUI
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(17, 242)
Me.Label4.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label4.Location = New System.Drawing.Point(13, 197)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(88, 20)
Me.Label4.Size = New System.Drawing.Size(73, 17)
Me.Label4.TabIndex = 18
Me.Label4.Text = "Mesh Size"
'
@ -191,10 +210,9 @@ Partial Class GUI
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(19, 377)
Me.Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label5.Location = New System.Drawing.Point(14, 306)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(85, 20)
Me.Label5.Size = New System.Drawing.Size(72, 17)
Me.Label5.TabIndex = 19
Me.Label5.Text = "Thickness"
'
@ -202,10 +220,9 @@ Partial Class GUI
'
Me.Label6.AutoSize = True
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(49, 325)
Me.Label6.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label6.Location = New System.Drawing.Point(37, 264)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(58, 20)
Me.Label6.Size = New System.Drawing.Size(49, 17)
Me.Label6.TabIndex = 20
Me.Label6.Text = "Height"
'
@ -213,10 +230,9 @@ Partial Class GUI
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(408, 34)
Me.Label7.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label7.Location = New System.Drawing.Point(306, 28)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(91, 20)
Me.Label7.Size = New System.Drawing.Size(78, 17)
Me.Label7.TabIndex = 21
Me.Label7.Text = "Functions"
'
@ -226,18 +242,17 @@ Partial Class GUI
Me.ComboBox_Width.Enabled = False
Me.ComboBox_Width.FormattingEnabled = True
Me.ComboBox_Width.Items.AddRange(New Object() {"500", "700", "722", "1000"})
Me.ComboBox_Width.Location = New System.Drawing.Point(125, 492)
Me.ComboBox_Width.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Width.Location = New System.Drawing.Point(94, 400)
Me.ComboBox_Width.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Width.Name = "ComboBox_Width"
Me.ComboBox_Width.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Width.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Width.TabIndex = 23
'
'Button_Square
'
Me.Button_Square.Location = New System.Drawing.Point(971, 68)
Me.Button_Square.Margin = New System.Windows.Forms.Padding(4)
Me.Button_Square.Location = New System.Drawing.Point(728, 55)
Me.Button_Square.Name = "Button_Square"
Me.Button_Square.Size = New System.Drawing.Size(123, 34)
Me.Button_Square.Size = New System.Drawing.Size(92, 28)
Me.Button_Square.TabIndex = 25
Me.Button_Square.Text = "Add Square Corner"
Me.Button_Square.UseVisualStyleBackColor = True
@ -246,10 +261,9 @@ Partial Class GUI
'
Me.Label9.AutoSize = True
Me.Label9.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label9.Location = New System.Drawing.Point(17, 15)
Me.Label9.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label9.Location = New System.Drawing.Point(13, 12)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(168, 20)
Me.Label9.Size = New System.Drawing.Size(146, 17)
Me.Label9.TabIndex = 26
Me.Label9.Text = "Floor gratings data"
'
@ -259,20 +273,19 @@ Partial Class GUI
Me.ComboBox_Material.Enabled = False
Me.ComboBox_Material.FormattingEnabled = True
Me.ComboBox_Material.Items.AddRange(New Object() {"12x100 (B9)", "25x50 (F4)", "34x37 (H3)"})
Me.ComboBox_Material.Location = New System.Drawing.Point(121, 108)
Me.ComboBox_Material.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Material.Location = New System.Drawing.Point(91, 88)
Me.ComboBox_Material.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Material.Name = "ComboBox_Material"
Me.ComboBox_Material.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Material.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Material.TabIndex = 27
'
'Label_Material
'
Me.Label_Material.AutoSize = True
Me.Label_Material.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_Material.Location = New System.Drawing.Point(37, 108)
Me.Label_Material.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label_Material.Location = New System.Drawing.Point(28, 88)
Me.Label_Material.Name = "Label_Material"
Me.Label_Material.Size = New System.Drawing.Size(69, 20)
Me.Label_Material.Size = New System.Drawing.Size(58, 17)
Me.Label_Material.TabIndex = 28
Me.Label_Material.Text = "Material"
'
@ -280,10 +293,10 @@ Partial Class GUI
'
Me.CheckBox_WholeMeshWidths.AutoSize = True
Me.CheckBox_WholeMeshWidths.Enabled = False
Me.CheckBox_WholeMeshWidths.Location = New System.Drawing.Point(125, 453)
Me.CheckBox_WholeMeshWidths.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.CheckBox_WholeMeshWidths.Location = New System.Drawing.Point(94, 368)
Me.CheckBox_WholeMeshWidths.Margin = New System.Windows.Forms.Padding(2)
Me.CheckBox_WholeMeshWidths.Name = "CheckBox_WholeMeshWidths"
Me.CheckBox_WholeMeshWidths.Size = New System.Drawing.Size(143, 21)
Me.CheckBox_WholeMeshWidths.Size = New System.Drawing.Size(121, 18)
Me.CheckBox_WholeMeshWidths.TabIndex = 29
Me.CheckBox_WholeMeshWidths.Text = "Whole mesh widths"
Me.CheckBox_WholeMeshWidths.UseCompatibleTextRendering = True
@ -292,16 +305,17 @@ Partial Class GUI
'TextBox_Length
'
Me.TextBox_Length.Enabled = False
Me.TextBox_Length.Location = New System.Drawing.Point(125, 566)
Me.TextBox_Length.Location = New System.Drawing.Point(94, 460)
Me.TextBox_Length.Margin = New System.Windows.Forms.Padding(2)
Me.TextBox_Length.Name = "TextBox_Length"
Me.TextBox_Length.Size = New System.Drawing.Size(187, 22)
Me.TextBox_Length.Size = New System.Drawing.Size(141, 20)
Me.TextBox_Length.TabIndex = 30
'
'GUI
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1845, 937)
Me.ClientSize = New System.Drawing.Size(1155, 687)
Me.Controls.Add(Me.TextBox_Length)
Me.Controls.Add(Me.AngleButton)
Me.Controls.Add(Me.Button_Square)
@ -326,10 +340,11 @@ Partial Class GUI
Me.Controls.Add(Me.DrawingPanel)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Margin = New System.Windows.Forms.Padding(4)
Me.MaximizeBox = False
Me.Name = "GUI"
Me.Text = "Floor Gratings"
Me.DrawingPanel.ResumeLayout(False)
Me.DrawingPanel.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
@ -358,4 +373,6 @@ Partial Class GUI
Friend WithEvents Label_Material As Label
Friend WithEvents CheckBox_WholeMeshWidths As CheckBox
Friend WithEvents TextBox_Length As TextBox
Friend WithEvents Label10 As Label
Friend WithEvents Label8 As Label
End Class

View File

@ -2,8 +2,8 @@
Imports Excel = Microsoft.Office.Interop.Excel
Public Class GUI
Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
'Public Shared filepath As String = "C:\Users\xperd\Documents"
'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
Public Shared filepath As String = "C:\Users\xperd\Documents"
Dim excelApp As Excel.Application = New Excel.Application
Dim excelWB As Excel.Workbook
@ -23,6 +23,10 @@ Public Class GUI
Get_Database()
CheckBox_WholeMeshWidths.Checked = True
GUI_Functions.pointsMeasurements.Add("Lmes", {1, 2, 1})
GUI_Functions.pointsMeasurements.Add("Wmes", {2, 3, 2})
End Sub
Private Sub Get_Database()

View File

@ -172,12 +172,15 @@
e.Graphics.DrawLine(symPen, ArrowSymbolPoints("p" & i)(0), ArrowSymbolPoints("p" & i)(1),
ArrowSymbolPoints("p" & i + 1)(0), ArrowSymbolPoints("p" & i + 1)(1))
Next
e.Graphics.TranslateTransform(20, containerW - 20)
e.Graphics.DrawString("Length", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -7))
e.Graphics.RotateTransform(-90)
e.Graphics.DrawString("Width", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -4))
e.Graphics.RotateTransform(90)
e.Graphics.TranslateTransform(-20, -containerW + 20)
'e.Graphics.TranslateTransform(20, containerW - 20)
'e.Graphics.DrawString("Length", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -7))
'e.Graphics.RotateTransform(-90)
'e.Graphics.DrawString("Width", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -4))
'e.Graphics.RotateTransform(90)
'e.Graphics.TranslateTransform(-20, -containerW + 20)
' Draw actual grating (black)
Dim pen As Pen = New Pen(Color.Black, 2)

View File

@ -6,6 +6,8 @@
Public Shared pointsFunc As New Dictionary(Of String, Boolean)
Public Shared pointsMeasurements As New Dictionary(Of String, Integer())
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
GUI.Controls("AngleButton").Enabled = False
@ -47,7 +49,7 @@
Private Shared Sub FunctionText_Changed(sender As TextBox, e As EventArgs)
If Not GUI.Controls("X_TextBox").Text = "" And Not GUI.Controls("Y_TextBox").Text = "" Then
If GUI.DrawingPanel.Controls.Count = 0 Then
If GUI.DrawingPanel.Controls.Count = 2 Then 'FIXA BÄTTRE
' Create Buttons for all clickable points
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
@ -115,20 +117,30 @@
'Kvadrant 4
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
Else
'Kvadrant 1
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 1
pointsMeasurements("Wmes")(0) = pointsMeasurements("Wmes")(0) + 1
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
End If
Else
If pYP > GUI_Drawing_Panel.containerMidY Then
'Kvadrant 3
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
Else
'Kvadrant 2
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 1
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
End If
End If
pointsFunc.Add("pA" & pointCounter * 2 - 1, False)
@ -153,6 +165,10 @@
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP + d2P, pXSW + d1SW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 2
pointsMeasurements("Wmes")(0) = pointsMeasurements("Wmes")(0) + 2
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
End If
Else
If pYP > GUI_Drawing_Panel.containerMidY Then
@ -160,11 +176,16 @@
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP - d2P, pXSW - d1SW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
Else
'Kvadrant 2
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP + d2P, pXSW - d1SW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 2
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
End If
End If
pointsFunc.Add("pS" & pointCounter * 3 - 2, True)
@ -198,4 +219,9 @@
GUI.Controls("AngleButton").Enabled = True
GUI.Controls("Button_Square").Enabled = True
End Sub
End Class

View File

@ -50,14 +50,19 @@ Public Class SW_Drawing_Gratings
skLine = swSkMgr.CreateLine(pX1, pY1, 0, pX2, pY2, 0)
Next
boolstatus = Model.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Model.FeatureManager.InsertRefPlane(8, gratingHeight, 0, 0, 0, 0)
'Rename sketch?
swSkMgr.InsertSketch(True)
Dim status As Boolean
Dim swModelDocExtension As ModelDocExtension
swModelDocExtension = Model.Extension
Dim status As Boolean
status = swModelDocExtension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Dim swFeatureMgr As FeatureManager
@ -104,35 +109,33 @@ Public Class SW_Drawing_Gratings
Dim RootComp = myView.RootDrawingComponent
Dim CompName = RootComp.Name
Dim dimension As IDisplayDimension
Dim measurement As IDisplayDimension
Dim OutLine = myView.GetOutline
Dim X_Mid = (OutLine(2) - OutLine(0)) / 2 + OutLine(0)
Dim Y_Mid = (OutLine(3) - OutLine(1)) / 2 + OutLine(1)
For i = 1 To 2
Dim point1Name As String = "Point" & i & "@Sketch1@" & CompName & "@" & myView.GetName2
Dim point2Name As String = "Point" & i + 1 & "@Sketch1@" & CompName & "@" & myView.GetName2
iDrawing.ClearSelection2(True)
swExtensions.SelectByID2(point1Name, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
swExtensions.SelectByID2(point2Name, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
If i = 1 Then
dimension = iDrawing.AddDimension2(X_Mid, OutLine(3), 0)
Else
dimension = iDrawing.AddDimension2(OutLine(2), Y_Mid, 0)
End If
iDrawing.ClearSelection2(True)
dimension.SetUnits2(False, 0, 1, 0, True, 12)
dimension.CenterText = True
dimension.SetPrecision3(0, 0, 0, 0)
Next
Add_Dimensions(GUI_Functions.pointsMeasurements("Lmes"), CompName, myView, iDrawing, swExtensions, measurement, X_Mid, OutLine, Y_Mid)
Add_Dimensions(GUI_Functions.pointsMeasurements("Wmes"), CompName, myView, iDrawing, swExtensions, measurement, X_Mid, OutLine, Y_Mid)
Dim myView2 As View
myView2 = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Top", swSheetWidth / 2, OutLine(3) + 0.03, 0)
myView2 = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Bottom", swSheetWidth / 2, OutLine(3) + 0.03, 0)
Dim OutLine2 = myView2.GetOutline
Dim point1Name As String = "Front Plane@" & CompName & "@" & myView2.GetName2
Dim point2Name As String = "Plane1@" & CompName & "@" & myView2.GetName2
iDrawing.ClearSelection2(True)
swExtensions.SelectByID2(point1Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
swExtensions.SelectByID2(point2Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
measurement = iDrawing.AddVerticalDimension2(OutLine2(2), OutLine2(1), 0)
iDrawing.ClearSelection2(True)
measurement.SetUnits2(False, 0, 1, 0, True, 12)
measurement.CenterText = True
measurement.SetPrecision3(0, 0, 0, 0)
Dim longstatus As Integer
Dim newName As String
@ -140,4 +143,32 @@ Public Class SW_Drawing_Gratings
longstatus = iDrawing.SaveAs3(newName, 0, 0)
End Sub
Private Shared Sub Add_Dimensions(points() As Integer, CompName As String, myView As View, iDrawing As DrawingDoc, swExtensions As SldWorks.ModelDocExtension _
, measurement As IDisplayDimension, X_Mid As Double, OutLine() As Double, Y_Mid As Double)
Dim point1Name As String = "Point" & points(0) & "@Sketch1@" & CompName & "@" & myView.GetName2
Dim point2Name As String = "Point" & points(1) & "@Sketch1@" & CompName & "@" & myView.GetName2
iDrawing.ClearSelection2(True)
swExtensions.SelectByID2(point1Name, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
swExtensions.SelectByID2(point2Name, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
If points(2) = 1 Then
measurement = iDrawing.AddHorizontalDimension2(X_Mid, OutLine(3), 0)
ElseIf points(2) = 2 Then
measurement = iDrawing.AddVerticalDimension2(OutLine(2), Y_Mid, 0)
ElseIf points(2) = 3 Then
measurement = iDrawing.AddHorizontalDimension2(X_Mid, OutLine(1), 0)
Else
measurement = iDrawing.AddVerticalDimension2(OutLine(0), Y_Mid, 0)
End If
iDrawing.ClearSelection2(True)
measurement.SetUnits2(False, 0, 1, 0, True, 12)
measurement.CenterText = True
measurement.SetPrecision3(0, 0, 0, 0)
End Sub
End Class