Store freezed layer in .lsp file

Store freezed layer in .lsp file

andreas7ZYXQ
Advocate Advocate
786 Views
5 Replies
Message 1 of 6

Store freezed layer in .lsp file

andreas7ZYXQ
Advocate
Advocate

Im looking for a routine that stores the layer i freeze in a .lsp file. 

 

It would work as follows:

User "layfrz" one or multiple layers. The routine then stores the layer name in a .lsp file in the same folder att the current dwg. formatted at a command.

(command "-layer" "f" "LAYER1" "")

(command "-layer" "f" "LAYER2" "")

etc...


If the file already exists then add the rows to the end.

 

Does anyone have something like this out there or could help me? It would be much appreciated.

0 Likes
Accepted solutions (2)
787 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Why to a *.lsp file? Can't think of a reason why that is a good idea.

0 Likes
Message 3 of 6

Jonathan3891
Advisor
Advisor

It might help if you could explain what exactly you are trying to accomplish.


Jonathan Norton
Blog | Linkedin
0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

The idea seems to be to make a file you can run again later, or in another drawing, to freeze the same Layers.  I don't think it can be done in connection with the LAYFRZ command itself, because I don't know of a way to extract the Layer name(s) frozen with it, afterwards.  But I think this does it [very lightly tested]:

(defun C:LFAAF ; = Layer Freeze and Add to AutoLisp File
  (/ frzfile esel lname)
  (setq frzfile (open (strcat (getvar 'dwgprefix) "layfrzfile.lsp") "a"))
  (while
    (setq esel (entsel "\nSelect object to Freeze its Layer and Add a line to the Layer-Freeze AutoLisp file: "))
    (setq lname (cdr (assoc 8 (entget (car esel)))))
    (command "_.layer" "_freeze" lname "")
    (write-line
      (strcat "(command \"_.layer\" \"_freeze\" \"" lname "\" \"\")")
      frzfile
    ); write-line
  ); while
  (close frzfile)
)

It does not yet account for the possibility of picking something on the current Layer [which will cause an error], but could be made to.

Kent Cooper, AIA
0 Likes
Message 5 of 6

andreas7ZYXQ
Advocate
Advocate

Thats what im looking for. 

 

But if i try to freeze layers inside a xref it will freeze the xref layer.

 

Would it be possible to freeze layers inside xrefs? 

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@andreas7ZYXQ wrote:

....

Would it be possible to freeze layers inside xrefs? 


Well, you could add a letter:

....

  (setq esel (nentsel "\nSelect object to ...

....

 

But that goes to the deepest-nested level of whatever you pick on.  So if you pick on a Block in the Xref, and the part of the Block you pick on was drawn on Layer 0, it will Freeze Layer 0.  I have a way around that, but I can't take time to dig it out right now -- you can Search for a routine called LayerQuellPick.lsp, and look in its LFPN command.

Kent Cooper, AIA
0 Likes