# oMessage.point.x to word processor

MicroStation V8i SS4

Hey all, I have create some code to place a cell, record that placement point (oMessage.Point) and then start the "place note" tool and populate the word processor with the value of that point. My issue is that is only giving me the value after the decimal of that point. It is ignoring the data that I need. For instance, if the value is 66927.1878173258 (from the expression watch), it is only pasting 1878173258. I need the full value and only 2 decimal places. I am currently only calling a single variable but eventually it will be all 3.

How do I resolve this issue? Here is the code:

Sub PlaceCoordNoteDEV()
Dim startPoint As Point3d
Dim oView As View
Dim pt1 As Point3d, pt2 As String
Dim point As Point3d
Dim lngTemp As Long
Dim oMessage As CadInputMessage
Dim pt1X As Double

On Error GoTo cleanup

Do While True

' Set element template and place cell

'Show messages
ShowPrompt "Place ID Point"
ShowMessage "Select ID Point in screen"
'CadInputQueue.SendKeyin "set item toolsettings celltruescaletoggle=1"

' Commands below will use the placement point above be recorded and use
If oMessage.InputType = msdCadInputTypeDataPoint Then
pt1 = oMessage.point
pt1X = oMessage.point.X

pt2 = CDbl(pt1X)

'Get View
Set oView = oMessage.View

.SendDataPoint pt1, oView
.SendKeyin "choose none"
.SendKeyin "place note"

.SendMessageToApplication "WORDPROC", "1 PasteTextInEditor 23" + pt2
.SendDataPoint pt1, oView

'Show Messages
ShowPrompt "Select next point for Note placement"
ShowMessage "Select next point for Note placement"

If oMessage.InputType = msdCadInputTypeDataPoint Then

End If

End With

ElseIf oMessage.InputType = msdCadInputTypeReset Then
GoTo cleanup
End If

Loop

cleanup:

ShowPrompt ""
ShowMessage "Macro Exited"

End Sub

• pt1X = oMessage.point.X

pt2 = CDbl(pt1X)

pt1x is declared as Double, so you've made a copy of point.X.

pt2 is declared as a String, so I think there's typo in the above.  Try:

pt2 = CStr (pt1X)

In fact, you never use variable pt1X again, so it would be simpler to discard pt1X and write:

pt2 = CStr (oMessage.point.X)
I need the full value and only 2 decimal places

You can use VBA's Format function for better control.  For example:

pt2 = Format(oMessage.point.X, "#,##0.00")

Regards, Jon Summers
LA Solutions

Answer Verified By: Mark Winegar

• The macro does not work in CONNECT

Please start a new thread.  While VBA for CONNECT is mostly the same as V8, you are calling some MDL functions that may require some additional tweaking where you declare them.

pt2 = Format(oMessage.point.Y, "###0.00") 'Northing
pt3 = Format(oMessage.point.X, "###0.00") 'Easting

Prefer named variables to comments.  Comments wear out over time.  This expresses better your intents...

Dim easting As String
easting = Format(oMessage.point.X, "###0.00")
Dim northing As String
northing = Format(oMessage.point.Y, "###0.00")

The macro seems to work when the coords of the element are close to the global origin, but it having issues when the elements are much further from the global origin

Please provide an example!

Regards, Jon Summers
LA Solutions

• Coord Note Testing.dgnIt looks like the issue may be the number of characters allowed from the code "14":