Looking for a LISP routine that selects all dimensions, puts them on a particular layer, applies drawing background mask, and brings them to draw order - front.

Looking for a LISP routine that selects all dimensions, puts them on a particular layer, applies drawing background mask, and brings them to draw order - front.

winstonfoxnelson
Enthusiast Enthusiast
754 Views
5 Replies
Message 1 of 6

Looking for a LISP routine that selects all dimensions, puts them on a particular layer, applies drawing background mask, and brings them to draw order - front.

winstonfoxnelson
Enthusiast
Enthusiast

Hello, I'm looking for a LISP routine that:

Selects all dimensions

Puts them on a particular layer

Applies a background mask  - drawing to them

Brings them to draw order - front

 

Thank you!

0 Likes
Accepted solutions (2)
755 Views
5 Replies
Replies (5)
Message 2 of 6

3wood
Advisor
Advisor
Accepted solution

You can try the codes below.

It unlocks all layers before changing the dimension layer.

It only works on the current layout. You can modify it to make it go through all layouts.

 

(defun C:ADB (/ t1 s1 n1 g1 g1)
  (setq t1 (getstring T "Dimension layer name: "))
  (command "._-layer" "m" t1 "")
  (command "._-layer" "U" "*" "")
 (setq s1 (ssget "x" '((0 . "*dim*")))
       n1 0)
  (command "._draworder" "p" "" "f" )
  (repeat (sslength s1)
    (setq e1 (ssname s1 n1))
    (setq g1 (entget e1))
    (entmod (subst (cons 8 t1) (assoc 8 g1) g1))
    (setpropertyvalue e1 "Dimtfill" 1)
    (setq n1 (1+ n1))
    )
  (command "._layerp")
  (command "._layerp")
  (princ)
)

 

 

 

Message 3 of 6

winstonfoxnelson
Enthusiast
Enthusiast

Wow thanks a lot, question - I should have specified that I'd like the routine to put the dimensions on a particular layer, not prompt the user to choose the layer every time. In my case I'd like that layer to be "F-DIM-F". Could this be tweaked to do that?

0 Likes
Message 4 of 6

3wood
Advisor
Advisor

Sure. Please try updated codes below:

(defun C:ADB (/ t1 s1 n1 g1 g1)
  ;(setq t1 (getstring T "Dimension layer name: "))
  (if (setq n1 0
	    s1 (ssget "x" '((0 . "*dim*")))
	    )
    (progn
      (setq t1 "F-DIM-F")
      (command "._-layer" "m" t1 "")
      (command "._-layer" "U" "*" "")
      
      (command "._draworder" "p" "" "f" )
      (repeat (sslength s1)
	(setq e1 (ssname s1 n1))
	(setq g1 (entget e1))
	(entmod (subst (cons 8 t1) (assoc 8 g1) g1))
	(setpropertyvalue e1 "Dimtfill" 1)
	(setq n1 (1+ n1))
	)
      (command "._layerp")
      (command "._layerp")
      )
    )
  (princ)
  )
Message 5 of 6

winstonfoxnelson
Enthusiast
Enthusiast

Beautiful, but I have one last request...

 

Can you tweak it to select only those dimensions which are currently visible?

 

I don't know who you are or why you're helping me, but please DM me with your Paypal or Venmo and I'll show my appreciation, whether or not you can fulfill this last bit.

 

Thank you ever so much!

 

 

0 Likes
Message 6 of 6

3wood
Advisor
Advisor
Accepted solution

If you want to apply changes to selected dimensions only, please try the codes below.

(defun C:ADB (/ t1 s1 n1 g1 g1)
  (if (setq n1 0
	    s1 (ssget '((0 . "*dim*")))
	    )
    (progn
      (setq t1 "F-DIM-F")
      (command "._-layer" "m" t1 "")
      (command "._-layer" "U" "*" "")
      
      (command "._draworder" "p" "" "f" )
      (repeat (sslength s1)
	(setq e1 (ssname s1 n1))
	(setq g1 (entget e1))
	(entmod (subst (cons 8 t1) (assoc 8 g1) g1))
	(setpropertyvalue e1 "Dimtfill" 1)
	(setq n1 (1+ n1))
	)
      (command "._layerp")
      (command "._layerp")
      )
    )
  (princ)
  )