Jump to content

Locating MTEXT objects that contain fields


HFB

Recommended Posts

Hi. I am getting my head around the sheet set manager, and have been using fields to reference different sheets numbers. I've broken some links at some point and have no problem fixing them, I just would like to know if there is a quick way to select all the MTEXT objects that contain fields. If I could narrow it down to ones that are broken (displaying ##), that would be even better. Prefer something simple, but am starting to use Lisps now that there are starting to be some LT useable ones.

Link to comment
Share on other sites

Doing a google found an answer by the great Lee-mac.

 

;; Field Code  -  Lee Mac
;; Returns the field expression associated with an object.

(defun LM:FieldCode ( en / fd id )
   (cond
       (   (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"))
               (setq fd (entget (cdr (assoc 360 en))))
           )
           (if (vl-string-search "\\_FldIdx " (cdr (assoc 2 en)))
               (vl-string-subst
                   (if (setq id (cdr (assoc 331 fd)))
                       (vl-string-subst
                           (strcat "ObjId " (itoa (vla-get-objectid (vlax-ename->vla-object id))))
                           "ObjIdx 0"
                           (cdr (assoc 2 fd))
                       )
                       (cdr (assoc 2 fd))
                   )
                   "\\_FldIdx 0"
                   (cdr (assoc 2 en))
               )
               (cdr (assoc 2 en))
           )
       )
   )
)
(vl-load-com)

 

 

Link to comment
Share on other sites

On 7/27/2024 at 12:48 PM, BIGAL said:

Doing a google found an answer by the great Lee-mac...

 

Thanks for that, but when I run it (after editing to change LM: to c:), I just get "too few arguments". I even went straight to LM's site and copied straight from there (slightly different to the version you've pasted) and get the same result. I've tried selecting everything before running, just in case that made a difference. I am running AutoCAD LT 2024.
Bearing in mind that lisps have only been useable in LT in the last year, I have very little knowledge of what sort of outcome I should expect from the code, so I can't even stare at it until I get an epiphany of where the problem might be...

Link to comment
Share on other sites

You load the defun then need to call the defun.

 

(defun LM:FieldCode ( en / fd id )
.........
.........
)

(LM:FieldCode (car (entsel "\nPick an entity for field check ")))

 

Link to comment
Share on other sites

AutoCAD 2024 LT will not run VLISP. (just a tip, if you see (vl-load-com), VL, among other things, it's VLISP)

 

Lee Mac's Code is VLISP.

 

 

Link to comment
Share on other sites

Posted (edited)
15 hours ago, SLW210 said:

AutoCAD 2024 LT will not run VLISP. (just a tip, if you see (vl-load-com), VL, among other things, it's VLISP)

 

Lee Mac's Code is VLISP.

 

 

Thanks for the heads up on that one. I did think it odd that it had LM: instead of c :

Edited by HFB
c: autocorrected to smiley face
Link to comment
Share on other sites

LM: just stands for LeeMac,

 

Possibly look at AutoLISP sites for learning, you might be able to come up with a non=VLISP solution. IIRC there are DXF codes for fields, but I am not sure how much an AutoLISP code can manipulate fields.

 

AfraLISP  would be a good place to start.

 

I am not at work today, but if no one jumps in, I'll try to find time tomorrow.

Link to comment
Share on other sites

There was a frequent member on here that used pre-LISP AutoCAD LT and did a lot of customization, mostly using Excel and maybe Diesel.

 

Browse through the AutoCAD LT section.

Link to comment
Share on other sites

Posted (edited)
On 7/30/2024 at 11:16 PM, SLW210 said:

There was a frequent member on here that used pre-LISP AutoCAD LT and did a lot of customization, mostly using Excel and maybe Diesel.

 

Browse through the AutoCAD LT section.

I will do that when I get a chance. I don't have a lot of spare time for creating/searching stuff at work, unfortunately.

Edited by HFB
minor amend
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...