Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

need explanation????

3 REPLIES 3
Reply
Message 1 of 4
zaldy
137 Views, 3 Replies

need explanation????

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))
;)
)

3 REPLIES 3
Message 2 of 4
krispy
in reply to: zaldy

you may have osnaps turned on? try changing this line:
{code:lisp}(command "line" New_Start Pt_End ""){code}
to:
{code:lisp}(command "line" (osnap New_Start "none") (osnap Pt_End "none") ""){code}

you can also change the setting for "osmode" programmatically to turn off osnaps
Message 3 of 4
Anonymous
in reply to: zaldy

(setq OSMODEOLD (getvar "OSMODE"))
(setvar "OSMODE" 0)
..
..
..
your code
..
..
..
(setvar "OSMODE" OSMODEOLD)


zaldy@play wrote:

> 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))
> 😉
> )
>
Message 4 of 4
zaldy
in reply to: zaldy

Geez, I forgot about the osnaps!

I thought there was something wrong with mixing visual lisp with autolisp..

Thank You everyone.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost