Campa150 Posted November 7, 2013 Share Posted November 7, 2013 i'm pretty new to Autolisp so don't really know if this can be done with a lisp but here it goes. i need a lisp that can select a block based on a attribute value, for example i have a drawing with a dozen blocks all with the same name "DFUBLANK1", this blocks have several attribute but i need to select only the block with the attribute tag "PART" with a value of "10". Any ideas? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 8, 2013 Share Posted November 8, 2013 This is close not tested ; simple find block ; by Alan H nov 2013 (setq ans (getstring "\nEnter attribute value")) (setq oldtag1 "yourattibute") ;attribute tag name (setq ss1 (ssget "x" '((0 . "INSERT") (2 . "yourblockname")(410 . "Model"))) ; change block name (setq inc (sslength ss1)) (repeat inc (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc))) )'getattributes) (if (= oldtag1 (strcase (vla-get-tagstring att))) (progn (if (= ans (vla-get-textstring att )) (progn (setq pt1 (vla-get-insertionpoint att)) (command "zoom" "c" pt1 100) ; zooms in on block ) ; end progn ) ; end if ans )); end if oldtag1 ) ; foreach att ) ; end repeat (princ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 8, 2013 Share Posted November 8, 2013 Welcome to CADTutor Try this . (defun c:Test (/ ss in sn en it ad ok) (if (setq ad (ssadd) ss (ssget "_X" (list '(0 . "INSERT") '(2 . "DFUBLANK1") '(66 . 1) (cons 410 (getvar 'CTAB)) ) ) ) (repeat (setq in (sslength ss)) (setq sn (ssname ss (setq in (1- in))) it sn ok nil ) (while (and (not ok) (/= (cdr (assoc 0 (setq en (entget (setq sn (entnext sn)))))) "SEQEND" ) ) (if (and (eq (strcase (cdr (assoc 2 en))) "PART") (eq (cdr (assoc 1 en)) "10") ) (setq ok t ad (ssadd it ad) ) ) ) ) ) (sssetfirst nil ad) (princ) ) Quote Link to comment Share on other sites More sharing options...
Campa150 Posted November 8, 2013 Author Share Posted November 8, 2013 thanks for the help guys , both work great but i'm going with Tharwat's, its more what i'm looking for. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 8, 2013 Share Posted November 8, 2013 thanks for the help guys , both work great but i'm going with Tharwat's, its more what i'm looking for. You're welcome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.