Jump to content

Autotext edit for dimension text


Drwhobe

Recommended Posts

Does anyone know of a lisp routine which would allow me select a dimension and ddedit and add a standard note to the dimension selected from a drop down box of standard notes abit like Autotext in MS Word or the ability to cycle through the notes.

 

For example the dimension would then read " O/A Width" etc.

 

The list would need to be customisable maybe held outside Autocad in an excel spreadsheet.

 

Does anyone have any ideas?

Link to comment
Share on other sites

Just thinking this one a bit further maybe it could be done by adding the drop down list to the mtext menu which is launched when you invoke the ddedit command. You can already insert fields and symbols maybe this would be an easier way to do this?

Link to comment
Share on other sites

You could easily construct a DCL menu with pulldown(s) (prefix and/or suffix). From there, you would select your dimensions and append the additional data.

 

Dimension styles have an option for a prefix/suffix, but only one to choose from for each style.

Link to comment
Share on other sites

As a modification of an old code I wrote:

 

(defun c:DimUpdate ( / *error* _read
                      dcfilename strfilename strlst ss dctag ptr dcflag str )
 ;; © Lee Mac 2010
 

 (setq dcfilename  "DimUpdate.dcl"   ;; DCL Filename

       Strfilename "DimUpdate.txt"   ;; Data Filename
  )


 (defun *error* ( msg )
   (and dcTag (unload_dialog dcTag))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))


 (defun _read ( file / ofile lst nl )

   (cond (  (setq ofile (open file "r"))
        
            (while (setq nl (read-line ofile))
              (setq lst (cons nl lst)))

            (close ofile)))
 
   (reverse lst)
 )


 (cond (  (not (setq Strfilename (findfile Strfilename)))

          (princ "\n** Data File not Found **"))

       (  (not (setq StrLst (_read Strfilename)))

          (princ "\n** Data File Empty **"))

       (  (not (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))))

       (  (<= (setq dcTag (load_dialog dcfilename)) 0)

          (princ "\n** Dialog Definition Not Found **"))

       (  (not (new_dialog "dimupdate" dcTag))

          (princ "\n** Dialog Could not be Loaded **"))

       (t
          (start_list "lst")
          (mapcar (function add_list) StrLst)
          (end_list)

          (set_tile "dcltitle" "Dimension Notes")

          (setq ptr (set_tile "lst" "0"))
        
          (action_tile  "lst" "(setq ptr $value)")

          (setq dcFlag (start_dialog) dcTag (unload_dialog dcTag) Str (nth (atoi ptr) StrLst))

          (if (= 1 dcFlag)
            (
              (lambda ( i / ent )
                (while (setq ent (ssname ss (setq i (1+ i))))
                  (entupd                     
                    (cdr
                      (assoc -1
                        (entmod
                          (subst (cons 1 (strcat "<>" str)) (assoc 1 (entget ent)) (entget ent))
                        )
                      )
                    )
                  )
                )
              )
              -1
            )

            (princ "\n*Cancel*")
          )
        )
 )
 
 (princ)
)

DCL File:

 

dimupdate : dialog { key = "dctitle";
 spacer;  
 : list_box { label = "Notes:"; key = "lst";
              alignment = centered; fixed_height = true;
              fixed_width = true; width = 50; height = 20; }
 spacer;
 ok_cancel;
}

Example of Txt Data File:

 

Dimension Note 1
Dimension Note 2
...

Make sure that the Txt and DCL files are saved to the search path under the names shown at the top of the LISP code.

 

Lee

Edited by Lee Mac
Link to comment
Share on other sites

Spot on works perfect,

 

Just what i was looking for, I did find a way of adding text to the symbols list in the mtext editor but requires editing the registry to the add the notes to the drop down menu but your solution is alot easier to add to on a regular basis.

Link to comment
Share on other sites

Lee,

This is a great lisp. Will save alot of time in my office. I think if it would be more efficient to preload the cursor with the text override to that it can be applied to a good few dimensions without having to restart it each time.

Link to comment
Share on other sites

  • 2 weeks later...

Lee, Could this code be modified to work with standard Mtext, for example if i wanted to add text to a note either as a prefix or a suffix. Maybe as a separate lisp and dialogue, and maybe dtext aswell.

