Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

freeze all xref layers

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
kpennell
665 Views, 5 Replies

freeze all xref layers

Hello all,

 

I have the following code that works, most of the time.  Actually, it works or completes itself all the time, but there is no "all encompassing" measures incorporated.

 

All of the reference entities, believe it or not, are on layer "0".  There are also some consistent layers, that you can see in the code below.  However, a user may create or even remove any layer in the reference drawing.  Therefore in my current drawing, I may have layers that are not frozen in the xref.

 

Like i said, the following code works, but not all encompassing.

 

(setq filename "7102-002-950 UC10-03")

(setq FreezePRD (strcat filename "|_PRD"))

(setq FreezeSLD (strcat filename "|_SLD"))

(setq FreezeBORDER (strcat filename "|0_BORDER"))

(setq FreezeDIM (strcat filename "|0_DIM"))

(setq FreezeREG (strcat filename "|0_REG"))

(setq FreezeTEXT (strcat filename "|0_TEXT"))

(setq FreezeVPORT (strcat filename "|VPORT"))

(command "ucs" "World")

(command "-xref" "Attach" filename "0,0,0" "1" "1" "0")

(command "-layer" "Freeze" FreezePRD "Freeze" FreezeSLD "Freeze" FreezeBORDER "Freeze" FreezeDIM "Freeze" FreezeREG "Freeze" FreezeTEXT "Freeze" FreezeVPORT "")

(command "ucs" "Previous")

 

I guess what I'm looking for is to freeze all layers that begin with "7102-002-950 UC10-03|".

 

Hope this makes sense.

 

Thanks

KP

 

 

5 REPLIES 5
Message 2 of 6
pbejse
in reply to: kpennell

Layer command accepts wildcard match for layer name

 

(command "_layer" "_freeze" "7102-002-950 UC10-03|*" "")


or even

 

(command "_layer" "_freeze" "*|*" "")

 

 

Message 3 of 6
kpennell
in reply to: pbejse

so this will freeze all layers, or just the first one it finds?

 

I will certainly test very shortly.

 

huge thanks

 

Why so simple I wonder?

Message 4 of 6
kpennell
in reply to: pbejse

It certainly worked.

 

Thanks

Message 5 of 6
BlackBox_
in reply to: kpennell

Building on pbesje's excellent suggestion, here's a quickly written routine:

 

(vl-load-com)

(defun c:FRZX () (c:FreezeXref))
(defun c:FreezeXref (/ ss oBlock blockName)
  (if
    (and
      (setq ss (ssget ":S:E" '((0 . "INSERT"))))
      (setq oBlock (vlax-ename->vla-object (ssname ss 0)))
      (= :vlax-true
         (vla-get-isxref
           (vla-item (vla-get-blocks
                       (vla-get-activedocument (vlax-get-acad-object))
                     )
                     (setq blockName (vla-get-effectivename oBlock))
           )
         )
      )
    )
     (command "._-layer"
              "freeze"
              (strcat (vl-filename-base blockName) "|*")
              ""
     )
     (prompt "\n** Must select an external reference ** ")
  )
  (princ)
)

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 6 of 6
BlackBox_
in reply to: BlackBox_

I should also note that I've intentionally used the -LAYER Command (rather than iterating the Layer Collection) for the benefit of being able to either UNDO (which could also be incoporated into this routine with a bit more code), and more importantly, the LAYERP functionality... Something I personally find invaluable.



"How we think determines what we do, and what we do determines what we get."

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost