type mismatch (error13) - get coords off AcadPoint

type mismatch (error13) - get coords off AcadPoint

Anonymous
Not applicable
1,167 Views
2 Replies
Message 1 of 3

type mismatch (error13) - get coords off AcadPoint

Anonymous
Not applicable

Hi, is there a way to get coords of a defined Acadpoint ? 

If I want to "print" the coords it says "error 13 - type mismatch"

Any idea why ? Thanks.

 

Sub point()
Dim pointObj As AcadPoint
Dim location(0 To 2) As Double
Dim retCoord As Variant
location(0) = 5#: location(1) = 5#: location(2) = 0#
Set pointObj = ThisDrawing.ModelSpace.AddPoint(location)
retCoord = pointObj.Coordinates
Debug.Print retCoord
End Sub
0 Likes
Accepted solutions (1)
1,168 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

You probably already knew that AcadPoint.Coordinate is Variant type (an array of 3 Double values).

 

Debug.Print can print data types that can be implicitly converted to a string value by VBA. In your case, VBA cannot do the conversion, so you need to do the print like this:

 

Debug.Print retCoord(0) & ", " & retCoord(1) & ", " & retCoord(2)

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

That's it. You're right I already tried to print the entitites of the arry, didn't work though. But your code works, thanks.

0 Likes