PDA

View Full Version : Lisp Help


chadley
2008-06-27, 06:30 PM
Hi,
I'm no programmer but I found this routine from Cadalyst Magazine and did a few edits to make it work in our office. Anyway, since I’m no programmer I’m sure what I did was wrong but it actually works. The only thing I want to add is, code that deletes a line that is made with this routine. The routine is a called Shelf and Rod. It draws the closet lines on an architectural floor plan. Thing is we use ADT 2006 and so the routine in it’s original form looks for a line not a wall style. My solution was to have the user draw the line and then let routine proceed. But to clean things up a bit I would like to get rid of the line they drew to start with. In fact I would mind getting rid of the part where they have to select the line for offset. I don’t know how to do that part. Any suggestions on how to accomplish what I need?
Thanks!
(defun *error* (msg)
(setvar "OSMODE" TOSMODE)
(setvar "ORTHOMODE" TORTHOMODE)
(setvar "CLAYER" TCLAYER)
(prompt msg)
(princ)
);end defun

(DEFUN C:SHELFROD ()
(graphscr)
(setvar "CMDECHO" 0)
(setq
TOSMODE (getvar "OSMODE")
TORTHOMODE (getvar "ORTHOMODE")
TCLAYER (getvar "CLAYER")
)
;(Alert "\nDraw wall line at back of closet" )
;(setq wall(command "line"(getpoint)(getpoint) ""))
(setvar "OSMODE" 3); end
(setq
line (command "line"(getpoint "\nSelect first point at back of closet" )(getpoint "\nSelect second point at back of closet" ) "")
wallline (entsel "\nClick on wall line" )
firstendpnt (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
pnt2 (getpoint "\nSpecify point toward closet: ")
ang1 (angle firstendpnt secondendpnt)
);end setq
(if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
(setq ang1 (+ ang1 pi))
);end if

(setvar "OSMODE" 0); none
(command
"offset" 12 wallline pnt2 ""
"-layer" "m" "1- Cabinets-1" "c" "green" "1- Cabinets-1" ""
"change" "L" "" "P" "LA" "1- Cabinets-1" "lt" "dashed2" ""
"offset" 10 wallline pnt2 ""
"change" "L" "" "P" "LA" "1- Cabinets-1" "lt" "center2" ""

)


(setvar "OSMODE" TOSMODE)
(setvar "ORTHOMODE" TORTHOMODE)
(setvar "CLAYER" TCLAYER)
(princ))

(prompt "\nLoaded SHELFROD")
;;;
(C:SHELFROD)
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)

bmckenzie
2008-06-27, 09:02 PM
I am not a lips expert either, but it seems you have some un-necessary code. Since you are picking points, all you need to do is;

(setq firstendpoint (getpoint "\nSelect first point at back of closet" ))
(setq secondpoint (getpoint "\nSelect first point at back of closet" ))

There is no need to draw the line, pick the line, and then extract the endpoints from it.

I hope that helps.

CAB2k
2008-06-27, 09:08 PM
Here is an old routine you can play with.

chadley
2008-06-27, 10:35 PM
The problem is that the routine needs to draw a line so we have something to offset from. What I need is to be able to delete the original line to keep things clean. With ADT the wall styles aren't lines so we need to draw the line and then offset and finally get rid of the original line.

chadley
2008-06-27, 10:57 PM
Ha! I look at the code on the shelf routine and I figure it out. Yippee! Still not as efficient a routine as it could be but it better than what everyone is currently doing with out the routine.
Thanks a million!

CAB2k
2008-06-27, 11:51 PM
Glad it worked for you.
As it was an old routine I made a few changes. Take a look.