From 352556ecc93e6e245f5129d1f6abd6ac66caff66 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 25 Jan 2021 15:49:07 +0100 Subject: [PATCH] =?UTF-8?q?Table,=20fixa=20hur=20punkterna=20ber=C3=A4knas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wardrobe/GUI.vb | 49 ++++++++++++++++++++++++++++++++------------- Wardrobe/Program.vb | 2 +- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Wardrobe/GUI.vb b/Wardrobe/GUI.vb index 5bb3844..ac3a7f8 100644 --- a/Wardrobe/GUI.vb +++ b/Wardrobe/GUI.vb @@ -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 diff --git a/Wardrobe/Program.vb b/Wardrobe/Program.vb index e670387..9c75d74 100644 --- a/Wardrobe/Program.vb +++ b/Wardrobe/Program.vb @@ -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