See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: changing the viewport layers color

  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 changing the viewport layers color

    Hello everyone,

    I'm in need of a lisp program that after I select a viewport it changes a list of layers' viewport color to a preset color.

    Here is the list of layers and colors the viewport color need to change to.
    For layer LP-PLNT_TREE* change viewpoint layer color to green

    For layer LP-PLNT_TURF-PATT* change viewpoint layer color to magenta
    For layer LP-PLNT_VINE* change viewpoint layer color to white

    I need it to have * wildcard because it will have -sht1, -sht2, etc after it in different viewports.


    Thanks, for the help.

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

    Default Re: changing the viewport layers color

    What are the steps you would do this if you were doing this manually? Have you looked at the options provided by the command line version of the LAYER command? What about the VPLAYER command?
    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

  3. #3
    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: changing the viewport layers color

    Quote Originally Posted by Opie View Post
    What are the steps you would do this if you were doing this manually? Have you looked at the options provided by the command line version of the LAYER command? What about the VPLAYER command?
    Opie,

    I had started using the VPLAYER command but the code will not work correctly.
    Code:
    (DEFUN C:ZVPCTREE()(COMMAND "VPLAYER" "COLOR" "3" "LP-PLNT_TREE-SHT*" "COLOR" "6" "LP-PLNT_VINE-SHT*" "COLOR" "7" "LP-PLNT_TURF-PATT*" "ALL" "")(princ))
    Thanks,

    Cadd4la
    Last edited by Opie; 2022-04-28 at 01:32 PM. Reason: change quote tags to code tags

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

    Default Re: changing the viewport layers color

    Where does it fail to work? Can you break it down into smaller instances of the VPLAYER command to see where it is breaking?

    The code you posted appears correct. Are objects not set to ByLayer or elements inside blocks not set to ByBlock?
    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

  5. #5
    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: changing the viewport layers color

    Quote Originally Posted by Opie View Post
    Where does it fail to work? Can you break it down into smaller instances of the VPLAYER command to see where it is breaking?

    The code you posted appears correct. Are objects not set to ByLayer or elements inside blocks not set to ByBlock?
    Opie,

    When I run the code It will only change the LP-PLNT_TREE-SHT* layer and skip LP-PLNT_VINE-SHT* and LP-PLNT_TURF-PATT layers, and all of the objects are set to ByLayer.

    Thanks,

    Cadd4la

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

    Default Re: changing the viewport layers color

    Try this, note the rgb Vplayer asks for RGB

    Code:
    (DEFUN C:ZVPCTREE()
    (setq lays (list (list "127,255,127" "LP-PLNT_TREE-SHT*")(list "255,0,255" "LP-PLNT_VINE-SHT*")(list "255,255,255" "LP-PLNT_TURF-PATT*")))
    (foreach lay lays 
    (COMMAND "VPLAYER" "COLOR" (car lay) (cadr lay) "ALL" "")
    )
    (princ)
    )

  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: changing the viewport layers color

    Big-Al,

    Thank you so much for your help, it works great!!!!

    Cad44la

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

    Default Re: changing the viewport layers color

    Quote Originally Posted by cadd4la View Post
    Opie,

    When I run the code It will only change the LP-PLNT_TREE-SHT* layer and skip LP-PLNT_VINE-SHT* and LP-PLNT_TURF-PATT layers, and all of the objects are set to ByLayer.

    Thanks,

    Cadd4la
    Your original code was missing a step between each color assignment per the VPLAYER command steps, with the exception of the last color assignment. You never specified which viewport your color assignments were designated to change. Adding "All" after each layer name (with the exception of the last one) should fix your code.

    Quote Originally Posted by BIG-AL View Post
    Try this, note the rgb Vplayer asks for RGB

    Code:
    (DEFUN C:ZVPCTREE()
    (setq lays (list (list "127,255,127" "LP-PLNT_TREE-SHT*")(list "255,0,255" "LP-PLNT_VINE-SHT*")(list "255,255,255" "LP-PLNT_TURF-PATT*")))
    (foreach lay lays 
    (COMMAND "VPLAYER" "COLOR" (car lay) (cadr lay) "ALL" "")
    )
    (princ)
    )
    The VPLAYER command will accept ACI color numbers either as an integer number or a string within the AutoLISP Command function call.
    Last edited by Opie; 2022-04-29 at 04:30 PM.
    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
    399
    Login to Give a bone
    0

    Default Re: changing the viewport layers color

    Opie,

    Thanks for your help.

    Cadd4la

Similar Threads

  1. Replies: 2
    Last Post: 2017-08-09, 01:04 PM
  2. Replies: 17
    Last Post: 2017-08-01, 01:12 AM
  3. 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
  4. Screen color vs Print Color vs Screen Color
    By bwiab in forum Revit Architecture - General
    Replies: 2
    Last Post: 2009-04-27, 02:22 PM
  5. layer to layer ..viewport to viewport
    By jfields.61630 in forum AutoCAD General
    Replies: 6
    Last Post: 2004-10-08, 06:57 PM

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
  •