Author Topic: How change the background color for 3D parallel projection ?  (Read 2699 times)

0 Members and 1 Guest are viewing this topic.

andy_lee

  • Newt
  • Posts: 147
Code - Auto/Visual Lisp: [Select]
  1. ;; This lisp can change background color for 2D model space
  2.  
  3. (defun c:gr (/ VAR-COLOUR DISPLAY clno blue rde green)
  4.   (setq clno (getint "\n=>Input colour No!"))
  5.   (prompt "\n,1=red,2=yellow,3=gree,4=cyan,5=blue,6=magenta,7=white"
  6.   )
  7.   (cond        ((= clno 1)
  8.          (progn (setq rde 255) (setq green 0) (setq blue 0))
  9.         )
  10.         ((= clno 2)
  11.          (progn (setq rde 255) (setq green 255) (setq blue 0))
  12.         )
  13.         ((= clno 3)
  14.          (progn (setq rde 0) (setq green 255) (setq blue 0))
  15.         )
  16.         ((= clno 4)
  17.          (progn (setq rde 0) (setq green 255) (setq blue 255))
  18.         )
  19.         ((= clno 5)
  20.          (progn (setq rde 0) (setq green 0) (setq blue 255))
  21.         )
  22.         ((= clno 6)
  23.          (progn (setq rde 255) (setq green 0) (setq blue 255))
  24.         )
  25.         ((= clno 7)
  26.          (progn (setq rde 255) (setq green 255) (setq blue 255))
  27.         )
  28.         ((= clno 8)
  29.          (progn (setq rde 128) (setq green 128) (setq blue 128))
  30.         )
  31.         ((= clno 9)
  32.          (progn (setq rde 192) (setq green 192) (setq blue 192))
  33.         )
  34.         (t (progn (setq rde 0) (setq green 0) (setq blue 0)))
  35.   )
  36.   (setq
  37.     VAR-COLOUR (vlax-make-variant
  38.                  (+ rde (* green 256)(* blue 65536))
  39.                  vlax-vblong
  40.                )
  41.     DISPLAY    (vla-get-display
  42.                  (vla-get-preferences
  43.                    (vla-get-application (vlax-get-acad-object))
  44.                  )
  45.                )
  46.   )
  47. )

How change the  background color for 3D parallel projection ?
« Last Edit: June 09, 2015, 01:48:07 AM by emk2012 »
andy.
Best regards.

77077

  • Guest
Re: How change the background color for 3D parallel projection ?
« Reply #1 on: September 29, 2014, 01:58:01 AM »
this ? This, I really don't idea...

lamarn

  • Swamp Rat
  • Posts: 636
Re: How change the background color for 3D parallel projection ?
« Reply #2 on: July 26, 2015, 04:08:46 PM »
Thanks. It helps! With also some JTB code.. :)
http://www.jtbworld.com/lisp/backgroundchanger.htm
« Last Edit: July 26, 2015, 04:20:11 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 636
Re: How change the background color for 3D parallel projection ?
« Reply #3 on: July 26, 2015, 05:15:02 PM »
In this code and in JTB code is good but unfortunately one part is still missing to get it working good for 3D use
The var 'graphicswinmodelbackgrndcolor' is assigned and only the 2D part
The 3D parallel and projection backgrounds are .. what?
See att.


Design is something you should do with both hands. My 2d hand , my 3d hand ..

andy_lee

  • Newt
  • Posts: 147
Re: How change the background color for 3D parallel projection ?
« Reply #4 on: July 26, 2015, 08:30:22 PM »
(getenv "Parallel background")
(setenv "Parallel background" "15202300")
andy.
Best regards.

lamarn

  • Swamp Rat
  • Posts: 636
Re: How change the background color for 3D parallel projection ?
« Reply #5 on: July 27, 2015, 02:57:10 AM »
Thanks for pointing that out. 8-)
How do you know these names?
Can you give me the names for perspective as well?

