Autolisp won't input a location

Autolisp won't input a location

Anonymous
Not applicable
966 Views
4 Replies
Message 1 of 5

Autolisp won't input a location

Anonymous
Not applicable

I have used this lisp for quite awhile.  It basically takes 4 points within a drawing, grabs a block and inserts the location within those 4 points.  The lisp wasnt changed at all.

 

Now when I insert the block it only inputs the default value of the block.  I have had this problem in the past and somehow came up with a solution, it was either a variable or maybe even a dll file that I had to replace.

 

I am not an autolisp expert, but its something in Autocad itself I have to fix.  I recently installed Router Cim on my machine and Im pretty sure it was the issue, because everything was working fine before then.

 

Thanks.

 

John

0 Likes
Accepted solutions (2)
967 Views
4 Replies
Replies (4)
Message 2 of 5

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

I have used this lisp for quite awhile.  

.... 

Now when I insert the block it only inputs the default value of the block.  

.... 

Thanks.

 

John


Mind showing us the lisp routine?

 

insert the block via routine or the use of native insert command?

 

If by that you mean attribute values?  ATTREQ is 0

or

Rotation/Scale/Insertion point?  Cant really help you there unless we see the code.

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

 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)
)

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....

Now when I insert the block it only inputs the default value of the block.

....

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.

....


I agree with @pbejse in Post 2 -- if by "default value" you mean it uses default Attribute values rather than those supplied by the code, you probably have the ATTREQ System Variable set to 0.  One could say that the code is the problem, since it should include setting ATTREQ to 1.  ATTDIA by itself isn't enough.

 

There are various improvements I could suggest about the code, but first see whether changing ATTREQ  to 1 solves the problem.

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable

My bad I just tried it.  ATTREQ set to 1 fixed my problem.

 

Thank You.

 

John

0 Likes