Command to change dimension layer and style

Command to change dimension layer and style

Anonymous
Not applicable
1,791 Views
5 Replies
Message 1 of 6

Command to change dimension layer and style

Anonymous
Not applicable

I've got some simple shortcut commands for changing layers for my dimensions ("1" sets current layer to 2D_DIM, "11" changes object layer to 2D_DIM, "2" sets current layer to 2D_DIM_VERIFY, "22" changes object layer to 2D_DIM_VERIFY). These work great for initial dimensioning, but when we get updated dimensions its a two step procedure the change the dimstyle to/from Annotative to AnnotativeVERIFY and then change the layer.

 

I would like to create command "111" to change the selected dimension to my Annotative dimstyle and change the layer to 2D_DIM. And then another command "222" to change the selected dimension to my AnnotativeVERIFY dimstyle and change the layer to 2D_DIM_VERIFY.

 

Everything I've tried does one or the other. Any help would be great.

0 Likes
Accepted solutions (1)
1,792 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Post the shortcuts you have already, and it should be a simple thing to edit them for the additional versions.

Kent Cooper, AIA
0 Likes
Message 3 of 6

Anonymous
Not applicable

(defun c:1()    (command "-layer" "s" "2D_DIM" ""))
(defun c:11()    (command "_.chprop" (ssget) "" "_layer" "2D_DIM" ""))

 

(defun c:2()    (command "-layer" "s" "2D_DIM_VERIFY" ""))
(defun c:22()    (command "_.chprop" (ssget) "" "_layer" "2D_DIM_VERIFY" ""))

 

 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

Oddly, the DIMSTYLE System Variable is not accepted in a DIMOVERRIDE command, which would make it simpler.  But these should do it, if by "the selected dimension" you mean one Dimension [minimally tested]:

 

defun c:1()    (command "-layer" "s" "2D_DIM" ""))
(defun c:11()    (command "_.chprop" (ssget) "" "_layer" "2D_DIM" ""))

(defun C:111 ()

  (command "_.chprop" (ssget) "" "_layer" "2D_DIM" "")

  (setq edata (entget (ssname (ssget "_P") 0)))

  (entmod (subst '(3 . "Annotative") (assoc 3 edata) edata))

)

 

(defun c:2()    (command "-layer" "s" "2D_DIM_VERIFY" ""))
(defun c:22()    (command "_.chprop" (ssget) "" "_layer" "2D_DIM_VERIFY" ""))

(defun C:222 ()

  (command "_.chprop" (ssget) "" "_layer" "2D_DIM_VERIFY" "")

  (setq edata (entget (ssname (ssget "_P") 0)))

  (entmod (subst '(3 . "AnnotativeVERIFY") (assoc 3 edata) edata))

)

 

Do you want the two- and three-digit command names to also set the current Layer to the appropriate one [as the one-digit command names do], and not just change the Layer of the selected Dimension?  That can easily be added.

 

If you want to be able to select multiple Dimensions, that can be accommodated with some additional code to step through the selection.  [If DIMOVERRIDE would take DIMSTYLE as a variable to override, it would work for single or multiple Dimensions more simply, which is why I wanted to use that, but....]

Kent Cooper, AIA
0 Likes
Message 5 of 6

Anonymous
Not applicable

It works great for one dimension, as you stated. It would be great if I could select multiple dimensions. I tried using aidimstyle but it was bringing up a window for me to select which dimstyle I wanted to use. I don't know if there is a way to get aidimstyle to have a set selection based off 111 and 222.

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... It would be great if I could select multiple dimensions. ....


Give these a try [untested]:

(defun C:111 (/ ss n ddata)
  (if (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
    (progn ; then
      (command "_.chprop" ss "" "_layer" "2D_DIM" "")
      (repeat (setq n (sslength ss))
        (setq ddata (entget (ssname ss (setq n (1- n)))))
        (entmod (subst '(3 . "Annotative") (assoc 3 ddata) ddata))
      ); repeat
    ); progn
  ); if
); defun
 
(defun C:222 (/ ss n ddata)
  (if (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
    (progn ; then
      (command "_.chprop" ss "" "_layer" "2D_DIM_VERIFY" "")
      (repeat (setq n (sslength ss))
        (setq ddata (entget (ssname ss (setq n (1- n)))))
        (entmod (subst '(3 . "AnnotativeVERIFY") (assoc 3 ddata) ddata))
      ); repeat
    ); progn
  ); if
); defun

They have the added bonus over earlier commands that they filter for Dimensions only, so you can window a whole area, and it will "see" only the Dimensions, and ignore the Lines and Text and so on.

Kent Cooper, AIA