Code:
Dim swApp As SldWorks.SldWorks
Dim selMgr As SldWorks.SelectionMgr
Dim Model As SldWorks.ModelDoc2
Dim SketchPoints As Variant
Dim SketchFeature As SldWorks.Feature
Dim PointCoords(2) As Double
Dim MathUtil As SldWorks.MathUtility
Dim MathTrans As SldWorks.MathTransform
Dim MathP As SldWorks.MathPoint
Dim ModelSketchTransform As Variant
Dim Feature As SldWorks.SketchPoint 'Connect the program to SolidWorks
Set swApp = CreateObject("SldWorks.Application")
Set Model = swApp.ActiveDoc
'Prepare the MathUtility
Set MathUtil = swApp.GetMathUtility
'Get the SelectionMgr
Set selMgr = Model.SelectionManager
'Get the Sketchpoint from the SelectionMgr
Set Feature = selMgr.GetSelectedObject6(1, -1) 'Feature ist ein Sketchpoint
PointCoords(0) = Feature.X
PointCoords(1) = Feature.Y
PointCoords(2) = Feature.Z
Set MathP = MathUtil.CreatePoint(PointCoords)
'Display the point coordinates in relation to the sketch origin
SketchPoints = MathP.ArrayData
MsgBox SketchPoints(0) & ". " & SketchPoints(1) & ". " & SketchPoints(2)
'bis hier klappt, ich bekomme die Koordinaten des gesetzen Punkts in der Zeichnung, aber die Koordinaten beziehen sich auf das KO-Systems des Punktes selbst. Wenn ich aber in SWX per Hand messe werden die Koordinaten vom Model/Zeichnung genommen.
'Ab hier weiss ich dann nicht genau wie ich weitermachen soll, damit ich dem Multiplaytransform was "richtiges" übergeben kann.
Set MathTrans = MathTrans.Inverse
'Multiply the point by the inverse transform
'MathP now refers to the point location in the model coordinates
Set MathP = MathP.MultiplyTransform(MathTrans)
'Display the point coordinates in relation to the model origin
SketchPoints = MathP.ArrayData
MsgBox SketchPoints(0) & ", " & SketchPoints(1) & ", " & SketchPoints(2)