AutoLISP: All Dimensions To A Layer

Here is a simple routine that searches for all dimensions in a drawing and asks the user to enter the name of the layer that you would like the dimensions to be on.

As seen Below:

There are some dimensions on the wrong layers.

  • DIMLAY <enter> to start
  • DIM <enter> this is the name of the dimension layer in my drawing. This will be different per drawing.

 

 

 

 

 

 

 

 

 

; This program selects all dimensions and places them

;	on a user-specified layer.

;

(defun C:DimLay (/ SETD LAY)						; Begin function

(setvar "CMDECHO" 0)						; Turn off command echo

(setq SETD (ssget "X" '((0 . "DIMENSION"))))			; Selection set of dims

(if (null SETD) 						; If there are no dims

(princ "\nThere are no associated dimensions.")			; THEN tell user

(progn								; ELSE begin (progn)

(setq LAY (getstring "\nTransfer to which layer? "))	; Get layer name

(command ".CHPROP" SETD "" "LA" LAY "")			; Change dimensions to layer

)								; End (progn)

)								; End (if)

(setvar "CMDECHO" 1)						; Turn on command echo

(princ)								; Clean exit

)									; End function

; - -( End of Program )- -

 

Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Dimensions, Modifying, TIPS. Bookmark the permalink.

One Response to AutoLISP: All Dimensions To A Layer

  1. thuan says:

    May I add the dimension inside block?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s