Option Explicit Dim oldpoint As SketchPoint Dim firstpoint As SketchPoint Private Sub insertpoint_Click() Dim xwert As Double Dim ywert As Double 'constpolygon = polygons.Value If XBox.Value = "" Or YBox.Value = "" Then MsgBox ("Bitte Koordinaten eingeben") Exit Sub End If On Error GoTo Umwandlungsfehler xwert = CDbl(XBox.Text) ywert = CDbl(YBox.Text) On Error GoTo 0 'Feststellen ob eine Skizze aktiv ist If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then MsgBox "Eine Skizze muss aktiv sein" Exit Sub End If 'Einen Bezug zur aktiven Skizze herstellen Dim oSketch As PlanarSketch Set oSketch = ThisApplication.ActiveEditObject 'Einen Bezug zur temporären Geometriesammlung herstellen Dim oTransGeom As TransientGeometry Set oTransGeom = ThisApplication.TransientGeometry Dim oLine As SketchLine 'erster Aufruf? If TypeName(oldpoint) = "Nothing" Then 'nimm 0,0 als Startpunkt und merke dir diesen als ersten Punkt Set oLine = oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(xwert, ywert)) Set firstpoint = oLine.StartSketchPoint Else 'zeiche vom alten zum neuen punkt Set oLine = oSketch.SketchLines.AddByTwoPoints(oldpoint, oTransGeom.CreatePoint2d(xwert, ywert)) End If 'lösche eingabefelder XBox.Text = "" YBox.Text = "" 'merke dir den neuen endpunkt Set oldpoint = oLine.EndSketchPoint 'Fehlerbehandlung GoTo ende Umwandlungsfehler: MsgBox ("Bitte Zahlen eingeben") GoTo ende: ende: End Sub Private Sub closeform_Click() If TypeName(oldpoint) = "Nothing" Then 'keine linien gezeichnet Exit Sub End If 'Feststellen ob eine Skizze aktiv ist If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then MsgBox "Eine Skizze muss aktiv sein" Exit Sub End If 'Einen Bezug zur aktiven Skizze herstellen Dim oSketch As PlanarSketch Set oSketch = ThisApplication.ActiveEditObject 'Einen Bezug zur temporären Geometriesammlung herstellen Dim oTransGeom As TransientGeometry Set oTransGeom = ThisApplication.TransientGeometry Dim oLine As SketchLine Set oLine = oSketch.SketchLines.AddByTwoPoints(oldpoint, firstpoint) UserForm1.Hide End Sub