CadTechJGC184 Posted May 4, 2009 Posted May 4, 2009 here is a screen shot of the exref layer I need frozen in my dwg's Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 ahhhhhhhhhhhhhh why can"t I added a print screen.... i give up!! here's the xref name and layer: UTILITY BASE/C-ELEC-LIN Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 Open all the docs you need to freeze the layer in and use this: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 ahhhhhhhhhhhhhh why can"t I added a print screen.... i give up!! here's the xref name and layer: UTILITY BASE/C-ELEC-LIN Just hit the print screen button, paste into MS Paint, and save as JPEG, then attach. Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 hey Lee Mac, How are you doing? thanks for the suggestions. i will give them both a try. Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 Lee Mac, do i open them all at one time or one at a time? Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 Open them all at once. I have just tested it though, and its seems to have a problem if the layer to be frozen is not in the drawing - which is weird because I thought I had accounted for that Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 Are you calling the function correctly? It is a sub-function and should be called as follows: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED]) [/color][/b][color=RED][color=Black](frzlay[/color][/color][b][color=RED][color=Black] "[/color][/color][/b]UTILITY BASE/C-ELEC-LIN") Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 what do i type once I have opened all the drawing that i want the layer frz in? Is it a lisp? Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 You can make your own LISP to call the sub-function and call it what you like: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED]) [/color][/b][color=RED][color=Black](defun c:whatever ()[/color] [/color][color=RED][color=Black] (frzlay[/color][/color][b][color=RED][color=Black] "[/color][/color][/b]UTILITY BASE/C-ELEC-LIN") (princ)) Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 oh and what do I save the "frzlay" as?? Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 (defun c:frzlay (lay / doc lyr) (vlax-for doc (vla-get-Documents (vlax-get-acad-object)) (and (setq lyr (vla-item (vla-get-layers doc) lay)) (vla-put-freeze lyr :vlax-true))) (princ)) (defun c:whatever () (frzlay "UTILITY BASE/C-ELEC-LIN") (princ)) is this correct? I'm a little lost. Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 The frzlay is a sub-function (no "c:"), and needs to be called with one argument (the layer string), from a main-function (which can be named whatever you like - but not the same as the sub-function). When you save LISPs, the filename can be whatever you like - it doesn't have to be the syntax name. I have been in conversation with RonJonp and he has provided a better way to cope with layers that aren't present: (defun frzlay (lay / doc lyr) (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (and (not (vl-catch-all-error-p (setq lyr (vl-catch-all-apply 'vla-item (list (vla-get-layers doc) lay))))) (vla-put-freeze lyr :vlax-true))) (princ)) (defun c:test () (frzlay "UTILITY BASE/C-ELEC-LIN") (princ)) Save as filename.lsp, open all drawings and invoke with "test" Quote
CadTechJGC184 Posted May 4, 2009 Author Posted May 4, 2009 i opened 3 just for a test and I typed frzlay, because that's what I named it c:frzlay not c:test and the layer was still thawed. Quote
ronjonp Posted May 4, 2009 Posted May 4, 2009 The layer name supplied is not valid : UTILITY BASE/C-ELEC-LIN Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 i opened 3 just for a test and I typed frzlay, because that's what I named it c:frzlay not c:test and the layer was still thawed. Also, don't name it the same name as the sub-function Quote
Lee Mac Posted May 4, 2009 Posted May 4, 2009 The layer name supplied is not valid : UTILITY BASE/C-ELEC-LIN Didn't notice that one Ron - nice one Quote
Recommended Posts
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.