JovanG Posted January 27, 2021 Share Posted January 27, 2021 Hi dear team. Wish you a great day I was wondering if there is a way to know if a DXF property exist on selected objects: For example: (setq ss (ssget "something")) (if (exist DXF code 3 in ss) (prompt "\nThe DXF code 3 exist in selected object") (prompt "\nThe DXF code 3 doesn`t exist in selected object")) Quote Link to comment Share on other sites More sharing options...
pkenewell Posted January 27, 2021 Share Posted January 27, 2021 (edited) @JovanG Look at using (assoc), it returns nil if the DXF code is not present. Example: (assoc 3 (entget (car (entsel)))) Paste this at the command line and select a longer mtext and a short mtext If you are iterating through the selection set it would be something like this snippet of code: (defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons x nlist)) ) ) (reverse nlist) ) ;defun (setq cnt -1) (repeat (sslength ss) (setq en (entget (ssname ss (1+ cnt)))) (if (assoc 3 en) (progn (setq str (apply 'strcat (cons (mapcar 'cdr (massoc 3 en)) (cdr (assoc 1 en)) ) ) ) ; .. do something .. ) (progn (setq str (cdr (assoc 1 en))) ; .. do something .. ) ) ) EDIT - corrected! The (apply) statement should've has 'strcat, not 'append Edited January 27, 2021 by pkenewell 1 Quote Link to comment Share on other sites More sharing options...
JovanG Posted January 27, 2021 Author Share Posted January 27, 2021 19 minutes ago, pkenewell said: Look at using (assoc), it returns nil if the DXF code is not present. Excellent! Thank you very much @pkenewell. That was just what I needed 1 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.