Jump to content

Control the xref layers based on selected object


samifox

Recommended Posts

Hi

Using acad 10.

 

when you want to hide a layer in the xref, ull use Freeze and select the object. in the same way i want to changh the color of the layer in the xref.

 

is that built-in acad function?

 

Thanks

S

Link to comment
Share on other sites

(vl-load-com)

(defun c:CLCN () (c:ChangeLayerColorNested))
(defun c:ChangeLayerColorNested (/ *error* entity layer layers color acDoc oLayers)
 (princ "\rCHANGELAYERCOLORNESTED ")

 (defun *error* (msg)
   (if acDoc
     (progn
       (vla-endundomark acDoc)
       (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)
 )

 (while
   (/= nil
       (setq entity
              (nentsel
                "\nSelect nested entity to change layer color: "
              )
       )
   )
    (if
      (not
        (vl-position
          (setq layer
                 (if
                   (= "0" (setq layer (cdr (assoc 8 (entget (car entity))))))
                    (cdr (assoc 8 (entget (car (last entity)))))
                    layer
                 )
          )
          layers
        )
      )
       (print (reverse (setq layers (cons layer layers))))
    )
 )
 (if
   (and
     layers
     (setq color
            (if (= 1 (length layers))
              (cdr (assoc 62 (tblsearch "layer" (car layers))))
              1
            )
     )
     (princ "\nSelect replacement layer color: ")
     (setq color (acad_colordlg color nil))
   )
    (progn
      (vla-startundomark
        (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
      )
      (setq oLayers (vla-get-layers acDoc))
      (foreach layer layers
        (vla-put-color (vla-item oLayers layer) color)
      )
    )
 )
 (*error* nil)
)

Link to comment
Share on other sites

(vl-load-com)

(defun c:CLCN () (c:ChangeLayerColorNested))
(defun c:ChangeLayerColorNested (/ *error* entity layer layers color acDoc oLayers)
 (princ "\rCHANGELAYERCOLORNESTED ")

 (defun *error* (msg)
   (if acDoc
     (progn
       (vla-endundomark acDoc)
       (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)
 )

 (while
   (/= nil
       (setq entity
              (nentsel
                "\nSelect nested entity to change layer color: "
              )
       )
   )
    (if
      (not
        (vl-position
          (setq layer
                 (if
                   (= "0" (setq layer (cdr (assoc 8 (entget (car entity))))))
                    (cdr (assoc 8 (entget (car (last entity)))))
                    layer
                 )
          )
          layers
        )
      )
       (print (reverse (setq layers (cons layer layers))))
    )
 )
 (if
   (and
     layers
     (setq color
            (if (= 1 (length layers))
              (cdr (assoc 62 (tblsearch "layer" (car layers))))
              1
            )
     )
     (princ "\nSelect replacement layer color: ")
     (setq color (acad_colordlg color nil))
   )
    (progn
      (vla-startundomark
        (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
      )
      (setq oLayers (vla-get-layers acDoc))
      (foreach layer layers
        (vla-put-color (vla-item oLayers layer) color)
      )
    )
 )
 (*error* nil)
)

Thanks Blackbox 8)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...