A construction xline can be placed anywhere in 3D space and extends to infinity in both directions.
To create an xline, use the AddXLine method. This method specifies the line by the two-point method; you enter or select two points to define the orientation. The first point, the root, is considered the midpoint of the construction line.
Add a construction line
The following example code creates an XLine object using the two points (5, 0, 0) and (1, 1, 0).
- AutoLISP
-
(vl-load-com) (defun c:Ch3_AddXLine() (setq acadObj (vlax-get-acad-object) doc (vla-get-ActiveDocument acadObj) moSpace (vla-get-ModelSpace doc)) ;; Define the xline (setq basePoint (vlax-3d-point 2 2 0) directionVec (vlax-3d-point 1 1 0)) ;; Create the xline in model space (setq xlineObj (vla-AddXLine moSpace basePoint directionVec)) (vla-ZoomAll acadObj) )
- VBA (AutoCAD Only)
-
Sub Ch3_AddXLine() Dim xlineObj As AcadXline Dim basePoint(0 To 2) As Double Dim directionVec(0 To 2) As Double ' Define the xline basePoint(0) = 2#: basePoint(1) = 2#: basePoint(2) = 0# directionVec(0) = 1#: directionVec(1) = 1#: directionVec(2) = 0# ' Create the xline in model space Set xlineObj = ThisDrawing.ModelSpace.AddXLine(basePoint, directionVec) ThisDrawing.Application.ZoomAll End Sub