I was hoping to use find and replace "#" with broken fields in the drawing. but it will not find the # value that the field creates when it is broken. Is the only way to find a broken field a visual check? or is there another way I am not aware of?
Thanks in advance.
Solved! Go to Solution.
I guess this would select all your fields in your drawing that do not have a logic value .
(defun c:TesT (/ nos ss) (vl-load-com) ;; Tharwat 18. Oct. 2011 ;; (if (setq nos (ssadd) ss (ssget "_x" '((0 . "MTEXT"))) ) (progn ((lambda (n / sset) (while (setq sset (ssname ss (setq n (1+ n)))) (if (and (wcmatch (vla-fieldcode (vlax-ename->vla-object sset)) "%*%" ) (vl-string-search "#" (cdr (assoc 1 (entget sset))) 0) ) (ssadd sset nos) ) ) ) -1 ) (sssetfirst nil nos) ) (princ) ) (princ) )
Thanks that is exactly what I am trying to do. I have fields in attributes instead of mtext, but I can adapt that code. I didn't even know there was a vla-get-fieldcode. That helps out a lot. The new help menu doesn't really show a lot of methods sinces they went to that web format.
I am glad that it worked for you Russ .
and the function is vla-fieldcode not vla-get-fieldcode
Thanks that is exactly what I am trying to do. I have fields in attributes instead of mtext, but I can adapt that code. I didn't even know there was a vla-get-fieldcode.
The FieldCode method only applies to Text or MText objects, to retrieve the Field Expression from Text, MText or Attribute objects, consider this code by Gile.
However, since you are only looking to detect broken fields, I see no reason to retrieve the field string, but only check whether the object does indeed contain a Field Expression.
For this task, I would instead use something like:
(defun c:getfubardfields ( / e f i l s ) (if (setq s (ssget "_X" (list '(-4 . "<OR") '(0 . "TEXT,MTEXT") '(-4 . "<AND") '(0 . "INSERT") '(66 . 1) '(-4 . "AND>") '(-4 . "OR>") (cons 410 (if (= 1 (getvar 'CVPORT)) (getvar 'CTAB) "Model")) ) ) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) ) (cond ( (wcmatch (cdr (assoc 0 l)) "TEXT,MTEXT") (if (not (and (LM:HasField-p e) (wcmatch (cdr (assoc 1 l)) "*`#*") ) ) (ssdel e s) ) ) ( t (while (and (null f) (eq "ATTRIB" (cdr (assoc 0 (entget (setq e (entnext e))))))) (if (and (LM:HasField-p e) (wcmatch (cdr (assoc 1 (entget e))) "*`#*") ) (setq f t) ) ) (if (null f) (ssdel (cdr (assoc 330 (entget e))) s)) (setq f nil) ) ) ) ) (sssetfirst nil s) (princ) ) ;; HasField-p - Lee Mac ;; Returns T if the supplied entity contains a Field Expression (defun LM:HasField-p ( en ) (and (wcmatch (cdr (assoc 0 (setq en (entget en)))) "TEXT,MTEXT,ATTRIB") (setq en (cdr (assoc 360 en))) (setq en (dictsearch en "ACAD_FIELD")) (setq en (dictsearch (cdr (assoc -1 en)) "TEXT")) ) )
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.