Results 1 to 9 of 9

Thread: Edit Layer Properties by Selection?

  1. #1
    Member
    Join Date
    2014-06
    Posts
    36
    Login to Give a bone
    0

    Default 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?

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default 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))
      )
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default 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.

  4. #4
    Certified AUGI Addict jaberwok's Avatar
    Join Date
    2000-12
    Location
    0,0,0 The Origin
    Posts
    8,570
    Login to Give a bone
    0

    Default Re: Edit Layer Properties by Selection?

    Quote Originally Posted by Tom Beauford View Post
    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).

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Edit Layer Properties by Selection?

    Quote Originally Posted by jaberwok View Post
    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.

  6. #6
    Certified AUGI Addict cadtag's Avatar
    Join Date
    2000-12
    Location
    Cairo - no, not Illinois
    Posts
    5,069
    Login to Give a bone
    0

    Default 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.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Edit Layer Properties by Selection?

    Quote Originally Posted by cadtag View Post
    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.

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Edit Layer Properties by Selection?

    Quote Originally Posted by cadtag View Post
    ... 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
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    Certified AUGI Addict cadtag's Avatar
    Join Date
    2000-12
    Location
    Cairo - no, not Illinois
    Posts
    5,069
    Login to Give a bone
    0

    Default Re: Edit Layer Properties by Selection?

    picky picky.... but not clicky

Similar Threads

  1. Replies: 1
    Last Post: 2013-12-04, 06:14 PM
  2. New object properties not matching layer properties
    By domniki in forum AutoCAD General
    Replies: 5
    Last Post: 2010-03-23, 09:48 AM
  3. View/Change Properties in Layer Properties Window
    By mlongfellow in forum AutoCAD General
    Replies: 2
    Last Post: 2007-12-28, 03:37 PM
  4. Copy Layer Properties - Alter Properties
    By trconnet in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2007-08-13, 04:03 PM
  5. Ability to Update an XREF Layer from the Layer Properties Manager
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-05-08, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •