Hello,
I wrote in "Microsstation V8i SS3" the VBA code below.
Now i'm trying to use this VBA code in "Microstation Connect" but, when running the vba, the origin of the textelement is not right.
The text is on a different coordinate than the original point.
when I do not use the rotation matrix, the text on the right place.
I also tried different matrixes like "Matrix3dFromVectorAndRotationAngle" and "Matrix3dRotationFromColumnZ" but the result is the same.
Does anyone know what here is going on?
kind regards,
Werner
The code of Class Module : PlaceTekstAfst
Option Explicit, Implements IPrimitiveCommandEvents Private nPunten As Long Private hoek As Double Private Afst As Double Private AfstV As Double Private strAfst As String Private Tekst As TextElement Private Lijn As LineElement Private SPoint(1) As Point3d Private Tpoint(1) As Point3d Private PPoint As Point3d Private Vect As Vector3d Private Rotatie As Matrix3d Private Sub IPrimitiveCommandEvents_Cleanup() End End Sub Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, ByVal View As View) If nPunten = 0 Then SPoint(0) = point nPunten = 1 ShowPrompt "enter eindpunt/esc om te stoppen" CommandState.StartDynamics ElseIf nPunten = 1 Then SPoint(1) = point If TekstAfstand.OBAASelectie.Value = True Then If SPoint(0).X = SPoint(1).X Then hoek = Pi / 2 Else hoek = Atn((SPoint(0).Y - SPoint(1).Y) / (SPoint(0).X - SPoint(1).X)) End If ElseIf TekstAfstand.OBAA0.Value = True Then hoek = 0 ElseIf TekstAfstand.OBAA90.Value = True Then hoek = Pi / 2 End If Dim Axis As Point3d Axis.X = 0 Axis.Y = 0 Axis.Z = 1 Rotatie = Matrix3dFromVectorAndRotationAngle(Axis, hoek) Afst = Point3dDistance(SPoint(0), SPoint(1)) strAfst = Str(Round(Afst, 3)) ShowPrompt "Place distance /esc to quit" nPunten = 2 ElseIf nPunten = 2 Then PPoint = point If ULs = True Then 'calculation linespacing Tpoint(0) = point Tpoint(1) = Lijn.ProjectPointOnPerpendicular(point, Matrix3dIdentity) Vect.X = Tpoint(0).X - Tpoint(1).X Vect.Y = Tpoint(0).Y - Tpoint(1).Y Vect.Z = Tpoint(0).Z - Tpoint(1).Z AfstV = Point3dDistanceXY(Tpoint(1), Tpoint(0)) If Vect.X <> 0 Then Vect.X = (Vect.X / AfstV) * Ls If Vect.Y <> 0 Then Vect.Y = (Vect.Y / AfstV) * Ls If Vect.Z <> 0 Then Vect.Z = (Vect.Y / AfstV) * Ls PPoint = Point3dAddPoint3dVector3d(Tpoint(1), Vect) End If Set Tekst = CreateTextElement1(Nothing, strAfst, PPoint, Rotatie) ActiveModelReference.AddElement Tekst Tekst.Redraw CommandState.StartPrimitive New PlaceTekstAfst End If End Sub Private Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode) If nPunten = 1 Then Set Lijn = CreateLineElement2(Nothing, SPoint(0), point) Lijn.Redraw DrawMode Dim PNormal As Point3d PNormal = Point3dSubtract(Lijn.EndPoint, Lijn.StartPoint) Set Tekst = CreateTextElement1(Nothing, Str(Round(Point3dDistance(SPoint(0), point), 3)), point, Matrix3dRotationFromColumnZ(PNormal)) Tekst.Redraw DrawMode ElseIf nPunten = 2 Then ModOmvormen.Text PPoint = point If ULs = True Then 'calculation linespacing Tpoint(0) = point Tpoint(1) = Lijn.ProjectPointOnPerpendicular(point, Matrix3dIdentity) Vect.X = Tpoint(0).X - Tpoint(1).X Vect.Y = Tpoint(0).Y - Tpoint(1).Y Vect.Z = Tpoint(0).Z - Tpoint(1).Z AfstV = Point3dDistanceXY(Tpoint(1), Tpoint(0)) If Vect.X <> 0 Then Vect.X = (Vect.X / AfstV) * Ls If Vect.Y <> 0 Then Vect.Y = (Vect.Y / AfstV) * Ls If Vect.Z <> 0 Then Vect.Z = (Vect.Y / AfstV) * Ls PPoint = Point3dAddPoint3dVector3d(Tpoint(1), Vect) End If Set Tekst = CreateTextElement1(Nothing, strAfst, PPoint, Rotatie) Tekst.Redraw DrawMode End If End Sub Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String) End Sub Private Sub IPrimitiveCommandEvents_Reset() End End Sub Sub IPrimitiveCommandEvents_Start() Dim lc As LocateCriteria Set lc = CommandState.CreateLocateCriteria(False) nPunten = 0 CommandState.SetLocateCriteria lc CommandState.EnableAccuSnap ShowCommand "Place distance" ShowPrompt "enter first point /esc to quit" End Sub