See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: assign layer lineweight based on layer color

  1. #1
    Member
    Join Date
    2000-11
    Posts
    13
    Login to Give a bone
    0

    Question assign layer lineweight based on layer color

    Any suggestions no how to write a lisp routine to add lineweight values to layers based on their layer color? Thanks in advance!

    - Kevin

  2. #2
    Super Moderator david_peterson's Avatar
    Join Date
    2002-09
    Location
    Madison, WI
    Posts
    5,687
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    Isn't that what they make .ctb files for?

    ~sorry I had to do it ~

  3. #3
    Member
    Join Date
    2000-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    Quote Originally Posted by david_peterson
    Isn't that what they make .ctb files for?

    ~sorry I had to do it ~
    Yeah, let's not go there.

  4. #4
    Super Moderator david_peterson's Avatar
    Join Date
    2002-09
    Location
    Madison, WI
    Posts
    5,687
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    If you need a quick fix for a few drawings, you could use the filter command to select all object of color "x" and then change the properties.

  5. #5
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    Quote Originally Posted by kjbusacker
    Any suggestions no how to write a lisp routine to add lineweight values to layers based on their layer color? Thanks in advance!

    - Kevin
    Hi Kevin,

    Maybe this will get you started:

    Code:
    (defun c:assignlineweights ( / layers_col col)
      (vl-load-com)
      (or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
      (setq layers_col (vla-get-layers *acaddoc*))
      (vlax-for item layers_col
        (setq col (vlax-get-property item 'color))
        (cond ((= col 1)(vlax-put-property item 'LineWeight acLnWt005))
                 ((= col 2)(vlax-put-property item 'LineWeight acLnWt018))
                 ((= col 3)(vlax-put-property item 'LineWeight acLnWt060));copy down and change to suit
     
    
       )
      )
    (princ)
    )
    The lineweights are listed in the developers documentation under ActiveX and VBA Reference/Properties/Lineweight Property.

    HTH

  6. #6
    Member
    Join Date
    2000-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    Quote Originally Posted by david_peterson
    If you need a quick fix for a few drawings, you could use the filter command to select all object of color "x" and then change the properties.
    Nope, have about 300 dwgs (100 layers in each) to process. Besides, I think that filter you mentioned should only give you entities assigned to color "x". All of our entities are color=256 (color by-layer).

  7. #7
    Member
    Join Date
    2000-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    Thanks Tim! I am not an experienced vl-lisper and was hoping to find more basic lisp functions like tblnext, but I will read-up on the vl functions you specified and give it the 'ol college try.

  8. #8
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    1

    Default Re: assign layer lineweight based on layer color

    Quote Originally Posted by kjbusacker
    Thanks Tim! I am not an experienced vl-lisper and was hoping to find more basic lisp functions like tblnext, but I will read-up on the vl functions you specified and give it the 'ol college try.

    No experience required:

    Each color you need to assign a lineweight will have a line like this:

    Code:
    ((= col 2)(vlax-put-property item 'LineWeight acLnWt018))
    In this example line, any layer with color yellow (2) will be assigned a lineweight of 0.18mm. To add more, just copy the line down, change the color number, and look up and change the lineweight; add as many as you need.

    Let me know if you need help loading and running it once you get it set up the way you want.

    Edit: ps, you can also post your code and we'll have a look at it, if needed.
    Last edited by .T.; 2007-02-28 at 10:02 PM.

  9. #9
    Member
    Join Date
    2000-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    That works great Tim, and makes perfect sense! Thanks again.

  10. #10
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: assign layer lineweight based on layer color

    I ran into this a while back. We had our company standard layers which were following the AIA-NCS (for the most part) using colors and a .ctb file. We needed to set up for some government work which required NCS 3.1 layer names, and with lineweights, and use thier .ctb file which ignored the colors. The good thing was I had written a lisp routine to make the layers in the first place. I simply did a "find and replace" and added the lineweight function to the routine based on the colors to match our desired plotted width.

    The original routine looked like:
    Code:
    (DEFUN C:LYRS (/ CME)	 
    	(SETQ CME (GETVAR "CMDECHO"))   
    	(SETQ LYR (GETVAR "CLAYER"))   
    	(SETVAR "CMDECHO" 0) 
    (COMMAND "LAYER" "MAKE" "A-ANNO-DIMS" "COLOR" "40" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-FUTR" "COLOR" "202" "" "")
    		(COMMAND "LAYER" "MAKE" "A-ANNO-STRS-EXST" "COLOR" "20" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-STRS" "COLOR" "4" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TEXT" "COLOR" "4" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TEXT-DEMO" "COLOR" "3" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TITL" "COLOR" "4" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-MTCH" "COLOR" "5" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA" "COLOR" "5" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA-PATT" "COLOR" "10" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA-IDEN" "COLOR" "4" "" "")
    	(COMMAND "LAYER" "MAKE" "A-CLNG-DEMO" "COLOR" "122" "" "LT" "HIDDEN2" "" "")
    (PRINC)
    )
    The new one looked like this:

    Code:
    (COMMAND "LAYER" "MAKE" "A-ANNO-DIMS" "COLOR" "40" "" "LW" "0.18" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-FUTR" "COLOR" "202" "" "LW" "0.35" "" "")
    		(COMMAND "LAYER" "MAKE" "A-ANNO-STRS-EXST" "COLOR" "20" "" "LW" "0.18" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-STRS" "COLOR" "4" "" "LW" "0.35" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TEXT" "COLOR" "4" "" "LW" "0.35" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TEXT-DEMO" "COLOR" "3" "" "LW" "0.35" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-TITL" "COLOR" "4" "" "LW" "0.35" "" "")
    	(COMMAND "LAYER" "MAKE" "A-ANNO-MTCH" "COLOR" "5" "" "LW" "0.5" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA" "COLOR" "5" "" "LW" "0.5" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA-PATT" "COLOR" "10" "" "LW" "0.18" "" "")
    	(COMMAND "LAYER" "MAKE" "A-AREA-IDEN" "COLOR" "4" "" "LW" "0.35" "" "")
    	(COMMAND "LAYER" "MAKE" "A-CLNG-DEMO" "COLOR" "122" "" "LW" "0.35" "" "LT" "HIDDEN2" "" "")
    
    (PRINC)
     )
    This is just a sample, but it helped that I had the routine already written.
    Find and replace works great in situation like this.

Similar Threads

  1. Changing color of Xref layers based on color and layer name
    By tuerlinckx_peter862162 in forum AutoLISP
    Replies: 7
    Last Post: 2013-02-14, 06:46 PM
  2. Assign Lineweight per color not layer
    By fcfcadd in forum AutoLISP
    Replies: 19
    Last Post: 2008-05-14, 03:18 PM
  3. assign layer lineweights based on layer color
    By viv.howe in forum AutoLISP
    Replies: 4
    Last Post: 2007-05-01, 04:27 PM
  4. Replies: 10
    Last Post: 2007-04-27, 06:17 PM
  5. assign color to layer
    By ccowgill in forum AutoLISP
    Replies: 14
    Last Post: 2005-11-14, 02:10 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
  •