Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

ВeekeeCZ
en respuesta a: Anonymous

wow, I'm using this routine once in awhile, but never noticed... thx.

 

;; If the object's properties color, linetype and lineweight are ByLayer, then these are changed according the layer.

(vl-load-com)

(defun c:SetByLayerReverse (/ *error* adoc layer obj en ss i tcol)
  
  (defun *error* (msg)
    (vla-endundomark adoc)
    (princ msg)
    (princ))
  
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (if (setq ss (ssget))
    (repeat (setq i (sslength ss))
      (setq en (ssname ss (setq i (1- i)))
	    obj (vlax-ename->vla-object en)
	    layer (vla-get-layer obj))
      
      (if (not (assoc 62 (entget en)))
	(progn
	  (vla-put-color obj (cdr (assoc 62 (tblsearch "layer" layer))))
	  (if (setq tcol (assoc 420 (entget (tblobjname "layer" layer))))
	    (entmod (append (entget en) (list tcol))))))
      
      (if (not (assoc 6 (entget en)))
	(vla-put-linetype obj (cdr (assoc 6 (tblsearch "layer" layer)))))
      
      (if (not (assoc 370 (entget en)))
	(vla-put-lineweight obj (cond ((cdr (assoc 370 (entget (tblobjname "layer" layer)))))
				      (-3))))))
  (vla-endundomark adoc)
  (princ)
)