- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been trying to make a LISP program that checks the value of specific attributes within a block, and if the value is not what it should be, it logs it as an error. I would like to use this as a final check for those little "gotchas" before submitting our drawings.
I've tried to use code from various posts across the internet, but don't have enough skills with LISP yet to make it work properly. This is one template that I've found to be closest to my end goal:
(vl-load-com) (defun C:demo (/ blockdata blockdef blockname blockref en ent tmp) (if (setq ent (entsel "\n >> Select a block instance >>")) (progn (setq en (car ent) blockref (vlax-ename->vla-object en) blockname (vla-get-effectivename blockref) blockdef (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blockname) ) (if (equal :vlax-true (vla-get-hasattributes blockref)) (progn (princ "\n") (princ en) (princ "\n") (princ blockref) (princ "\n") (princ blockname) (princ "\n") (princ blockdef) (princ "\n") (princ "\n") (princ "\n") (foreach attrib (vlax-invoke blockref 'GetAttributes) (vlax-for item blockdef (if (equal (vla-get-objectname item) "AcDbAttributeDefinition") (progn (if (equal (vla-get-tagstring attrib) (vla-get-tagstring item)) (progn (setq tmp (list (vla-get-promptstring item) (vla-get-tagstring attrib) (vla-get-textstring attrib))) (setq blockdata (cons tmp blockdata)) ) ) ) ) ) ) (setq blockdata(reverse blockdata) ) (foreach lst blockdata (princ (strcat "\n Prompt: " (car lst) " *** Tag: " (cadr lst) " *** Value: " (last lst))) ) ) ) ) (princ "\n >> Nothing selected. Try again...") ) (princ) )
However, I would like to delete the following line:
(if (setq ent (entsel "\n >> Select a block instance >>")) (progn
And instead, I would like the block that the LISP program is looking for, to be predefined within the LISP program. So, no user input. From there, the LISP program checks attribute values of that block for other predefined values. Can anyone help?
Thanks,
Rob
Solved! Go to Solution.