Here is the lisp, but I know its not the problem, I have had this issue before. I cant, nor remember what the solution was.
Thanks.
John
; Get the four corners of the booth.
(defun booth (/ laname)
(setvar "CMDECHO" 0)
(setvar "attdia" 0)
(setq OUN (getvar "lunits")) ; remember current linear units
(setq OUP (getvar "luprec")) ; remember current units precision
(setvar "lunits" 4) ; set linear units to feet-inches
(setvar "luprec" 2) ; set units precision to nearest 1/8inch
(initget "E e P p B b C c H h T t")
(setq ln (getkword "\nPurpose of locater (E)lectric (P)anel (B)aseplate (C)olumn (H)angpoint (T)ower : "))
(if (member ln '("E" "e"))
(setq laname "Dims Electric")
)
(if (member ln '("P" "p"))
(setq laname "Dims Panel")
)
(if (member ln '("B" "b"))
(setq laname "Dims Baseplate")
)
(if (member ln '("C" "c"))
(setq laname "Dims Column")
)
(if (member ln '("H" "h"))
(setq laname "Dims Hangpoint")
)
(if (member ln '("T" "t"))
(setq laname "Dims Tower")
)
(initget "D d S s")
(setq bt (getkword "\nType of locater (D)ot (S)ymbol : "))
(if (member bt '("D" "d"))
(setq bltype "D")
)
(if (member bt '("S" "s"))
(setq bltype ln)
)
(if(not (tblsearch "layer" laname))
(command "layer" "make" laname "color" "6" "" "")
(command "layer" "set" laname "")
)
(setq pt1 (getpoint "\nLower left corner of booth: "))
(setq pt2 (getpoint "\nLower right corner of booth: "))
(setq pt3 (getpoint "\nUpper right corner of booth: "))
(setq pt4 (getpoint "\nUpper left corner of booth: "))
)
; Get the insertion point of the drop and convert to feet-inches
(defun place (/ a b c d down in over up)
(setvar "lunits" 4) ; set linear units to feet-inches
(setvar "luprec" 2) ; set units precision to nearest 1/8inch
(setq ip (getpoint "Where do you want place drop ? ")) (terpri)
(setq up (- (car pt1) (car ip))) ; subtract x value of insertion point from x value of pt1
(setq down (- (car pt2) (car ip))) ; subtract x value of insertion point from x value of pt2
(setq in (- (cadr pt1) (cadr ip))) ; subtract y value of insertion point from y value of pt1
(setq over (- (cadr pt4) (cadr ip))) ; subtract y value of insertion point from y value of pt4
(setq c (abs up)) ; get absolute value of "up" variable
(setq d (abs down)) ; get absolute value of "down" variable
(setq a (abs in)) ; get absolute value of "in" variable
(setq b (abs over)) ; get absolute value of "over" variable
(setq y (rtos (min a b))) ; get the minimum y value from the insertion pt
(setq x (rtos (min c d))) ; get the minimum x value from the insertion pt
(setq val1 (+ a c)) ; get the sum of a + c
(setq val2 (+ a d)) ; get the sum of a + d
(setq val3 (+ b c)) ; get the sum of b + c
(setq val4 (+ b d)) ; get the sum of b + d
(setq sect (min val1 val2 val3 val4)) ; find out which sum is the least
)
; Determine which section of the drawing you are working in
(defun symbol ()
(if (= sect val1)
(setq bn (strcat "DROPLL-" bltype)) ;if value 1 is the least use block "dropll-"
)
(if (= sect val2)
(setq bn (strcat "DROPLR-" bltype)) ;if value 2 is the least use block "droplr-"
)
(if (= sect val3)
(setq bn (strcat "DROPUL-" bltype)) ;if value 3 is the least use block "dropul-"
)
(if (= sect val4)
(setq bn (strcat "DROPUR-" bltype)) ;if value 4 is the least use block "dropur-"
)
)
; Insert the block and ask for the next insertion point
(defun setsymbol ()
(setq sf (getvar "dimscale")) ; uses the current dimscale for the scale of the block
(setvar "attdia" 0)
(command "insert" bn ip sf sf "0" x y) ; inserts the block based on the calculated information
(setvar "lunits" OUN) ; set linear units to original setting
(setvar "luprec" OUP) ; set units precision to original settings
(setvar "attdia" 1)
)
; Create the loop
(defun loop ()
(place) ; runs the place function
(symbol) ; runs the symbol function
(setsymbol) ; runs the setsymbol function
)
; Run the program and keep looping until user CRTL-C
(defun c:drop (/ bltype bn bt ln ip OUN OUP pt1 pt2 pt3 pt4 sect val1 val2 val3 val4 x y) ; this runs the entire program
(booth)
(place)
(symbol)
(setsymbol)
(repeat 75 (loop)) ; this creates the loop it will ask for up to 75 outlets
(princ)
)