Edit Layer Properties by Selection?
Hi,
Is there a way to graphically select an object and then edit the properties of the lay to which it belongs?
For example, I'd like to be able to start a command, have it prompt me to select a line, for example, and then allow me to change the corresponding layer color from red to blue.
Thoughts?
Re: Edit Layer Properties by Selection?
I wrote this a few years back when I was first learning VL (could use some work to simplify); please take from it what you like (modify to support True Color):
Code:
(vl-load-com)
(defun c:CLC () (c:ChangeLayerColor))
(defun c:ChangeLayerColor (/ *error*)
(princ "\rCHANGELAYERCOLOR ")
(defun *error* (msg)
(if acDoc
(progn
(vla-endundomark acDoc)
(if regen
(vla-regen acDoc acAllViewports)
)
)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat " ** Error: " msg " ** ")))
) ; Fatal error, display it
(princ)
)
((lambda (acDoc / ss color oLayers oLayer layers regen)
(vla-startundomark acDoc)
(if (not (setq ss (ssget "_i")))
(progn
(prompt "\nSelect entity on layer to change color: ")
(setq ss (ssget))
)
)
(if (= 1 (sslength ss))
(setq color
(cdr
(assoc 62
(tblsearch "layer"
(cdr (assoc 8 (entget (ssname ss 0))))
)
)
)
)
)
(if (and ss
(princ "\nSelect replacement layer color: ")
(setq color (acad_colordlg (if color color 1) nil))
)
(progn
(setq oLayers (vla-get-layers acDoc))
(vlax-for x (setq ss (vla-get-activeselectionset acDoc))
(if
(not
(vl-position (setq oLayer (vla-item oLayers (vla-get-layer x))) layers)
)
(setq layers (cons oLayer layers))
)
)
(vla-delete ss)
(foreach oLayer layers
(if (or regen
(= :vlax-true (vla-get-lock oLayer))
)
(setq regen T)
)
(vla-put-color oLayer color)
)
(*error* nil)
)
)
)
(vla-get-activedocument (vlax-get-acad-object))
)
)
Re: Edit Layer Properties by Selection?
To change the corresponding layer color from red to blue of a selected object you can also use the Ribbon Layer List Combo Box. Pick the color box and select the color you want.
Re: Edit Layer Properties by Selection?
Quote:
Originally Posted by
Tom Beauford
To change the corresponding layer color from red to blue of a selected object you can also use the Ribbon Layer List Combo Box. Pick the color box and select the color you want.
Unless the ribbon uses some new magic, that will change the properties of the object, not of its layer (which seems a very odd requirement anyway).
Re: Edit Layer Properties by Selection?
Quote:
Originally Posted by
jaberwok
Unless the ribbon uses some new magic, that will change the properties of the object, not of its layer (which seems a very odd requirement anyway).
It's worked that way since at least 2012 I believe, make sure you're using the Ribbon Layer List Combo Box not the Ribbon Combo Box - Object Color.
Re: Edit Layer Properties by Selection?
Lock/unlock, on/off, freeze/thaw, & color all work. Transparency by layer, lineweight, plotstyle, and plot/noplot are only available from the layer manager.
but really, what's there now is 90% of the layer manipulation I need in a typical session.
Re: Edit Layer Properties by Selection?
Quote:
Originally Posted by
cadtag
Lock/unlock, on/off, freeze/thaw, & color all work. Transparency by layer, lineweight, plotstyle, and plot/noplot are only available from the layer manager.
but really, what's there now is 90% of the layer manipulation I need in a typical session.
Possible Wish list item: System variable to modify the Ribbon Layer List Combo Box to include options for Transparency by layer, Lineweight, Plotstyle, and Plot/noPlot items. They would need to be modifiable like the existing items. The box size doesn't need to change it already expands as needed on drop-down. Or maybe an option to select a layer to modify in Properties Palette?
Our base template has so many layers selecting the one you want to modify takes time. I'd like to see an option to have a selected objects layer selected in the layer dialog instead of the current layer.
Re: Edit Layer Properties by Selection?
Quote:
Originally Posted by
cadtag
... Transparency by layer, lineweight, plotstyle, and plot/noplot are only available from the layer manager.
FWIW -
These properties are accessible through the -LAYER Command, in addition to being exposed to API (as discussed here).
Cheers
Re: Edit Layer Properties by Selection?
picky picky.... :) but not clicky :) :)