aloy,
Please read the CODE POSTING GUIDELINES and edit your post.
I moved this thread to the AutoLISP, Visual LISP & DCL forum.


Registered forum members do not see this ad.
I have a list given below:
When it is loaded and run with the code below the line segents drawn are not as expected. What seems to be the problem(setq l '((0.0 (298.546 228.499 0.0)) (20.0 (316.873 236.508 0.0)) (40.0 (335.2 244.516
0.0)) (60.0 (353.526 252.524 0.0)) (76.7565 (368.881 259.234 0.0)) (80.0
(371.853 260.533 0.0)) (100.0 (390.094 268.732 0.0)) (120.0 (407.932 277.769
0.0)) (126.756 (413.792 281.131 0.0)) (140.0 (425.028 288.076)) (140.0 (441.616
299.307)) (160.0 (457.594 311.333)) (180.0 (472.95 324.142)) (200.0 (487.648
337.704)) (220.0 (501.649 351.982)) (240.0 (514.919 366.943)) (260.0 (527.424
382.54)) (280.0 (539.135 398.759)) (300.0 (550.02 415.535)) (320.0 (560.053
432.834)) (320.916 (560.492 433.63)) (340.0 (568.86 450.673 0.0)) (360.0
(576.592 469.116 0.0)) (370.916 (580.594 479.272 0.0))))
(setq p1(cadr (car l)))
(while (/= l nil)
(setq l(cdr l))
(setq p2(cadr (car l)))
(command "line" p1 p2 "")
(setq p1 p2)
)
Last edited by aloy; 24th Jun 2012 at 05:34 am. Reason: As advised
aloy,
Please read the CODE POSTING GUIDELINES and edit your post.
I moved this thread to the AutoLISP, Visual LISP & DCL forum.
“A narrow mind and a fat head invariably come on the same person” Zig Zigler
![]()
I suspect that is an interference with current Osnap mode – please adjust you code as below and see if help:
Code:(command "_line" "_NON" p1 "_NON" p2 "")
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Welcome to CADTutor
Object Snap may be affecting your use of the Line command, causing points to jump to the nearest osnap point. To avoid this, use "_non" to ignore Object Snap when supplying points.
Here are some alternatives to your code:
Code:(while (cadr l) (command "_.line" "_non" (cadar l) "_non" (cadadr l) "") (setq l (cdr l)) )Edit: Added "" to Line Command - thanks pBe!Code:(mapcar '(lambda ( a b ) (command "_.line" "_non" (cadr a) "_non" (cadr b) "")) l (cdr l))
Last edited by Lee Mac; 23rd Jun 2012 at 12:47 pm.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
I'd tried to clean up your code a bit:
See if that helps. -DavidCode:(defun c:test (/ l p1 p2) (setq l '( (0.0 (298.546 228.499 0.0)) (20.0 (316.873 236.508 0.0)) (40.0 (335.2 244.516 0.0)) (60.0 (353.526 252.524 0.0)) (76.7565 (368.881 259.234 0.0)) (80.0 (371.853 260.533 0.0)) (100.0 (390.094 268.732 0.0)) (120.0 (407.932 277.769 0.0)) (126.756 (413.792 281.131 0.0)) (140.0 (425.028 288.076)) (140.0 (441.616 299.307) ) (160.0 (457.594 311.333)) (180.0 (472.95 324.142)) (200.0 (487.648 337.704)) (220.0 (501.649 351.982)) (240.0 (514.919 366.943)) (260.0 (527.424 382.54)) (280.0 (539.135 398.759)) (300.0 (550.02 415.535)) (320.0 (560.053 432.834)) (320.916 (560.492 433.63)) (340.0 (568.86 450.673 0.0)) (360.0 (576.592 469.116 0.0)) (370.916 (580.594 479.272 0.0)))) (while (> (length l) 1) (setq p1 (cadr (car l))) (setq p2 (cadr (cadr l))) (command "line" p1 p2 "") (setq l (cdr l))) (prin1))
R12 (Dos) - A2K


Thanks for the advice. The codes used to generate the horizonal alignment which includes straight sections, spirals and circular curves which was developed over 20 year ago using AutoCAD v. 1.2 is also mine. These programs were used to generate verticle alignments, long sections, cross sections and earthworks calculations. Some highways were built using them. Since I moved to other areas of civil engineering I did not have the opportunity to further develop them. My attempt now is to develop programmes to design the geomatric elements according to Uk's TD 9, TD 22 etc. interactively on a topo plan in Autocad. In this connection, I have already received help in this forum and I am gratful for that.
Aloy


Hi David,
Thaks for the reply. However it did not work. From the replies in this forum, I realised that the problem is due to the object snap being on during the exection. My code given in the posting works when the object snap is off.
Redards,
Aloysius. H


Hi Lee Mac,
Thanks for the reply. However the code did not work. I remember using lambda fuctions more than twenty years ago when I was developing a routine for earthworks calculations. It was very useful and there were no internet then. I had to do reseach work in British council Library to 'discover' them.
My code in the posting works when object snap is off.
Regards,
Aloysius. H


Hi Mircea,
Thanks for the help. It worked when using the code sugested by you. It also works with the code in my posting when object snap is off.
Regards,
Aloysius.H
Registered forum members do not see this ad.
Inputting "_NON" before supplying points is in fact overriding the current Osnap settings with None mode; is equivalent with setting Osnap to Off, but you don't need to pay attention to manage it manually (set Off before running the routine, restoring it later).
Alternatively, when the code is more complex, to don’t have to pay attention to add the "_NON" each time is required, you can retain current Osnap value (system variable OSMODE), disable it, run your code and restore it with the previous value before exit.
An advanced solution that isn't affected by current Osnap is to directly add or modify the entities into drawing's database - please check the ENT* functions family.Code:(setq myOsm (getvar "OSMODE")) (setvar "OSMODE" 0) ;;; code (setvar "OSMODE" myOsm)
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Bookmarks