Jump to content

Stuck on OR function


LISP2LEARN

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...