PDA

View Full Version : Bored and looking to help someone who can't Lisp?


chadley
2007-10-18, 08:08 PM
I found this lisp routine a million years ago and we still use it. Maybe one of you wrote it? Anyway, I need help switching this code from selecting every thing in the drawing to letting the user select only a specific part of the drawing. Any help you can give will be greatly apprecited! I tried to figure it out but I'm too lame so it didn't work, it would only let you select one thing at a time and not use a crossing to select so that would be to tedious for everyone.

(defun c:sketchit-2(/ extDist ss i eName eList startPt endPt lineLength newStartPt newEndPt =20)
;; make sure the geometry calcualator is loaded ...
(setq qa (setvar "qaflags" 0))
(if (not cal)
(arxload "geomcal")
)
;; no do it ...
(defun *error* (msg)
(princ "This is an error")
(if qa
(setvar "qaflags" qa)
)
(setq *error* nil)
)

(setq myss (ssget "x" '((0 . "POLYLINE,LWPOLYLINE"))))

;; If POLYLINES, Expode them
(if myss
(progn
(setvar "qaflags" 1)
(command "explode" myss "")
(setvar "qaflags" 0)
)
)


(setq
extDist (getdist "\nDistance to extend: ")
ss (ssget "x" '((0 . "LINE")))
)
(if ss
(progn
(setq i 0)
(repeat (sslength ss)
(setq
eName (ssname ss i)
eList (entget eName)
startPt (cdr (assoc 10 eList))
endPt (cdr (assoc 11 eList))
lineLength (distance startPt endPt)
)
;; If Existing LINE Endpoints are not same, modify them, else do nothing
(if (not (equal startPt endPt 0.00001))
(progn
(setq newStartPt (cal "pld(endPt,startPt,lineLength + extDist)")
newEndPt (cal "pld(startPt,endPt,lineLength + extDist)")
eList (subst (cons 10 newStartPt) (assoc 10 eList) eList)
eList (subst (cons 11 newEndPt) (assoc 11 eList) eList)
)
(entmod eList)
)
)
(setq i (1+ i))
)
)
)
(setq ss nil)
(princ)
)


Thanks!!
Cynthia

kennet.sjoberg
2007-10-18, 08:45 PM
remove the "x" in the ssget statements
(ssget "x" '((0. . . . .
(ssget '((0. . . . .
will let you select multiple

or to ":S"
(ssget ":S" '((0. . . . .
will let you select single

: ) Happy Computing !

kennet

T.Willey
2007-10-18, 08:47 PM
When a routine selects all objects, there is usually a statement like
(ssget "x" .... )
To change that, just take out the "x" part, so it would look like
(ssget ..... )

Hope that helps.

Edit: Got beat to the punch.... Oh well.

chadley
2007-10-18, 09:41 PM
Thank you so much!!! I clearly over thought this and I'm so glad I posted the question! You guys are awesome my routine work perfectly now!
Thanks again!
Cynthia