BasePoint Example

Using Programming Languages other than VBA

Sub Example_BasePoint()
	' This example creates a ray object. It then finds the
	' base point of the ray, changes the base point, and
	' queries the new base point.
	Dim basePoint(0 To 2) As Double
	Dim directionVec(0 To 2) As Double
	Dim rayObj As AcadRay

	' Establish the base point and directional vector for the ray
	basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#
	directionVec(0) = 1#: directionVec(1) = 1#: directionVec(2) = 0#

	' Create a Ray object in model space
	Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, directionVec)

	ThisDrawing.Regen True
	MsgBox "A new Ray has been added.", vbInformation

	' Define a new base point
	Dim newBase(0 To 2) As Double
	newBase(0) = 4#: newBase(1) = 2#: newBase(2) = 0#

	' Update the ray using the new base point
	rayObj.basePoint = newBase
		
	' Query the new basepoint for the Ray
	Dim currBase As Variant	' Note that return from basepoint property is Variant and not a SafeArray
	Dim msg As String
	currBase = rayObj.basePoint
	msg = currBase(0) & ", " & currBase(1) & ", " & currBase(2)

	ThisDrawing.Regen True
	MsgBox "We've just changed the basepoint of the new Ray to: " & msg, vbInformation
End Sub

 

   Comments?