- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Definite LISP newbie. This is my first. I know, big undertaking. I have been working this lisp routine that you select the wall, select point on wall for the start of the break, select door width and a point on perpendicular line and it will break both lines and draw the ends of the walls in on the correct layer, and inserts the door block on the correct layer. I have 4 possible scenarios for the wall layers, (EXST-WALL-INTR, EXST-WALL EXTER, NEW-WALL-INTR, NEW-WALL-EXTR) and 4 scenarios for the door layer (EXST-DOOR-EXTR, EXST-DOOR-INTR, NEW-DOOR-EXTR, NEW-DOOR-INTR ) I have accomplished this task . . . . to an extent. I have figured out setting the wall layers. The issue is having 4 possibilities of door layers based on what wall layer is picked. I have made 2 lisp routines, one for existing and one for new. I would like to have one routine for all scenarios. I am wonder if there is a way to to have one routine (Door.lisp) that can process all existing and new conditions and set appropriate layers. I have found help from various sites on the internet to put this routine together but can seem to find an answer to what I am looking for. Hence the reason for this post. Here is what I have found, pieced together and figured out so far.
;Program to cut door opening in wall and insert door on correct layer -- DoorExst.lsp
(defun c:doorexst (/ pt1 pt2 pt3 pt4 ang1 ang2 dst1 osnap1 str1 clyr wlyr bfind msg)
(setvar "cmdecho" 0)
(command "-purge" "b" "door" "n")
(setq osnap1 (getvar "osmode"))
(setq clyr (getvar "clayer"))
(defun *error* (msg)
(setvar "osmode" osnap1)
(setvar "clayer" clyr)
(princ msg)
(princ)
)
(setvar "osmode" 512) ;nearest osnap mode
(setq wlyr (entget (car (entsel "\nSelect Wall: "))));end setq
(setq pt1 (getpoint "\nSelect point on wall to start point of opening: ")) ;get first break point
(setq pt2 (getpoint pt1 "\nEnter endpoint of opening: ")) ;get second break point
(setvar "osmode" 128) ;perpend osnap mode
(setq pt3 (getpoint pt1 "\nSelect opposite side of wall: "));get 2nd line
(Setvar "osmode" 0) ;no osnap mode
(setq ang1 (angle pt1 pt3)) ;find angle btwn lines
(setq dst1 (distance pt1 pt3)) ;find dist. btwn lines
(setq pt4 (polar pt2 ang1 dst1)) ;derive pt4 on 2nd line
(setq ang2 (* (angle pt1 pt2)57.2958)) ;find angle for door insertion
(setvar "clayer" (cdr (assoc 8 wlyr);end set current layer
(command
"break" pt1 pt2 ;break 1st line
"break" pt3 pt4 ;break 2nd line
"line" pt1 pt3 "" ;close ends of lines
"line" pt2 pt4 ""
);end command
(defun intr ()
(setvar "clayer" "exst-door-intr")
);end intr
(defun extr ()
(setvar "clayer" "exst-door-extr")
);end extr
(initget "Exterior Interior");end initget
(setq str1 (getkword "Is this an Exterior or Interior door?<Exterior/Interior>:"));end str1
(if (= str1 "Exterior")
(extr)
(intr)
);end if
(defun bfind (/ bfind)
(setq bfind (tblsearch "block" "standards"))
(if (not bfind)(command "-insert" "standards.dwg=" "0,0" "" "" ""))
(princ "Standards is already inserted. ")
(command "_.erase" "l" "")
);end bfind
(bfind)
(princ)
(command "-insert" "door" pt3 1 1 ang2)
(command "draworder" "l" "" "b")
(setvar "clayer" clyr)
(setvar "osmode" osnap1)
(setvar "cmdecho" 1)
(princ)
);end doorexst
Any help would be greatly appreciated. Also, I know the structure is probably less than desirable. All suggestions on lisp structure are welcome as well. New to these forums, if this needs to be move to a more appropriate location feel free to move.
Thanks in advance,
Scott
Solved! Go to Solution.