Table, fixa hur punkterna beräknas
This commit is contained in:
parent
e139f77cf3
commit
352556ecc9
|
|
@ -6,8 +6,9 @@ Public Class GUI
|
|||
Dim GratingW, GratingH As Double
|
||||
Dim DrawW, DrawH As Integer
|
||||
Dim Aspect1, Aspect2 As Double
|
||||
Dim pDiff As Double
|
||||
|
||||
Dim p1X, p1Y, p2X, p2Y, p3X, p3Y, p4X, p4Y As Integer
|
||||
Public p1X, p1Y, p2X, p2Y, p3X, p3Y, p4X, p4Y As Integer
|
||||
|
||||
|
||||
|
||||
|
|
@ -64,35 +65,55 @@ Public Class GUI
|
|||
Aspect2 = GratingW / GratingH
|
||||
If Aspect2 > Aspect1 Then
|
||||
'Change draw height
|
||||
Dim wDiff As Double
|
||||
wDiff = GratingW / DrawW
|
||||
pDiff = GratingW / DrawW
|
||||
|
||||
p1Y = boxMidY - CInt(GratingH / (wDiff * 2))
|
||||
p2Y = boxMidY - CInt(GratingH / (wDiff * 2))
|
||||
p3Y = boxMidY + CInt(GratingH / (wDiff * 2))
|
||||
p4Y = boxMidY + CInt(GratingH / (wDiff * 2))
|
||||
p1Y = boxMidY - CInt(GratingH / (pDiff * 2))
|
||||
p2Y = boxMidY - CInt(GratingH / (pDiff * 2))
|
||||
p3Y = boxMidY + CInt(GratingH / (pDiff * 2))
|
||||
p4Y = boxMidY + CInt(GratingH / (pDiff * 2))
|
||||
|
||||
set_startPointsX()
|
||||
Else
|
||||
'Change draw width
|
||||
Dim hDiff As Double
|
||||
hDiff = GratingH / DrawH
|
||||
pDiff = GratingH / DrawH
|
||||
|
||||
p1X = boxMidX - CInt(GratingW / (hDiff * 2))
|
||||
p2X = boxMidX + CInt(GratingW / (hDiff * 2))
|
||||
p3X = boxMidX + CInt(GratingW / (hDiff * 2))
|
||||
p4X = boxMidX - CInt(GratingW / (hDiff * 2))
|
||||
p1X = boxMidX - CInt(GratingW / (pDiff * 2))
|
||||
p2X = boxMidX + CInt(GratingW / (pDiff * 2))
|
||||
p3X = boxMidX + CInt(GratingW / (pDiff * 2))
|
||||
p4X = boxMidX - CInt(GratingW / (pDiff * 2))
|
||||
|
||||
set_startPointsY()
|
||||
End If
|
||||
|
||||
'Redraw rectangle
|
||||
Me.Refresh()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function create_pointTable()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable.Columns.Add("X", GetType(Double))
|
||||
pointTable.Columns.Add("Y", GetType(Double))
|
||||
|
||||
For i = 0 To 3
|
||||
pointTable.Rows.Add()
|
||||
Dim tempPX, tempPY As Double
|
||||
tempPX = (CallByName(Me, "p" & i + 1 & "X", vbGet) + boxMidX) * pDiff / 1000
|
||||
tempPY = (CallByName(Me, "p" & i + 1 & "Y", vbGet) + boxMidY) * pDiff / 1000
|
||||
|
||||
pointTable.Rows(i)("X") = tempPX
|
||||
pointTable.Rows(i)("Y") = tempPY
|
||||
Next
|
||||
|
||||
Return pointTable
|
||||
End Function
|
||||
|
||||
Private Sub ExportSW_Click(sender As Object, e As EventArgs) Handles ExportSW.Click
|
||||
Program.Export_SW()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable = create_pointTable()
|
||||
|
||||
Program.Export_SW(pointTable)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Imports System.Runtime.InteropServices
|
|||
Imports System
|
||||
Imports SldWorks
|
||||
Public Class Program
|
||||
Public Shared Sub Export_SW()
|
||||
Public Shared Sub Export_SW(pointTable As DataTable)
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
Dim Model As ModelDoc2
|
||||
|
|
|
|||
Loading…
Reference in New Issue