PDA

View Full Version : changing the viewport layers color



cadd4la
2022-04-22, 10:32 PM
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.

Opie
2022-04-25, 12:25 PM
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?

cadd4la
2022-04-27, 11:37 PM
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.


(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

Opie
2022-04-28, 01:33 PM
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?

cadd4la
2022-04-29, 12:24 AM
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

BIG-AL
2022-04-29, 04:31 AM
Try this, note the rgb Vplayer asks for RGB



(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)
)

cadd4la
2022-04-29, 03:05 PM
Big-Al,

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

Cad44la

Opie
2022-04-29, 03:51 PM
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.


Try this, note the rgb Vplayer asks for RGB



(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.

cadd4la
2022-04-29, 04:03 PM
Opie,

Thanks for your help.

Cadd4la