Jump to content

Lisp to select a field and highlight associated object


Recommended Posts

Posted

I am not sure if this is built into CAD or if I need a lisp. I would like to select a field that contains area information and have the object that is associated with that field highlight. The field is an attribute in a block. any suggestions?

Posted

Here is a basic form of the program:

 

(defun c:fieldobject ( / en )
   (while
       (progn (setvar 'ERRNO 0) (setq en (car (nentsel "\nSelect Field: ")))
           (cond
               (   (= 7 (getvar 'ERRNO))
                   (princ "\nMissed, try again.")
               )
               (   (eq 'ENAME (type en))
                   (if
                       (and
                           (wcmatch (cdr (assoc 0 (setq en (entget en)))) "*TEXT,ATTRIB")
                           (setq en (cdr (assoc 360 en)))
                           (setq en (dictsearch en "ACAD_FIELD"))
                           (setq en (dictsearch (cdr (assoc -1 en)) "TEXT"))
                           (setq en (cdr (assoc 360 en)))
                           (setq en (cdr (assoc 331 (entget en))))
                       )
                       (redraw en 3)
                       (princ "\nObject does not contain a Field.")
                   )
               )
           )
       )
   )
   (princ)
)

Posted

This ... ?

 

(defun c:TesT (/ selectionlist ss i ssNme lst)
;;; Tharwat 17. Oct. 2011 ;;;
 (if (setq selectionlist (ssadd)
           ss            (ssget "_x" '((0 . "INSERT") (66 . 1)))
     )
(progn
   (repeat (setq i (sslength ss))
     (setq ssNme (ssname ss (setq i (1- i))))
     (vlax-for x
                 (vla-item
                   (vla-get-blocks
                     (vla-get-activedocument (vlax-get-acad-object))
                   )
                   (cdr (assoc 2 (entget ssNme)))
                 )
       (if
         (and
           (eq (vla-get-objectname x) "AcDbMText")
           (not
             (eq (vl-string-search "Area" (vla-fieldcode x) 0) "")
           )
         )
          (ssadd ssNme selectionlist)
       )
     )
   )
(sssetfirst nil Selectionlist)
)
   (princ)
 ) 
 (princ)
)
(vl-load-com)

Tharwat

  • 2 weeks later...
Posted

Were either of these solutions suitable markv, or were we wasting our time?

Posted

Sorry i have been using the first soulution. Thansk for all the help. I thoguht I posted back already. again I apologize

Posted
Sorry i have been using the first soulution. Thansk for all the help. I thoguht I posted back already. again I apologize

 

No problem , and it is good to hear from you at last . :)

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