See the top rated post in this thread. Click here

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

Thread: Lisp to change xref layers by a set of given layer name

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

    Lightbulb Lisp to change xref layers by a set of given layer name

    Hi everyone,

    I am looking to have a lisp program that will change the Color, linetype,and the lineweight in the layer properties manager of a xref drawing from a give list.

    Background.
    We use a irrigation consultant that draws their irrigation plan in it own file then xref that plan into our file that has our titleblock, and the base files that make up the site plan. The problem is that we use .ctb for our pens and they use .stb file, so they have to go into the layer properties manager and change the layer setting manual to what we use if we had done the irrigation plan.

    Therefore, I would like to have the lisp change the irrigation consultant layer Color, linetype,and the lineweight to a set of layer Color, linetype,and the lineweight that we use automatically, so they can use our .ctb file

    an example of these set layers to be used in the lisp to change the layer properties in the final output file not the original file:

    L-PIPES_LATS color 13 Linetype Continuous Lineweight Default
    L-PIPES_MAINLINE color 2 Linetype DASHDOT Lineweight Default
    L-PIPES_SLEEVING color 2 Linetype DASHED Lineweight Default

    Thanks for your,

    Kyle C.

  2. #2
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Lisp to change xref layers by a set of given layer name

    Hi

    Look into the _.LayTrans command.

    Have a good one, Mike

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

    Default Re: Lisp to change xref layers by a set of given layer name

    Mike,

    I was looking for a lisp that could do it by reading the settings in a empty .dwg file, your way would take to long to input the data.

    The layer names would be the same.

    Quote Originally Posted by Mike.Perry
    Hi

    Look into the _.LayTrans command.

    Have a good one, Mike

  4. #4
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Lisp to change xref layers by a set of given layer name

    Quote Originally Posted by kylec_edg
    I was looking for a lisp that could do it by reading the settings in a empty .dwg file, your way would take to long to input the data.

    The layer names would be the same.
    Hi

    Using your original example, you would only need to set it up once, then save it as a .DWS file for later use when using the Irrigation Consultant's drawings.

    Either way LISP routine OR _.LayTrans route requires "you" to initially set-up the required Layer / Color / Linetype / etc mapping required for your needs.

    Have a good one, Mike

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

    Default Re: Lisp to change xref layers by a set of given layer name

    Mike,

    I tried _.LayTrans I don't see any of the layers that are xrefed into the drawing under the translate from box all I see is the layers that are in the drawing.

    Quote Originally Posted by kylec_edg
    I am looking to have a lisp program that will change the Color, linetype,and the lineweight in the layer properties manager of a xref drawing from a give list.

    Background.
    We use a irrigation consultant that draws their irrigation plan in it own file then xref that plan into our file that has our titleblock, and the base files that make up the site plan. The problem is that we use .ctb for our pens and they use .stb file, so they have to go into the layer properties manager and change the layer setting manual to what we use if we had done the irrigation plan.

    Therefore, I would like to have the lisp change the irrigation consultant layer Color, linetype,and the lineweight to a set of layer Color, linetype,and the lineweight that we use automatically, so they can use our .ctb file

    an example of these set layers to be used in the lisp to change the layer properties in the final output file not the original file:

    L-PIPES_LATS color 13 Linetype Continuous Lineweight Default
    L-PIPES_MAINLINE color 2 Linetype DASHDOT Lineweight Default
    L-PIPES_SLEEVING color 2 Linetype DASHED Lineweight Default

    Thanks for your,

    Kyle C.

    Quote Originally Posted by Mike.Perry
    Hi

    Using your original example, you would only need to set it up once, then save it as a .DWS file for later use when using the Irrigation Consultant's drawings.

    Either way LISP routine OR _.LayTrans route requires "you" to initially set-up the required Layer / Color / Linetype / etc mapping required for your needs.

    Have a good one, Mike
    Kyle C.[/
    AutoCAD 2010 Windows7 Ultimate
    _________________________________________________________
    My spelling is wobbly. It's good spelling but it wobbles and the letters get in the wrong places.
    ... Winnie the Pooh

  6. #6
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Lisp to change xref layers by a set of given layer name

    Quote Originally Posted by kylec_edg
    I tried _.LayTrans I don't see any of the layers that are xrefed into the drawing under the translate from box all I see is the layers that are in the drawing.
    Hi

    that will teach me for not carrying out proper testing... I assumed (and we all know, one should never assume) Xref Layers would be listed in "Layer Translator" dialog box.

    Ok! you could still use _.LayTrans just need to set it up within the actual Irrigation Consultant's (Xref) drawing file.

    OR

    Utilizing Layer States would work very well in this situation.

    Have a good one, Mike

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

    Lightbulb Re: Lisp to change xref layers by a set of given layer name

    OK, so nobody was able to write a code for what I needed, so now after days of looking through different codes that did something that I need (the base code I used changed all xref to a given color) and a few hours of trying to change the code to do what I needed this is what I got.

    Now, I would like the experts to take a look at the code and see if you can improve on it to run smoother, I still need to add about twenty more layers.

    Thank you for the help

    Kyle C.

    Code:
    (defun c:x-I96(/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 tb1)
    (setvar "cmdecho" 0)
    (if (setq xr1 (entsel "nSelect xref to change to IDS 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 "|*"))
    (setq xr6 (strcat xr3 "|L-TEXTS_LEGEND"))
    (command "-layer" "c" "2" xr6 "")
    (command "-layer" "lt" "Continuous" xr6 "")
    (command "-layer" "lw" "Default" xr6 "")
    (setq xr7 (strcat xr3 "|L-equpt_meter"))
    (command "-layer" "c" "1" xr7 "")
    (command "-layer" "lt" "Dashed" xr7 "")
    (command "-layer" "lw" "Default" xr7 "")
    (setq xr8 (strcat xr3 "|L-TEXTS_NOTES"))
    (command "-layer" "c" "3" xr8 "")
    (command "-layer" "ltype" "Phantom" xr8 "")
    (command "-layer" "lw" "Default" xr8 "")
    )
    (prompt (strcat "n""xr3"" is not an X-Ref."))
    )
    )
    (prompt "nNo External Reference selected")
    )
    )
    )
    (setvar "cmdecho" 1)
    (princ)
    )
    Last edited by Glenn Pope; 2005-08-22 at 08:50 PM. Reason: Fixed code tag
    AutoCAD 2010 Windows7 Ultimate
    _________________________________________________________
    My spelling is wobbly. It's good spelling but it wobbles and the letters get in the wrong places.
    ... Winnie the Pooh

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

    Default Re: Lisp to change xref layers by a set of given layer name

    Kyle,

    Why not create a sub-routine to do your changes to your layers and call it with an included list of things to change.

    In place of this
    Code:
    (setq xr6 (strcat xr3 "|L-TEXTS_LEGEND"))
    (command "-layer" "c" "2" xr6 "")
    (command "-layer" "lt" "Continuous" xr6 "")
    (command "-layer" "lw" "Default" xr6 "")
    Use something along the lines of this
    Code:
    (defun correctlayer ( layername color ltype lweight / )
    (command "-layer" "c" color layername "lt" ltype layername "lw" lweight layername "")
    )
    And then call the sub-routine like this
    Code:
    (correctlayer (list "|L-TEXTS_LEGEND" "2" "Continuous" "Default"))
    This could reduce your code to this
    Code:
    (defun C:X-I96 (/ 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 IDS 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
    		(list (strcat XR3 "|L-TEXTS_LEGEND") "2" "Continuous" "Default")
    	      )
    	      (CORRECTLAYER
    		(list (strcat XR3 "|L-equpt_meter") "1" "Dashed" "Default")
    	      )
    	      (CORRECTLAYER
    		(list (strcat XR3 "|L-TEXTS_NOTES") "3" "Phantom" "Default")
    	      )
    	    )
    	    (prompt (strcat "n" "xr3" " is not an X-Ref."))
    	  )
    	)
    	(prompt "nNo External Reference selected")
          )
        )
      )
      (setvar "cmdecho" 1)
      (princ)
    )
    If you are going to repeat a series of identical steps, with only changes to variables (such as your changing the layers, colors, etc.), I would recommend you create a sub-routine for those steps. Try breaking down the big routine into smaller steps.

    HTH
    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

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

    Default Re: Lisp to change xref layers by a set of given layer name

    Richard,

    Sorry, there is a problem with the code, this is what I get when I run your code on the same drawing I check my code on.

    Command: x-I96
    nSelect xref to change to IDS standards for a 1/8'' drawing: ; error: too few
    arguments
    Quote Originally Posted by richardl.25628
    Kyle,

    Why not create a sub-routine to do your changes to your layers and call it with an included list of things to change.

    In place of this
    Code:
    (setq xr6 (strcat xr3 "|L-TEXTS_LEGEND"))
    (command "-layer" "c" "2" xr6 "")
    (command "-layer" "lt" "Continuous" xr6 "")
    (command "-layer" "lw" "Default" xr6 "")
    Use something along the lines of this
    Code:
    (defun correctlayer ( layername color ltype lweight / )
    (command "-layer" "c" color layername "lt" ltype layername "lw" lweight layername "")
    )
    And then call the sub-routine like this
    Code:
    (correctlayer (list "|L-TEXTS_LEGEND" "2" "Continuous" "Default"))
    This could reduce your code to this
    Code:
    (defun C:X-I96 (/ 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 IDS 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
    		(list (strcat XR3 "|L-TEXTS_LEGEND") "2" "Continuous" "Default")
    	 )
    	 (CORRECTLAYER
    		(list (strcat XR3 "|L-equpt_meter") "1" "Dashed" "Default")
    	 )
    	 (CORRECTLAYER
    		(list (strcat XR3 "|L-TEXTS_NOTES") "3" "Phantom" "Default")
    	 )
    	 )
    	 (prompt (strcat "n" "xr3" " is not an X-Ref."))
    	 )
    	)
    	(prompt "nNo External Reference selected")
    )
    )
    )
    (setvar "cmdecho" 1)
    (princ)
    )
    If you are going to repeat a series of identical steps, with only changes to variables (such as your changing the layers, colors, etc.), I would recommend you create a sub-routine for those steps. Try breaking down the big routine into smaller steps.

    HTH
    AutoCAD 2010 Windows7 Ultimate
    _________________________________________________________
    My spelling is wobbly. It's good spelling but it wobbles and the letters get in the wrong places.
    ... Winnie the Pooh

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

    Default Re: Lisp to change xref layers by a set of given layer name

    Quote Originally Posted by kylec_edg
    Richard,

    Sorry, there is a problem with the code, this is what I get when I run your code on the same drawing I check my code on.
    Kyle,

    Sorry about that. I wasn't thinking very well.

    remove the items in red in your main function when calling the sub-routine
    Code:
    (correctlayer (list "|L-TEXTS_LEGEND" "2" "Continuous" "Default"))
    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Change XREF layers
    By Wish List System in forum AutoCAD Wish List
    Replies: 10
    Last Post: 2016-12-10, 02:49 PM
  2. Change layers in a lisp
    By luislhss in forum AutoLISP
    Replies: 3
    Last Post: 2013-07-08, 08:34 PM
  3. Replies: 0
    Last Post: 2008-03-17, 02:07 AM
  4. Replies: 6
    Last Post: 2007-05-30, 05:45 PM
  5. Replies: 10
    Last Post: 2007-04-27, 06:17 PM

Posting Permissions

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