Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Need a Lisp

  1. #1
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Need a Lisp

    I'm looking for a lisp that will freeze a set of layers that are in a file that is xrefed into the opened drawing by either selecting that xref file or by looking at all xrefs in the drawing.

    Also, I would like to be able to add layer names to the program and not have it crash if a layer name is listed in the program but not in the xrefed file.

    For the time being, you can use layer1, layer2, etc. as a placeholder and I will add the layers myself.

    Thank you for the help.

    Cadd4la

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Use something like this before freezing a layer

    Code:
    (tblsearch "layer" Layname) ; returns true if it exists

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Need a Lisp

    For more current versions of AutoCAD in the Layer Properties Palette expand the Xref Filter, right-click the Xref with the drawing name you want to freeze the layers of and set Visibility to Frozen. Piece of cake!

  4. #4
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Tom,

    I'm not looking to freeze all the layers in the xref just a select group. So if I can have a lisp that would freeze the layers from a list all at once when I select it or a wildcard because the file name will always be different name because of having the job number at the end and not having to go into the layer menu and do it one by one.

    Thanks,

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Where is this list of layer names going to reside?

    In other words, suppose this lisp file already existed, how would it know what layer names to freeze?
    R.K. McSwain | CAD Panacea |

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Need a Lisp

    You could get the xref drawing name after selecting the xref. Then strcat it with "|" and the name of each layer and each layer from your set of layers to freeze them. Adding layers to the xref file when ones from your set of layers aren't in it is a little trickier. Is that what you're looking for?

  7. #7
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Quote Originally Posted by rkmcswain View Post
    Where is this list of layer names going to reside?

    In other words, suppose this lisp file already existed, how would it know what layer names to freeze?
    I would like it to be in the lisp file.

  8. #8
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Code:
    (defun C:XXX-xI96 (/ CORRECTLAYER TX1 XR1 XR2 XR3 XR4 XR5)
      (defun CORRECTLAYER (LAYERNAME COLOR LTYPE LWEIGHT /)
        (command "-layer" "c" COLOR	LAYERNAME "lt" LTYPE LAYERNAME "lw" LWEIGHT LAYERNAME "")
      )
      (setvar "cmdecho" 0)
      (if (setq XR1	(entsel
    		  "nSelect xref to change to XXX standards for a 1/8'' drawing: "
    		)
          )
        (progn
          (setq XR2 (entget (car XR1)))
          (setq TX1 (cdr (assoc 0 XR2)))
          (if (= TX1 "INSERT")
    	(progn
    	  (setq XR3 (cdr (assoc 2 XR2)))
    	  (setq XR4 (tblsearch "block" XR3))
    	  (if (setq XR5 (cdr (assoc 1 XR4)))
    	    (progn
    	      ;;(setq xr6 (strcat xr3 "|*"))
    	      (CORRECTLAYER
    		(strcat XR3 "|layer1") "9" "Continuous" "Default"
    	      )
    	      (CORRECTLAYER
    		(strcat XR3 "|layer2") "7" "Continuous" "Default"
    	      )
    	      (CORRECTLAYER
    		(strcat XR3 "|layer3") "13" "Continuous" "Default"
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer4") "13" "Divide" "Default"
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer5") "13" "Continuous" "Default"
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer6") "4" "Dashdot" "Default"
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer7") "6" "Continuous" "Default"
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer8") "107" "Dashed" "Default"
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer9") "2" "Continuous" "Default"
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer10") "9" "Continuous" "Default"
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer11") "251" "Continuous" "Default"
    	      )
    	    )
    	    (prompt (strcat "n" "xr3" " is not an X-Ref."))
    	  )
    	)
    	(prompt "nNo External Reference selected")
          )
        )
      )
      (setvar "cmdecho" 1)
      (princ)
    )
    I have this one for example for over 13 years that will change color and line type of a group of layers xrefed in to a file but I don't know how to change the code to freeze layers from a list in the code.

    Thanks,
    Last edited by rkmcswain; 2018-06-27 at 11:46 AM. Reason: Added [CODE] tags

  9. #9
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Need a Lisp

    A few tweaks to that file should be easy.

    Your CORRECTLAYER sub-routine could be updated to request one more argument for the freeze/thaw setting. Something like this:

    Code:
      (defun CORRECTLAYER (LAYERNAME COLOR LTYPE LWEIGHT FREEZE/)
        (command "-layer" "c" COLOR	LAYERNAME "lt" LTYPE LAYERNAME "lw" LWEIGHT LAYERNAME "")
        (if FREEZE
          (command "-layer" "f" LAYERNAME "")
        )
      )
    This change would require tweaks to each of your calls to that sub-routine.

    Something like this for a layer that needs to be frozen:
    Code:
    	      (CORRECTLAYER
    		(strcat XR3 "|layer3") "13" "Continuous" "Default" T
                  )
    And something like this for a layer that needs to be thawed:
    Code:
    	      (CORRECTLAYER
    		(strcat XR3 "|layer4") "13" "Divide" "Default" nil
                  )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  10. #10
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Need a Lisp

    Quote Originally Posted by Opie View Post
    A few tweaks to that file should be easy.

    Your CORRECTLAYER sub-routine could be updated to request one more argument for the freeze/thaw setting. Something like this:

    Code:
      (defun CORRECTLAYER (LAYERNAME COLOR LTYPE LWEIGHT FREEZE/)
        (command "-layer" "c" COLOR	LAYERNAME "lt" LTYPE LAYERNAME "lw" LWEIGHT LAYERNAME "")
        (if FREEZE
          (command "-layer" "f" LAYERNAME "")
        )
      )
    This change would require tweaks to each of your calls to that sub-routine.

    Something like this for a layer that needs to be frozen:
    Code:
    	      (CORRECTLAYER
    		(strcat XR3 "|layer3") "13" "Continuous" "Default" T
                  )
    And something like this for a layer that needs to be thawed:
    Code:
    	      (CORRECTLAYER
    		(strcat XR3 "|layer4") "13" "Divide" "Default" nil
                  )
    Opie, Thanks I think I didn't make myself clear I'm only looking for the code to freeze layers not do anything else. I included the code to show how I want to list the layer names in the code and not an exterior locations

    Code:
    (defun C:XXX-XFR (/ CORRECTLAYER TX1 XR1 XR2 XR3 XR4 XR5)
      (defun CORRECTLAYER (LAYERNAME FREEZE /)
        (command "-layer" "F" LAYERNAME "lt" "")
      )
      (setvar "cmdecho" 0)
      (if (setq XR1	(entsel
    		  "nSelect xref to freeze layers: "
    		)
          )
        (progn
          (setq XR2 (entget (car XR1)))
          (setq TX1 (cdr (assoc 0 XR2)))
          (if (= TX1 "INSERT")
    	(progn
    	  (setq XR3 (cdr (assoc 2 XR2)))
    	  (setq XR4 (tblsearch "block" XR3))
    	  (if (setq XR5 (cdr (assoc 1 XR4)))
    	    (progn
    	      ;;(setq xr6 (strcat xr3 "|*"))
    	      (CORRECTLAYER
    		(strcat XR3 "|layer1") T
    	      )
    	     (CORRECTLAYER
    		(strcat XR3 "|layer2") T
    	      )
    	      (CORRECTLAYER
    		(strcat XR3 "|layer3") T
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer4") T
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer5") T
                  )
                  (CORRECTLAYER
    		(strcat XR3 "|layer6") T
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer7") T
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer8") T
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer9") T
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer10") T
    	      )
                  (CORRECTLAYER
    		(strcat XR3 "|layer11") T
    	      )
    	    )
    	    (prompt (strcat "n" "xr3" " is not an X-Ref."))
    	  )
    	)
    	(prompt "nNo External Reference selected")
          )
        )
      )
      (setvar "cmdecho" 1)
      (princ)
    )
    I tried to add the thinks you posted but it will not work.

    Thanks,
    Last edited by rkmcswain; 2018-06-28 at 11:46 AM. Reason: added [CODE] tags

Page 1 of 2 12 LastLast

Similar Threads

  1. Help with autolisp (2 lisp programs in one lisp execution)
    By javier-perez1956746375 in forum AutoLISP
    Replies: 1
    Last Post: 2017-06-15, 07:40 PM
  2. Replies: 13
    Last Post: 2014-01-20, 06:14 PM
  3. Replies: 3
    Last Post: 2012-05-07, 08:16 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •