李青松 发表于 2019-8-16 16:44:38

怎样用lisp来控制绘图背景黑色与白色的切换

怎样用lisp来控制绘图背景黑色与白色的切换

start4444 发表于 2019-8-16 17:17:51

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=102288&highlight=%D0%DE%B8%C4CAD%B1%B3%BE%B0%D1%D5%C9%AB
参考这里的

李青松 发表于 2019-8-16 17:44:59

如果是黑色就该改成白色,如果是黑色就该改成白色,进行切换,用一个命令控制。程序怎么改

(defun c:tt (/ VAR-COLOUR DISPLAY clno blue rde green)
(setq clno (getint "\n=>输入颜色序号!"))
(prompt "\n,1=红,2=黄,3=绿,4=青,5=蓝,6=紫,7=白,8=灰,9=灰白"
)
(cond      ((= clno 1)
         (progn (setq rde 255) (setq green 0) (setq blue 0))
      )
      ((= clno 2)
         (progn (setq rde 255) (setq green 255) (setq blue 0))
      )
      ((= clno 3)
         (progn (setq rde 0) (setq green 255) (setq blue 0))
      )
      ((= clno 4)
         (progn (setq rde 0) (setq green 255) (setq blue 255))
      )
      ((= clno 5)
         (progn (setq rde 0) (setq green 0) (setq blue 255))
      )
      ((= clno 6)
         (progn (setq rde 255) (setq green 0) (setq blue 255))
      )
      ((= clno 7)
         (progn (setq rde 255) (setq green 255) (setq blue 255))
      )
      ((= clno 8)
         (progn (setq rde 128) (setq green 128) (setq blue 128))
      )
      ((= clno 9)
         (progn (setq rde 192) (setq green 192) (setq blue 192))
      )
      (t (progn (setq rde 0) (setq green 0) (setq blue 0)))
)
(setq
    VAR-COLOUR (vlax-make-variant
               (+ rde (* green 256)(* blue 65536))
               vlax-vblong
               )
    DISPLAY    (vla-get-display
               (vla-get-preferences
                   (vla-get-application (vlax-get-acad-object))
               )
               )
)
(vla-put-graphicswinlayoutbackgrndcolor DISPLAY VAR-COLOUR)
(vla-put-graphicswinmodelbackgrndcolor DISPLAY VAR-COLOUR)
)

yshf 发表于 2019-8-16 21:22:15

;执行两次程序,模型空间背景颜色在黑色与白色之间切换
(defun c:bjys()
    (vl-load-com)
    (setq yssz (variant-value
                  (vlax-variant-change-type
                        (vla-get-GraphicsWinModelBackgrndColor      
                               (setq display (vla-get-display
                                                (vla-get-preferences
                                                       (vlax-get-acad-object)
                                                )
                                             )
                               )
                        )
                        vlax-vblong
                  )
                )
    )
    (setq yssz(vlax-make-variant (abs (- yssz 16777215)) vlax-vblong))
    (vla-put-GraphicsWinModelBackgrndColor display yssz)
    (vlax-release-object display)
    (princ)
)

start4444 发表于 2019-8-16 22:01:22

本帖最后由 start4444 于 2019-8-16 22:13 编辑

背景在黑与白之间转换

摘自明经通道

(defun c:ax (/ prefdisplay)
(vl-load-com)
(setq prefdisplay (vla-get-display (vla-get-preferences
                                                          (vlax-get-acad-object)
                                     )
                  )
      color (vlax-variant-value (vlax-variant-change-type
                                                            (vla-get-graphicswinmodelbackgrndcolor prefdisplay)
                                                            vlax-vblong
                                  )
            )
)
(vla-put-graphicswinmodelbackgrndcolor prefdisplay
                                       (vlax-make-variant (if (= color 0)
                                                            16777215
                                                            0
                                                            ) vlax-vblong
                                       )
)
(princ)
)

start4444 发表于 2019-8-16 22:10:58

根据二楼修改的
(defun c:tt5(/ col DISPLAY)
        (setq    DISPLAY    (vla-get-display
                                                                                                (vla-get-preferences
                                                                                                        (vla-get-application (vlax-get-acad-object))
                                                                                                )
                                                                                        )
)
        (if (= (getenv "Background") "0") (setq col 255) (setq col 0))
        (vla-put-graphicswinlayoutbackgrndcolor DISPLAY (vlax-make-variant
                                                                                                                                                                                                                (+ col (* col 256)(* col 65536))
                                                                                                                                                                                                                vlax-vblong
                                                                                                                                                                                                        ))
(vla-put-graphicswinmodelbackgrndcolor DISPLAY (vlax-make-variant
                                                                                                                                                                                                       (+ col (* col 256)(* col 65536))
                                                                                                                                                                                                       vlax-vblong
                                                                                                                                                                                               ))
        (princ)
)

ketxu 发表于 2019-8-29 02:43:19

Do you want like this :o

https://www.youtube.com/watch?v=_wcSnFInffA
页: [1]
查看完整版本: 怎样用lisp来控制绘图背景黑色与白色的切换