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
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Layer command accepts wildcard match for layer name
(command "_layer" "_freeze" "7102-002-950 UC10-03|*" "")
or even
(command "_layer" "_freeze" "*|*" "")
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?
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."
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."