Centerline Dimension Extension Lines in AutoCAD®


Contents:
Overview ---- Body ---- Conclusion

1Overview
The Problem

In architectural documentation linear dimensions often vary between distances from edges to distances from centers.  This means that sometimes you want one to two extension lines to show as centerlines instead of solid lines.  Alternating between two different extension lines is fairly simple in AutoCAD (since 2006, I believe) but can be time consuming if you have a lot of dimensions that alternate.  The ideal would be a Dimension Object smart enough to recognize when you are Snapping to the Middle or Center of something and provide the appropriate linetype but the next best thing would be to simply pick on an extension line and change it to a centerline.  In the discussion below, I outline how to do just that.

2Body
The Standard Solution

Your standard Dimension Style is most likely set to use "ByLayer" for the two extension lines on Linear Dimensions.  If you wish to change one or both extension linetypes, you can use the Properties Palette, as illustrated to the right, to make that change.

If you want to make a quick Dimension Style override to create a series of dimensions with the "Center2" Linetype, for example, you can type "DimLtex1" and/or "DimLtex2" and set these dimension variables to "Center2".  This is not the greatest solution.  You can, of course, also have a separate Dimension Style just for this type of dimensioning.

 

The Custom Solution

A while back I came across a nifty bit of Lisp code that answers a need I have had for many many years.  The code was posted to a board by Lee Mac of Lee Mac Programs - Custom Programming for AutoCAD.

The Lisp code defines a new command, "extlt", that allows you to select one of the two linear dimension extension lines and change it to whatever linetype is specified by the quotient (or variable) "ltp".  In the code below "ltp" is set to "CENTER" but I prefer to use "CENTER2" so that's all I have to change in this code.  There are several ways you can use the code.  In the illustration to the right I show how you can configure a Tool Palette Button to load the code and then execute the "extlt" command.  This is not the cleanest solution because the code is reloaded every time you pick the button but it is an effective approach for beginners.

Highlight the code written below, copy it and paste it into a Notepad file.  Then, save the file with a name like "dim_centerline.lsp" and be sure to use the extension ".lsp".  When you have saved this file to a location on your machine, create an AutoCAD tool as illustrated to the right and use the Command String field to load this file and execute the command.  The expression you need to write for the Command string should look something like this: ^C^C(load "C:/ACAD Standards/Lisp/dim_centerline.lsp");extlt  For the path after C:/, put in your own path information.

(defun c:extlt ( / ent enx ltp obj pnt )
    (setq ltp "CENTER")
    (if (tblsearch "LTYPE" ltp)
        (progn
            (while
                (progn (setvar 'errno 0) (setq ent (entsel "\nSelect Extension Line: "))
                    (cond
                        (   (= 7 (getvar 'errno))
                            (princ "\nMissed, try again.")
                        )
                        (   (null ent) nil)
                        (   (not (wcmatch (cdr (assoc 0 (entget (car ent)))) "*DIMENSION"))
                            (princ "\nSelected object is not a Dimension: ")
                        )
                    )
                )
            )
            (if ent
                (progn
                    (setq pnt (trans (cadr ent) 1 0)
                          enx (entget (car ent))
                          obj (vlax-ename->vla-object (car ent))
                    )
                    (vlax-put-property obj
                        (if (< (distance pnt (cdr (assoc 13 enx))) (distance pnt (cdr (assoc 14 enx))))
                            'extline1linetype
                            'extline2linetype
                        )
                        ltp
                    )
                )
            )                           
        )
        (princ (strcat "\nLinetype " ltp " not loaded."))
    )
    (princ)
)
(vl-load-com) (princ)

 

For the Command string, set the path to your lisp code using forward slashes "/" as shown and use a path to your own code location.

3Conclusion
The End

Hopefully this little nugget of information will prove to be as useful to you as it has been to me.  If you are looking for other interesting bits of code check out Lee Mac's website.

 

 

 

© Copyright 2013 ARCHIdigm. All rights reserved.
Disclaimer and Copyright Information

See this Page as Originally Intended