aloy Posted June 22, 2012 Share Posted June 22, 2012 (edited) I have a list given below: (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)))) 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 p1(cadr (car l))) (while (/= l nil) (setq l(cdr l)) (setq p2(cadr (car l))) (command "line" p1 p2 "") (setq p1 p2) ) Edited June 24, 2012 by aloy As advised Quote Link to comment Share on other sites More sharing options...
SLW210 Posted June 22, 2012 Share Posted June 22, 2012 aloy, Please read the CODE POSTING GUIDELINES and edit your post. I moved this thread to the AutoLISP, Visual LISP & DCL forum. Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 22, 2012 Share Posted June 22, 2012 I suspect that is an interference with current Osnap mode – please adjust you code as below and see if help: (command "[color=red]_[/color]line" [color=red]"_NON"[/color] p1 [color=red]"_NON"[/color] p2 "") Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 22, 2012 Share Posted June 22, 2012 (edited) 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: (while (cadr l) (command "_.line" "_non" (cadar l) "_non" (cadadr l) "") (setq l (cdr l)) ) (mapcar '(lambda ( a b ) (command "_.line" "_non" (cadr a) "_non" (cadr b) "")) l (cdr l)) Edit: Added "" to Line Command - thanks pBe! Edited June 23, 2012 by Lee Mac Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 22, 2012 Share Posted June 22, 2012 I'd tried to clean up your code a bit: (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)) See if that helps. -David Quote Link to comment Share on other sites More sharing options...
aloy Posted June 22, 2012 Author Share Posted June 22, 2012 aloy, Please read the CODE POSTING GUIDELINES and edit your post. I moved this thread to the AutoLISP, Visual LISP & DCL forum. 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 Quote Link to comment Share on other sites More sharing options...
aloy Posted June 23, 2012 Author Share Posted June 23, 2012 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 Quote Link to comment Share on other sites More sharing options...
aloy Posted June 23, 2012 Author Share Posted June 23, 2012 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 Quote Link to comment Share on other sites More sharing options...
aloy Posted June 23, 2012 Author Share Posted June 23, 2012 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 Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 23, 2012 Share Posted June 23, 2012 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. (setq myOsm (getvar "OSMODE")) (setvar "OSMODE" 0) ;;; code (setvar "OSMODE" myOsm) 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2012 Share Posted June 23, 2012 Hi Lee Mac,Thanks for the reply. However the code did not work. Which code did you test? The while loop or the mapcar iteration? What error do you receive, if any? Looking back at both of my examples, I don't see why it should fail... Quote Link to comment Share on other sites More sharing options...
pBe Posted June 23, 2012 Share Posted June 23, 2012 maybe... (command "_.line" "_non" (cadar l) "_non" (cadadr l) [b][color=blue]""[/color][/b]) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2012 Share Posted June 23, 2012 maybe... (command "_.line" "_non" (cadar l) "_non" (cadadr l) [b][color=blue]""[/color][/b]) Ah yes, of course! Thanks pBe, I have updated my earlier code Quote Link to comment Share on other sites More sharing options...
pBe Posted June 23, 2012 Share Posted June 23, 2012 Ah yes, of course! Thanks pBe, I have updated my earlier code My pleasure Cheers Quote Link to comment Share on other sites More sharing options...
aloy Posted June 23, 2012 Author Share Posted June 23, 2012 Sorry, Lee Mac, I only hand copied the two codes. When I copied and pasted, the mapcar worked very well. How ever in both occations the while loop did not draw anything and the list emptied. Thank you very much for welcoming me to the forum. Aloy Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 23, 2012 Share Posted June 23, 2012 Welcome to CADTutor, aloy! FWIW - You may want to consider (if you haven't already), asking your employer to provide you with an AutoCAD Vertical such as Civil 3D, given that you're needing to do roadway alignments, etc... My $0.02, anyway. Quote Link to comment Share on other sites More sharing options...
aloy Posted June 23, 2012 Author Share Posted June 23, 2012 Thank you, RenderMan. I am from a third world country, working in a rich fairly developed one from ASEAN, now on my own. I wanted to see how civil- 3D look like and tried to down load a trial pack on the internet. My connection needed 7 hours and I gave up. I have a reasonable knowledge on the design process and have samples of drawings generated by expensive packages. These packages run on their own platforms. My aim is to develop something that can run in AutoCAD and is also affordable to an engineer or a small company from a third world country. Are there any other cheap version that can run inside AutoCAD and generate drawings needed?. Regards, Aloy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.