Link to comment
Share on other sites

As a VERY quick modification:

 

(defun c:TxtUpdate ( / *error* _read
                      dcfilename strfilename strlst ss dctag ptr dcflag str )
 ;; © Lee Mac 2010
 

 (setq dcfilename  "txtUpdate.dcl"   ;; DCL Filename

       Strfilename "txtUpdate.txt"   ;; Data Filename
  )


 (defun *error* ( msg )
   (and dcTag (unload_dialog dcTag))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))


 (defun _read ( file / ofile lst nl )

   (cond (  (setq ofile (open file "r"))
        
            (while (setq nl (read-line ofile))
              (setq lst (cons nl lst)))

            (close ofile)))
 
   (reverse lst)
 )


 (cond (  (not (setq Strfilename (findfile Strfilename)))

          (princ "\n** Data File not Found **"))

       (  (not (setq StrLst (_read Strfilename)))

          (princ "\n** Data File Empty **"))

       (  (not (setq ss (ssget "_:L" '((0 . "*TEXT"))))))

       (  (<= (setq dcTag (load_dialog dcfilename)) 0)

          (princ "\n** Dialog Definition Not Found **"))

       (  (not (new_dialog "txtupdate" dcTag))

          (princ "\n** Dialog Could not be Loaded **"))

       (t
          (start_list "lst")
          (mapcar (function add_list) StrLst)
          (end_list)

          (set_tile "dcltitle" "Text Notes")

          (setq ptr (set_tile "lst" "0"))
        
          (action_tile  "lst" "(setq ptr $value)")

          (setq dcFlag (start_dialog) dcTag (unload_dialog dcTag) Str (nth (atoi ptr) StrLst))

          (if (= 1 dcFlag)
            (
              (lambda ( i / ent )
                (while (setq ent (ssname ss (setq i (1+ i))))
                  (entupd                     
                    (cdr
                      (assoc -1
                        (entmod
                          (subst (cons 1 (strcat (cdr (assoc 1 (entget ent))) str)) (assoc 1 (entget ent)) (entget ent))
                        )
                      )
                    )
                  )
                )
              )
              -1
            )

            (princ "\n*Cancel*")
          )
        )
 )
 
 (princ)
)

 

txtupdate : dialog { key = "dctitle";
 spacer;  
 : list_box { label = "Notes:"; key = "lst";
              alignment = centered; fixed_height = true;
              fixed_width = true; width = 50; height = 20; }
 spacer;
 ok_cancel;
}

 

Literally really only changed the names and a few other bits - and its completely untested.

 

This may be more suited to you:

 

http://www.theswamp.org/index.php?topic=1392.0

 

You might need to become a member to view it as its in a restricted section - but its one of CAB's and its well worth it :)

Link to comment
Share on other sites

Yep works ok would need to be able to put text as a prefix aswell as a suffix thou. How would the code be altered to do this

Link to comment
Share on other sites

Change:

 

(subst (cons 1 (strcat (cdr (assoc 1 (entget ent))) str)) (assoc 1 (entget ent)) (entget ent))

 

to

 

(subst (cons 1 (strcat str (cdr (assoc 1 (entget ent))))) (assoc 1 (entget ent)) (entget ent))

 

I'll leave the adding of prompts to you if you like - just remember to mark/initial where modifications are made.

Link to comment
Share on other sites

  • 2 months later...

This is a very handy LISP routine! Thanks very much for sharing it. :)

 

I do have a question:

I've added the line " \U+2104" to the associated text file to add the centerline symbol to dimensions. On my computer, using ACAD2011/Win7 64bit, the dialog box shows the centerline symbol in the list. On another machine with ACAD2008/XP Pro 64bit it shows up as a small vertical rectangle in the dialog box list. I checked Options/Display/Fonts and both copies of AutoCAD use the same font settings. Is the problem with displaying the correct symbol an operating system issue? Is there a setting in XP that will let the dialog box show the correct symbol?

 

Thanks-

Mike

Link to comment
Share on other sites

Thanks CADapult, glad you like it :)

 

As for the display, this would be something inherent to how the DCL interacts with XP or different versions of AutoCAD, I'm not sure how one would go about changing that :(

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