DirectionVector Example

Using Programming Languages other than VBA

Sub Example_DirectionVector()
	' This example creates a ray and then changes the direction vector
	' for the ray.

	Dim rayObj As AcadRay
	Dim basePoint(0 To 2) As Double
	Dim SecondPoint(0 To 2) As Double
	Dim newDirectionVec(0 To 2) As Double

	basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#
	SecondPoint(0) = 1#: SecondPoint(1) = 3#: SecondPoint(2) = 0#

	' Create a Ray object in model space
	Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, SecondPoint)
	ZoomAll
	MsgBox "The ray has a direction vector of " & rayObj.DirectionVector(0) & ", " & rayObj.DirectionVector(1) & ", " & rayObj.DirectionVector(2), vbInformation, "DirectionVector Example"

	' Change the direction vector
	newDirectionVec(0) = 3#: newDirectionVec(1) = 1#: newDirectionVec(2) = 0#
	rayObj.DirectionVector = newDirectionVec
		
	' Query the new direction vector for the Ray
	Dim retDir As Variant			' Note that return from DirectionVector property is Variant and not a SafeArray
	retDir = rayObj.DirectionVector

	ThisDrawing.Regen True
	MsgBox "The direction vector of the ray has been changed to " & rayObj.DirectionVector(0) & ", " & rayObj.DirectionVector(1) & ", " & rayObj.DirectionVector(2), vbInformation, "DirectionVector Example"

End Sub

 

   Comments?