I am trying to find the error in this lisp. It happens at the blockit function. Can someone please point it out to me and tell me what I need to do to fix it.
Thank you
(defun C:WINTRIM ( / *error* stq wq pick1 pick2 pick3 pick4 tpnt1 tpnt2 bpnt)
(setvar "cmdecho" 0)
(setq o_osmode (getvar "osmode")
o_clayer (getvar "clayer")
*error* sillerr
blss nil
)
(if (not stype) (setq stype "TS"))
(if (not width) (setq width 3))
(prompt "\nType: TS-Trim Sill/TSS-Trim Sill Surround/BS-Brick Surround/BR-Brick Rowlock")
(initget "TS TSS BS BR")
(if (/= (setq stq (getkword (strcat "\nSpecify type [TS/TSS/BS/BR]<" stype ">: "))) nil)
(setq stype stq)
)
(initget "3 4 6 8")
(if (/= (setq wq (getkword (strcat "\nSpecify width [3/4/6/8]<" (itoa width) ">: "))) nil)
(setq width (atoi wq))
)
(cond
((= stype "TS")
(initget 1)
(setq pick1 (getpoint "\nSelect left corner: "))
(initget 1)
(setq pick2 (getpoint pick1 "\nSelect right corner: "))
(setq tpnt1 (polar pick1 (angle pick2 pick1) 0.75)
tpnt2 (polar pick2 (angle pick1 pick2) 0.75)
bpnt (polar pick1 (angle pick1 pick2) (/ (distance pick1 pick2) 2))
)
(drawit stype tpnt1 tpnt2 width nil)
(blockit stype tpnt1 tpnt2 bpnt width nil blss)
)
((= stype "TSS")
(initget 1)
(setq pick1 (getpoint "\nSelect top left corner: "))
(initget 1)
(setq pick2 (getpoint pick1 "\nSelect bottom left corner: "))
(initget 1)
(setq pick3 (getpoint pick2 "\nSelect bottom right corner: "))
(initget 1)
(setq pick4 (getpoint pick3 "\nSelect top right corner: "))
(setq tpnt1 (polar pick2 (angle pick3 pick2) (+ width 0.75))
tpnt2 (polar pick3 (angle pick2 pick3) (+ width 0.75))
bpnt (polar pick1 (angle pick1 pick4) (/ (distance pick1 pick4) 2))
)
(drawit stype pick1 pick2 width nil)
(drawit stype tpnt1 tpnt2 width nil)
(drawit stype pick3 pick4 width nil)
(blockit stype tpnt1 tpnt2 bpnt width (+ (distance pick1 pick2) width) blss)
)
((= stype "BR")
(initget 1)
(setq pick1 (getpoint "\nSelect left corner: "))
(initget 1)
(setq pick2 (getpoint pick1 "\nSelect right corner: "))
(setq bpnt (polar pick1 (angle pick1 pick2) (/ (distance pick1 pick2) 2)))
(drawit stype pick1 pick2 width 2.750)
(blockit stype pick1 pick2 bpnt width nil blss)
)
((= stype "BS")
(initget 1)
(setq pick1 (getpoint "\nSelect top left corner: "))
(initget 1)
(setq pick2 (getpoint pick1 "\nSelect bottom left corner: "))
(initget 1)
(setq pick3 (getpoint pick2 "\nSelect bottom right corner: "))
(initget 1)
(setq pick4 (getpoint pick3 "\nSelect top right corner: "))
(setq tpnt1 (polar pick2 (angle pick3 pick2) width)
tpnt2 (polar pick3 (angle pick2 pick3) width)
bpnt (polar pick1 (angle pick1 pick4) (/ (distance pick1 pick4) 2))
)
(drawit stype pick1 pick2 width 3.0)
(drawit stype tpnt1 tpnt2 width 2.750)
(drawit stype pick3 pick4 width 3.0)
(blockit stype tpnt1 tpnt2 bpnt width (+ (distance pick1 pick2) width) blss)
)
)
(setvar "clayer" o_clayer)
(setvar "osmode" o_osmode)
(setvar "cmdecho" 1)
(princ)
)
;Draw Routine
(defun drawit (typ pt1 pt2 wdth lnspac / reclgth ang pt3 pt4 realnum remain
intnum offset lnpt1 lnpt2
)
(setq reclgth (distance pt1 pt2)
ang (angle pt1 pt2)
pt3 (polar pt1 (- ang (/ pi 2)) wdth)
pt4 (polar pt2 (- ang (/ pi 2)) wdth)
)
(setvar "clayer" "0")
(setvar "plinewid" 0)
(setvar "osmode" 0)
(command "-color" 6 "-linetype" "Set" "ByBlock" "")
(command "_.pline" pt1 pt3 pt4 pt2 "C")
(if (not blss) (setq blss (ssadd (entlast))) (ssadd (entlast) blss))
(if (/= lnspac nil)
(progn
(setq realnum (rtos (/ reclgth lnspac) 2
)
(setq remain (distof (substr realnum (+ (vl-string-search "." realnum) 1)) 2))
(if (>= remain 0.53125)
(setq intnum (+ (atoi realnum) 1))
(setq intnum (atoi realnum))
)
(setq offset (/ (- reclgth (* intnum lnspac)) 2))
(setq offset (+ lnspac offset))
(command "-color" 1)
(repeat (- intnum 1)
(setq lnpt1 (polar pt1 ang offset))
(setq lnpt2 (polar pt3 ang offset))
(command "_.line" lnpt1 lnpt2 "")
(ssadd (entlast) blss)
(setq offset (+ lnspac offset))
)
(command "-color" "ByLayer" "-linetype" "Set" "ByLayer" "")
)
)
)
;Block Routine
(defun blockit (typ pt1 pt2 basept wdth hgt ss / )
(setvar "filedia" 1)
(if (/= hgt nil)
(setq blk_name (strcat (itoa wdth) typ "-" (rtos (distance pt1 pt2) 2 1) " X " (rtos hgt 2 1) ".dwg"))
(setq blk_name (strcat (itoa wdth) typ "-" (rtos (distance pt1 pt2) 2 1) ".dwg"))
)
C:\Documents and Settings\bcrouse\Desktop\Library R & D Blocks\Window Trim" blk_name))
(command "_.move" ss "" basept "0,0,0")
(if (/= (findfile path) nil)
(command "_.-wblock" path "Y" "" "0,0,0" ss "")
(command "_.-wblock" path "" "0,0,0" ss "")
)
(command "_.-insert" path "S" 1 basept 0)
(setvar "filedia" 1)
)
;Error Routine
(defun sillerr (msg)
(prompt (strcat "\nError: " msg))
(command "-color" "ByLayer" "-linetype" "Set" "ByLayer" "")
(setvar "clayer" o_clayer)
(setvar "osmode" o_osmode)
(setvar "cmdecho" 1)
(princ)
)[/code]