Design is something you should do with both hands. My 2d hand , my 3d hand ..

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: How change the background color for 3D parallel projection ?
« Reply #6 on: July 27, 2015, 06:17:37 AM »
Code - Auto/Visual Lisp: [Select]
  1. ;; This lisp can change background color for 2D model space
  2.  
  3. (defun c:gr (/ VAR-COLOUR DISPLAY clno blue rde green)
  4.   (setq clno (getint "\n=>Input colour No!"))
  5.   (prompt "\n,1=red,2=yellow,3=gree,4=cyan,5=blue,6=magenta,7=white"
  6.   )
  7.   (cond        ((= clno 1)
  8.          (progn (setq rde 255) (setq green 0) (setq blue 0))
  9.         )
  10.         ((= clno 2)
  11.          (progn (setq rde 255) (setq green 255) (setq blue 0))
  12.         )
  13.         ((= clno 3)
  14.          (progn (setq rde 0) (setq green 255) (setq blue 0))
  15.         )
  16.         ((= clno 4)
  17.          (progn (setq rde 0) (setq green 255) (setq blue 255))
  18.         )
  19.         ((= clno 5)
  20.          (progn (setq rde 0) (setq green 0) (setq blue 255))
  21.         )
  22.         ((= clno 6)
  23.          (progn (setq rde 255) (setq green 0) (setq blue 255))
  24.         )
  25.         ((= clno 7)
  26.          (progn (setq rde 255) (setq green 255) (setq blue 255))
  27.         )
  28.         ((= clno 8)
  29.          (progn (setq rde 128) (setq green 128) (setq blue 128))
  30.         )
  31.         ((= clno 9)
  32.          (progn (setq rde 192) (setq green 192) (setq blue 192))
  33.         )
  34.         (t (progn (setq rde 0) (setq green 0) (setq blue 0)))
  35.   )
  36.   (setq
  37.     VAR-COLOUR (vlax-make-variant
  38.                  (+ rde (* green 256)(* blue 65536))
  39.                  vlax-vblong
  40.                )
  41.     DISPLAY    (vla-get-display
  42.                  (vla-get-preferences
  43.                    (vla-get-application (vlax-get-acad-object))
  44.                  )
  45.                )
  46.   )
  47. )

Here's another approach:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:gr ( / col dis )
  2.     (if (setq col (acad_colordlg 1 nil))
  3.         (progn
  4.             (setq dis (vla-get-display (vla-get-preferences (LM:acapp)))
  5.                   col (LM:aci->ole col)
  6.             )
  7.             (vla-put-graphicswinlayoutbackgrndcolor dis col)
  8.             (vla-put-graphicswinmodelbackgrndcolor  dis col)
  9.         )
  10.     )
  11.     (princ)
  12. )
  13.  
  14. ;; ACI -> OLE  -  Lee Mac
  15. ;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
  16.  
  17. (defun LM:ACI->OLE ( c )
  18.     (apply 'LM:RGB->OLE (LM:ACI->RGB c))
  19. )
  20.  
  21. ;; RGB -> OLE  -  Lee Mac
  22. ;; Args: r,g,b - [int] Red, Green, Blue values
  23.  
  24. (defun LM:RGB->OLE ( r g b )
  25.     (logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16))
  26. )
  27.  
  28. ;; ACI -> RGB  -  Lee Mac
  29. ;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
  30.  
  31. (defun LM:ACI->RGB ( c / o r )
  32.     (if (setq o (vla-getinterfaceobject (LM:acapp) (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))
  33.         (progn
  34.             (setq r
  35.                 (vl-catch-all-apply
  36.                    '(lambda ( )
  37.                         (vla-put-colorindex o c)
  38.                         (list (vla-get-red o) (vla-get-green o) (vla-get-blue o))
  39.                     )
  40.                 )
  41.             )
  42.             (vlax-release-object o)
  43.             (if (vl-catch-all-error-p r)
  44.                 (prompt (strcat "\nError: " (vl-catch-all-error-message r)))
  45.                 r
  46.             )
  47.         )
  48.     )
  49. )
  50.  
  51. ;; Application Object  -  Lee Mac
  52. ;; Returns the VLA Application Object
  53.  
  54. (defun LM:acapp nil
  55.     (eval (list 'defun 'LM:acapp 'nil (vlax-get-acad-object)))
  56.     (LM:acapp)
  57. )
  58.  

The above uses my Colour Conversion Functions.