hello to everyone.
Attached is a lisp file. Its just a simple routine that could create new segments out of a selected line. Lisp is not yet complete.. Here is the problem, first, create a line (0,0,0) to (10,0,0), just to make it simple. Next run the lisp. Specify 5 as the number of segments. It will create a line of zero length at (0,0,0). In the lisp, put a semicolon or delete the line that states, (command "line" New_Start Pt_End ""), then run the lisp. In the command prompt, Pt_End has a coordinate (2,0,0).
Question is what happened? Why does the line that must have coordinates of (0,0,0) (2,0,0) becomes (0,0,0) (0,0,0)? Even if you type in the command prompt !Pt_End, it has a value of (2,0,0).. Can anyone help?
Thanks..
;this lisp will divide a selected line into segments, as specified by the user.
(defun c:qaz ()
(line_segments)
)
(defun line_segments (/ Line_Name)
(setq
ss_Line (ssget)
Line_Name (ssname ss_Line 0)
Line_Property (vlax-ename->vla-object Line_Name)
Line_Length (vlax-get Line_Property 'Length)
Start_Point (vlax-get Line_Property 'StartPoint)
End_Point (vlax-get Line_Property 'EndPoint)
Line_Rotation (vlax-get Line_Property 'Angle)
No_of_Segments (getreal "\nEnter number of segments: ")
New_Distance (/ Line_Length No_of_Segments)
)
;;getting the x,y,z distances
(setq
X_Coordinate (/ (- (car End_Point) (car Start_Point)) No_of_Segments)
Y_Coordinate (/ (- (cadr End_Point) (cadr Start_Point)) No_of_Segments)
Z_Coordinate (/ (- (caddr End_Point) (caddr Start_Point)) No_of_Segments)
)
(setq Counting_Number 1)
;;creating the segments
;(repeat No_of_Segments
(setq
New_Start (list (* (car Start_Point) Counting_Number) (* (cadr Start_Point) Counting_Number) (* (caddr Start_Point) Counting_Number))
Pt_End (list (+ (car New_Start) X_Coordinate) (+ (cadr New_Start) Y_Coordinate) (+ (caddr New_Start) Z_Coordinate))
)
(command "line" New_Start Pt_End "")
;(setq Counting_Number (+ 1 Counting_Number))
;)
)