place a circle if the attribute value is less than 20.0

place a circle if the attribute value is less than 20.0

nanja_c86
Enthusiast Enthusiast
398 Views
4 Replies
Message 1 of 5

place a circle if the attribute value is less than 20.0

nanja_c86
Enthusiast
Enthusiast

I have a Lisp code designed to place a circle if the value is less than 20.0, but it's not functioning properly. Could you please review and correct the Lisp code for me?

(defun c:PlaceCircle ()
(vl-load-com)
(setq blockName "DN_EOL")
(setq attributeName "HIGH_DIGITAL")
(setq circleDiameter 40.0)

(setq blk (tblsearch "block" blockName))
(if blk
(progn
(setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 blockName))))
(if ss
(repeat (sslength ss)
(setq ent (ssname ss 0))
(setq atts (entget ent))
(setq attValue nil)
(foreach att atts
(if (eq (car att) (cons 2 attributeName))
(setq attValue (cdr att))
)
)
(if (and attValue (< (atof attValue) 20.00))
(progn
(setq insertPt (cdr (assoc 10 (entget ent))))
(command "_CIRCLE" insertPt circleDiameter)
)
)
)
)
)
)
(princ)
)

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

ВeekeeCZ
Consultant
Consultant
Accepted solution

Where is the code coming from? Whoever made this should learn how to get attributes.

 

(vl-load-com)

(defun c:AttCheck ( / b a v r s i e x)

  (setq b "DN_EOL"
	a "HIGH_DIGITAL"
	v 20
	r 20)


  (if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 b))))
    (repeat (setq i (sslength s))
      (and (setq e (ssname s (setq i (1- i))))
	   (not (vl-catch-all-error-p (setq x (vl-catch-all-apply 'getpropertyvalue (list e a)))))
	   (< (atof x) v)
	   (entmake (list '(0 .  "CIRCLE") (assoc 10 (entget e)) (cons 40 r))))))
  (princ)
  )

 

0 Likes
Message 3 of 5

nanja_c86
Enthusiast
Enthusiast

@ВeekeeCZ 

I'm uncertain about the author of this Lisp code. Thank you for your assistance; it's now functioning perfectly. I appreciate your help.

0 Likes
Message 4 of 5

CLL_PBE
Contributor
Contributor

@nanja_c86 wrote:

I have a Lisp code designed to place a circle if the value is less than 20.0, 


You mean only for the value "HIGH DIGITAL" ? is it targeting the two other tags?  and is the target always less than 20? or does it depend on the values of the two other attributes? 

 

0 Likes
Message 5 of 5

nanja_c86
Enthusiast
Enthusiast
@CLL_PBE
its only for the value "HIGH DIGITAL" tag. It will be Always less than 20. It will not depend on other two tag values.
0 Likes