Author Topic: Changing the Layout Tabs Color with a Lisp  (Read 4438 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Changing the Layout Tabs Color with a Lisp
« on: August 19, 2013, 11:30:44 AM »
I am trying to get  a lisp to change the layout tab color from the "Display Plot Styles" Color White; to "Turn off Display Plot Styles" Color Black.

Lisp to Show Plot Styles On

Code - Auto/Visual Lisp: [Select]
  1. (Defun showpstyle ( / DOC LAYOUTS)
  2.         layouts (vla-get-layouts doc)
  3.         ); setq
  4.   (vlax-for n layouts
  5.     (vl-catch-all-apply 'vla-put-showplotstyles (list n :vlax-true))
  6.     ); vlax-for
  7.   (vla-regen doc acAllViewports)
  8.   (mapcar 'vlax-release-object (list layouts doc))
  9.   (princ)
  10.   ); defun
  11. (showpstyle)
  12.  
  13. (setq DisplayObj
  14. )))
  15. (vlax-put-property DisplayObj 'Layoutbackground 7)
  16.  
  17. (vlax-release-object DisplayObj)




Lisp to Turn off Plot Styles

Code - Auto/Visual Lisp: [Select]
  1. (Defun showpstyle ( / DOC LAYOUTS)
  2.         layouts (vla-get-layouts doc)
  3.         ); setq
  4.   (vlax-for n layouts
  5.     (vl-catch-all-apply 'vla-put-showplotstyles (list n :vlax-false))
  6.     ); vlax-for
  7.   (vla-regen doc acAllViewports)
  8.   (mapcar 'vlax-release-object (list layouts doc))
  9.   (princ)
  10.   ); defun
  11. (showpstyle)
  12.  
  13. (setq DisplayObj
  14. )))
  15. (vlax-put-property DisplayObj 'Layoutbackground 0)
  16.  
  17. (vlax-release-object DisplayObj)
« Last Edit: August 22, 2013, 10:15:20 AM by CAB »
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Changing the Layout Tabs Color with a Lisp
« Reply #1 on: August 19, 2013, 01:00:39 PM »
I found an answer and would like to share it


Found here: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Update-this-LISP-for-Display-Plot-Styles-in-2012/td-p/3807876


Code - Auto/Visual Lisp: [Select]
  1. ;-------------------------------------------------------
  2. ; DPS - DisplayPlotStyles
  3. ; 04/03/10 ruul at ctr.co.at
  4. ; nomen est omen - toggles display of plotstyles...
  5. ;-------------------------------------------------------
  6. ; Updated 110208 by Mike Sweeney
  7. ; Added code to change background color of layout tabs to black or white (depending on state of 'Display Plot Styles')
  8. ; Added (BGWhite) and (BGBlack) sub-routines
  9. ;-------------------------------------------------------
  10.  
  11.  
  12. (defun DPS_Post ()
  13.   (setvar "cmdecho" 0)
  14.   (command "_.regenall")
  15.   (setvar "cmdecho" 1)
  16.   (princ)
  17. )
  18. ;-------------------------------------------------------
  19. (defun c:DPSON ()
  20.   (rm:displayplotstyles t nil)
  21.   (BGWhite)
  22.   (DPS_Post)
  23. )
  24. ;-------------------------------------------------------
  25. (defun c:DPSONALL ()
  26.   (rm:displayplotstyles t t)
  27.   (BGWhite)
  28.   (DPS_Post)
  29. )
  30. ;-------------------------------------------------------
  31. (defun c:DPSOFF ()
  32.   (rm:displayplotstyles nil nil)
  33.   (BGBlack)
  34.   (DPS_Post)
  35. )
  36. ;-------------------------------------------------------
  37. (defun c:DPSOFFALL ()
  38.   (rm:displayplotstyles nil t)
  39.   (BGBlack)
  40.   (DPS_Post)
  41. )
  42. ;-------------------------------------------------------
  43. ;
  44. ;
  45. (defun rm:displayplotstyles (bshow ball / acapp acdoc layouts layout bvshow)
  46.    (princ "\n...Display plotstyles ")
  47.  
  48.    (setq layouts (vla-get-layouts acdoc))
  49.    (setq bvshow (if bshow :vlax-true :vlax-false))
  50.    (princ (if bshow "ON" "OFF"))
  51.    (cond
  52.       (ball
  53.          (vlax-for layout layouts
  54.             (if (/= (vla-get-name layout) "Model")
  55.             (vla-put-ShowPlotStyles layout bvshow))
  56.          )
  57.       (princ " in all layouts.\n")
  58.       )
  59.       (T (setq layout (vla-get-ActiveLayout acdoc))
  60.          (vla-put-ShowPlotStyles layout bvshow)
  61.          (princ " in current layout.\n")
  62.       )
  63.    )
  64.    (prin1)
  65. )
  66.  
  67.  
  68. ; Set the background in model and paper space to white
  69. (defun BGWhite ()
  70. )
  71.  
  72. ; Set the background in model and paper space to black
  73. (defun BGBlack  ()
  74. )
  75. ;---------------------------------------------- ---------
  76. (princ (strcat "\n...DisplayPlotStyles is loaded || DPSON, DPSONALL, DPSOFF, DPSOFFALL...\n"))
  77. ;--------------------------------------------- ----------[\code]
« Last Edit: August 22, 2013, 10:16:00 AM by CAB »
Civil3D 2020

BlackBox

  • King Gator
  • Posts: 3770
Re: Changing the Layout Tabs Color with a Lisp
« Reply #2 on: August 19, 2013, 02:01:05 PM »
[Edit] - Looks like you found the right Property while I composed my post.



The Property you're after is the GraphicsWinLayoutBackgrndColor, methinks... Here's a quickly written toggle routine:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:ShowPlotStyle (/ *error* _ShowPlotStyle acApp acDoc acDispPrefs)
  3.  
  4.   (defun *error* (msg)
  5.     (if acDoc
  6.       (vla-regen acDoc acallviewports)
  7.     )
  8.     (cond ((not msg))                                                   ; Normal exit
  9.           ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
  10.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  11.     )
  12.     (princ)
  13.   )
  14.  
  15.   (defun _ShowPlotStyle (acDoc value)
  16.     (vlax-for x (vla-get-layouts acDoc)
  17.       (vl-catch-all-apply 'vla-put-showplotstyles (list x value))
  18.     )
  19.   )
  20.  
  21.   (if
  22.     (and (setq acApp (vlax-get-acad-object))
  23.          (setq acDoc (vla-get-activedocument acApp))
  24.          (setq acDispPrefs (vla-get-display (vla-get-preferences acApp)))
  25.     )
  26.      (if *GraphicsWinLayoutBackgrndColor*
  27.        (progn                                                           ; disable
  28.          (setq *GraphicsWinLayoutBackgrndColor*
  29.                   acDispPrefs
  30.                   *GraphicsWinLayoutBackgrndColor*
  31.                 )
  32.          )
  33.          (_ShowPlotStyle acDoc :vlax-false)
  34.        )
  35.        (progn                                                           ; enable
  36.          (setq *GraphicsWinLayoutBackgrndColor*
  37.                   acDispPrefs
  38.                 )
  39.          )
  40.            acDispPrefs
  41.            16777215
  42.          )
  43.          (_ShowPlotStyle acDoc :vlax-true)
  44.        )
  45.      )
  46.   )
  47.   (*error* nil)
  48. )
  49.  



... If this is a critical setting, I'd also suggest you incorporate an Event handler which restores your original options prior to the Application closing.

Cheers
"How we think determines what we do, and what we do determines what we get."