By using the methods provided by the Utility object, you can quickly solve a mathematical problem or locate points on your drawing.
By using methods on the Utility object, you can do the following:
This example uses the GetDistance method to obtain the point coordinates, and the MsgBox function to display the calculated distance.
(vl-load-com)
(defun c:Ch3_GetDistanceBetweenTwoPoints()
(setq acadObj (vlax-get-acad-object)
doc (vla-get-ActiveDocument acadObj)
utilityObj (vla-get-Utility doc))
;; Return the value entered by user. A prompt is provided.
(setq returnDist (vla-GetDistance utilityObj nil "\nPick two points: "))
(alert (strcat "The distance between the two points is: " (rtos returnDist 2)))
)
Sub Ch3_GetDistanceBetweenTwoPoints() Dim returnDist As Double ' Return the value entered by user. A prompt is provided. returnDist = ThisDrawing.Utility.GetDistance(, "Pick two points: ") MsgBox "The distance between the two points is: " & returnDist End Sub