LISP2LEARN Posted June 22, 2013 Share Posted June 22, 2013 Hi guys, Need your help again on a simple conditional statement. I need to pick a block on a xref. Block must have an attribute/s. Entities inside of the block have 2 layers which is A-DOORTAG and A-TEXT. Line, leaders and circle reside on A-DOORTAG layer and the attributes on A-TEXT layer. my goal is which ever I pick (lines circle or attribute) I get the value of "e". Layer must be "A-doortag" or "a-text" Thanks! (while (or (not (setq e (nentsel "\nSelect a door tag : "))) (< (length e) 3) (not (wcmatch (strcase (cdr (assoc 8 (entget (car (last e)))))) "*|A-DOORTAG")) [color="#2e8b57"];(not (wcmatch (strcase (cdr (assoc 8 (entget (car (last e)))))) "*|A-TEXT"))[/color] ) (princ "\nObject was not a door tag.") ) Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted June 23, 2013 Share Posted June 23, 2013 1) An object can not be in two layers, so one of (not (wcmatch... is always True. This is the place where you should use OR function. 2) You've picked the wrong ename returned by nentsel. The last one contains the parent object, the Xref itself. Try this (defun sel_xref_obj (/ e) (setvar 'errno 0) (cond ((setq e (nentsel "\nSelect a door tag : ")) (if (and (> (length e) 3) (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-DOORTAG,*|A-TEXT") ; OR equivalent ;(or ; (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-DOORTAG") ; (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-TEXT") ) e (progn (princ "\nObject was not a door tag.") (sel_xref_obj)) ) ) ((= (getvar 'errno) 7) (princ "\nNothing selected.") (sel_xref_obj)) ) ) Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 23, 2013 Author Share Posted June 23, 2013 Got it now. Thanks Stefan. Works great, appreciate your help! 1) An object can not be in two layers, so one of (not (wcmatch... is always True. This is the place where you should use OR function.2) You've picked the wrong ename returned by nentsel. The last one contains the parent object, the Xref itself. Try this (defun sel_xref_obj (/ e) (setvar 'errno 0) (cond ((setq e (nentsel "\nSelect a door tag : ")) (if (and (> (length e) 3) (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-DOORTAG,*|A-TEXT") ; OR equivalent ;(or ; (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-DOORTAG") ; (wcmatch (strcase (cdr (assoc 8 (entget (car e))))) "*|A-TEXT") ) e (progn (princ "\nObject was not a door tag.") (sel_xref_obj)) ) ) ((= (getvar 'errno) 7) (princ "\nNothing selected.") (sel_xref_obj)) ) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 24, 2013 Share Posted June 24, 2013 This would be a great place for a single ssget call, using a comma separated layer string for the DXF 8 grouped pair of a given selection set filter. Much less keystrokes. 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.