IanJC Posted July 19, 2010 Posted July 19, 2010 Hi Everybody, I need some help with my AutoLISP script. I work for a decking company and am trying to streamline some of our layout procedures. The problem I'm having is that when the program enters my loop, it doesn't work correctly. Every loop interation is supposed to increment the x and y values slightly, exactly like an array. The array cycles correctly for all interations, but it will not draw the lines in the proper spots. For example a line of length 10000 with a deck size of 500 should have 20 interations, and therefore 20 lines layed out like an array. It preforms the loop 20 times, but does not draw 20 lines at the points where it's supposed to. I've checked that the line values are being incremented correctly and they are, it has to be a problem with the way I'm using the line command or something. I've attached the lsp file and a drawing with some lines to select to see what I mean. Any help would be great, I'm stumped. deckLines.lsp deckTest.dwg Quote
rkmcswain Posted July 19, 2010 Posted July 19, 2010 Only took a quick look at your code, but since you are using the (command) function to draw the lines, make sure that object snaps are disabled. My guess is that a running snap is on and the lines you are drawing are snapping to something else instead of going to the coordinate provided. Quote
profcad Posted July 20, 2010 Posted July 20, 2010 I got the program to work fine. I think your problem may be the direction that each of the lines are drawn. In the graphic below, the drawing on the left had the lines drawn in the same direction. The one on the right, one was drawn right to left and the other left to right. Quote
IanJC Posted July 20, 2010 Author Posted July 20, 2010 Thank you both for your replies, the problem I was having was the OSNAPs - I hadn't even considered the other issue but that's something I'm going to have to address now too. Quote
BIGAL Posted July 21, 2010 Posted July 21, 2010 (edited) I put this into nearly every lisp I do (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) ;;;at end (setvar "osmode" oldsnap) Edited July 21, 2010 by rkmcswain add CODE tags Quote
rkmcswain Posted July 21, 2010 Posted July 21, 2010 I put this into nearly every lisp I do (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) ;;;at end (setvar "osmode" oldsnap) It's good to have an error handler too in case the routine ends before that last line executes, but if you don't, then you should consider just turning off object snap instead of setting the value of osmode to 0. This way, if the last line never executes, the object snap settings are not lost. ;;; example from http://forums.autodesk.com/t5/AutoCAD-2011/Aperture-Box-and-OSMODE/m-p/2673449#M1148 ;;; turns off running snaps (setvar "OSMODE" (logior (getvar "OSMODE") 16384)) ;;; restores running snaps (setvar "OSMODE" (logand (getvar "OSMODE") (~ 16384))) Quote
Freerefill Posted July 21, 2010 Posted July 21, 2010 I can't tell you how many times I've had issues with osnaps fouling up my LISPs (ok well, technically the reverse...). At first I turned them off within the code, but with so many different people in my office using so many different versions of AutoCAD, and each version tweaked to their personal preferences, not to mention my own inexperience, I had a lot of errors in my code which meant the osnaps turned off and stayed off. The error handling was nice, but I kept forgetting to put that into my code. My solution: mash F3 before running a LISP. Quote
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.