Print Page | Close Window

Simple Lisp Problem?

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DXF formats, Design Review, AutoCAD web, Drive, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=4805
Printed Date: 11.Jun.2026 at 22:45


Topic: Simple Lisp Problem?
Posted By: jpkibble
Subject: Simple Lisp Problem?
Date Posted: 19.Nov.2010 at 17:01
I've recently been getting into Lisp with AutoCAD2006 with some success, however the following routine is giving me a headache.

It should draw a simple array of vertical lines 100 high at 25 unit intervals, it works fine but after a few test runs it starts doing funny things, missing every other line...missing lots of random lines or even spuriously joining lines to nearby objects. All very strange - have you any ideas why it might be happening?

(defun c:SPR ()
(setq leng (getint "Enter Length of Section in Metres:"))
(setq sectionstart (getpoint "\nPick Insertion point:"))
(setq aa (car sectionstart))
(setq bb (cadr sectionstart))
(setq rptn (+ 1 (fix (/ leng 25))))
(command "line" (list (+ aa leng) bb) (list (+ aa leng) (+ bb 100)) "")
; Repeat loop starts here
(repeat rptn
(command "line" (list aa bb) (list aa (+ bb 100) ) "")
(setq aa (+ aa 25))
)
; Repeat loop stops here
)






Replies:
Posted By: CarlB
Date Posted: 20.Nov.2010 at 07:20
Sounds like a common problem, for people learning Lisp...

You have a running Osnap set, so line snaps to an endpoint rather than the desired coordinate. It's erratic because it depends on the zoom level/pickbox size.


Posted By: jpkibble
Date Posted: 20.Nov.2010 at 08:55
That's great - problem solved with the use of OSMODE.

Thanks.Clap



Print Page | Close Window