乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 21|回复: 8

[编程交流] 快速切换Autocad颜色Sch

[复制链接]
VVA

1

主题

308

帖子

308

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-6 08:51:33 | 显示全部楼层 |阅读模式
该程序允许您在AutoCAD中应用配色方案(如WinAmp)
设置存储在xml文件中。
Dwgru\u color\u模式。xml文件的位置应支持AutoCAD。
由2个命令定义:
ACS-应用所选方案
GetShema-打印在当前配色方案的文本框片段设置xml文件中。
颜色sheme。拉链
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:03:33 | 显示全部楼层
非常有创意的弗拉基米尔,我喜欢这个主意
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:12:04 | 显示全部楼层
谢谢VVA。这是一个新的想法来放松眼睛和一些ex如何处理XML文件^
回复

使用道具 举报

0

主题

11

帖子

11

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 09:18:23 | 显示全部楼层
谢谢你这个好主意。
回复

使用道具 举报

VVA

1

主题

308

帖子

308

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-6 09:27:26 | 显示全部楼层
感谢您的关注。这段代码是为了演示动态对话的形成,并将数据存储在xml文件中。
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:36:19 | 显示全部楼层
嗨,VVA,很有趣的是,我不擅长XML结构,所以我将其修改为注册表存储,以制作一个新的脏版本,希望您不要介意。
我想问一下,当双击一个列表框中的“项目”时,如何使用$Reason 4来应用,就像选择应用按钮一样。互联网上的一些例子不足以让我的IQ分数很低^^
  1. ;;-------------------=={ Color sheme }==------------------------;;
  2. ;;                                                              ;;
  3. ;;  Change the color scheme in AutoCAD (like WinAmp)            ;;
  4. ;;  the data of color schemes for AutoCAD stored in xml file    ;;
  5. ;;--------------------------------------------------------------;;
  6. ;; Author: Vladimir Azarko (VVA), Copyright © 2011 - www.dwg.ru ;;
  7. ;; Some of updates : Ketxu (Nguyen Son Tung                     ;;
  8. ;;--------------------------------------------------------------;;
  9. ;; Special thanks                                               ;;
  10. ;; gomer - idea                                                 ;;
  11. ;; Vov.ka - xml parser                                          ;;
  12. ;; Alexandr Rivilis - GetOleColor, GerRGB                       ;;
  13. ;;--------------------------------------------------------------;;
  14. ;; ALL RIGHTS REMOVED                                           ;;
  15. ;;--------------------------------------------------------------;;
  16. ;;--------------------------------------------------------------;;
  17. (defun c:ACS()
  18. (setq appRegPath "HKEY_CURRENT_USER\\Software\\ACS\")
  19. (defun ACS:WK (key)(vl-registry-write (setq rt (strcat appRegPath key))) rt)
  20. (defun ACS:WV (path key val)(vl-registry-write (ACS:WK path) key (vl-princ-to-string val))) ;Reg write
  21. (defun ACS:W_Shema (x) (ACS:WV (car x) nil (cadr x)))
  22. (defun ACS:RV (path key)(read(vl-registry-read (strcat appRegPath path) key))) ;Reg read
  23. (defun ACS:Apply_Shema (themes)(mapcar '(lambda(x y) (set_shema (eval x)  y)) lstFunc_Put (ACS:RV themes nil)))
  24. (defun ACS:Insert_Shema (sName lstColor) ;Insert Shema to Reg
  25. (or sName (setq sName (strcat "Themes - " (menucmd (strcat "m=$(edtime,"  (rtos (getvar "DATE") 2  ",DD:MO:YY - HH:MM:SS)")))))
  26. (ACS:W_Shema
  27. (cons sName
  28.     (list
  29.     (cond
  30.         (lstColor)   
  31.         (list
  32.             ((lambda (display)
  33.                 (mapcar '(lambda (x)                                          
  34.                               (GetRGB (vlax-variant-value
  35.                                          (vlax-variant-change-type
  36.                                            (eval (list x display))
  37.                                            vlax-vblong
  38.                                          ) ;_ end of vlax-variant-change-type
  39.                                        ) ;_ end of vlax-variant-value
  40.                                ) ;_ end of GetRGB                                                   
  41.                          ) ;_ end of lambda
  42.                         (list
  43.                           'vla-get-graphicswinmodelbackgrndcolor
  44.                           'vla-get-modelcrosshaircolor
  45.                           'vla-get-textwinbackgrndcolor
  46.                           'vla-get-textwintextcolor
  47.                           'vla-get-graphicswinlayoutbackgrndcolor
  48.                           'vla-get-layoutcrosshaircolor) ;_ end of list
  49.                 ) ;_ end of mapcar
  50.               ) ;_ end of lambda
  51.                (vla-get-display
  52.                  (vla-get-preferences (vlax-get-acad-object))
  53.                ) ;_ end of vla-get-display
  54.             )
  55.         )
  56.     )
  57.     )
  58. )
  59. )
  60. )
  61. ;;; A. Rivilis
  62. (defun GetOleColor (r g b) (+ r (lsh g  (lsh b 16)))
  63. (defun GetRGB (Olecolor)
  64.   (list
  65.     (logand Olecolor 255)
  66.     ;; R
  67.     (logand (lsh Olecolor - 255)
  68.     ;; G
  69.     (logand (lsh Olecolor -16) 255)
  70.     ;; B
  71.   ) ;_ end of list
  72. ) ;_ end of defun
  73. (defun set_shema (func lst)
  74. ;;; func - function like 'vla-put-ModelCrosshairColor
  75. ;;; lst - RGB list (R G B) or (255 0 234)
  76.   (func
  77.     (vla-get-display
  78.       (vla-get-preferences (vlax-get-acad-object))
  79.     ) ;_ end of vla-get-display
  80.     (vlax-make-variant (apply 'GetOleColor lst) vlax-vblong)
  81.   ) ;_ end of func
  82. ) ;_ end of defun
  83. ;VVA : i change sth to learn about action in DCL
  84. (defun mydcl (zagl info-list / fl ret dcl_id)
  85.   (vl-load-com)
  86.   (or zagl (setq zagl "Select"))
  87.   (setq fl (vl-filename-mktemp "mip" nil ".dcl"))
  88.   (setq ret (open fl "w")
  89.   ud (lambda()
  90.             (start_list "info" 3)
  91.             (mapcar 'add_list (setq info-list (acad_strlsort  (vl-registry-descendents  appRegPath))))
  92.             (end_list))
  93.     )
  94.   (mapcar
  95.     '(lambda (x) (write-line x ret))
  96.     (list "mip_msg : dialog { "
  97.           (strcat "label="" zagl "";")
  98.           " :list_box {"
  99.           "alignment=top ;width=51 ;allow_accept = true;"
  100.           "tabs = "16 32";tab_truncate = true;"
  101.             (if (> (length info-list) 26)
  102.                 "height= 26 ;"
  103.                 (strcat "height= " (itoa (+ 3 (length info-list))) ";")
  104.             ) ;_ end of if
  105.           "is_tab_stop = false ;"
  106.           "key = "info";}"         
  107.           " :row {"
  108.           " :button {"
  109.           "label=" OK ";"
  110.           "key = "Accept";"
  111.           "is_cancel = true;}"
  112.           " :button {"
  113.           "label="Apply";"
  114.           "key = "kApply";}"
  115.           " :button {"
  116.           "label="Insert";"
  117.           "key = "kInsert";}"   
  118.           " :button {"
  119.           "label="Delete";"
  120.           "key = "kDelete";}"
  121.           " :button {"
  122.           "label="Cancel ";"
  123.           "key = "kCancel";}"
  124.           "}}"         
  125.     ) ;_ end of list
  126.   ) ;_ end of mapcar
  127.   (setq ret (close ret))
  128.   (if (and (not (minusp (setq dcl_id (load_dialog fl))))
  129.            (new_dialog "mip_msg" dcl_id)
  130.       ) ;_ end of and
  131.     (progn
  132.       (start_list "info")
  133.       (mapcar 'add_list info-list)
  134.       (end_list)
  135.       (set_tile "info" "0")
  136.       (setq ret (car info-list))
  137.       (action_tile
  138.         "info"
  139.         "(setq ret (nth (atoi $value) info-list))"
  140.       ) ;_ end of action_tile
  141.       (action_tile
  142.         "kCancel"
  143.         "(progn(setq ret nil)(done_dialog 0))"
  144.       ) ;_ end of action_tile
  145.       (action_tile "Accept" "(done_dialog 1)")
  146.       (action_tile "kApply" "(ACS:Apply_Shema (nth (atoi(get_tile "info")) info-list))")
  147.       (action_tile "kInsert" "(ACS:Insert_Shema nil nil)(ud)")
  148.       (action_tile "kDelete" "(vl-registry-delete (strcat appRegPath (nth (atoi(get_tile "info")) info-list)))(ud)")      
  149.       (start_dialog)
  150.     ) ;_ end of progn
  151.   ) ;_ end of if
  152.   (unload_dialog dcl_id)
  153.   (vl-file-delete fl)
  154.   ret)
  155. (setq lstFunc_Put
  156.     '(
  157.     vla-put-GraphicsWinModelBackgrndColor
  158.     vla-put-ModelCrosshairColor
  159.     vla-put-TextWinBackgrndColor
  160.     vla-put-TextWinTextColor
  161.     vla-put-GraphicsWinLayoutBackgrndColor
  162.     vla-put-LayoutCrosshairColor
  163.     ))
  164. (cond
  165.     ((not (vl-registry-descendents  appRegPath)) ;First run
  166.         (mapcar 'ACS:W_Shema
  167.             (list
  168.                 (cons  "Classic"     (list (list '(0 0 0) '(255 255 255)  '(255 255 255) '(0 0 0) '(255 255 255) '(0 0 0))))               
  169.                 (cons  "Negative"     (list (list '(255 255 255) '(0 0 0) '(0 0 0) '(255 255 255) '(255 255 255) '(0 0 0))))
  170.                 (cons  "Winter"     (list (list '(214 214 214) '(0 0 0) '(255 255 255) '(0 0 0) '(255 255 255) '(0 0 0))))
  171.                 (cons  "The Matrix" (list (list '(0 0 0) '(0 255 0) '(0 0 0) '(0 255 0) '(255 255 255) '(0 0 0))))
  172.                 (cons  "Ocean"         (list (list '(0 0 0) '(255 255  255) '(0 173 173)  '(255 255 255) '(255 255 255) '(0 0 0))))
  173.                 (cons  "Pascal"     (list (list '(0 0 0) '(255 255 255) '(0 0 255) '(255 255 0) '(255 255 255) '(0 0 0))))
  174.                 (cons  "Sakura"     (list (list '(0 0 0) '(246 223 233) '(246 223 233) '(120 70 44) '(255 255 255) '(0 0 0))))
  175.                 (cons  "Deep dive"     (list (list '(38 40 48) '(127 159  255) '(38 40 48) '(127 159 255) '(51 102 255) '(0 0 0))))
  176.             )
  177.         )
  178.     )
  179. )
  180. (if (setq item (mydcl "Select Shema to Apply :" (acad_strlsort  (vl-registry-descendents  appRegPath))))
  181.     (ACS:Apply_Shema item)
  182. )
  183. )
回复

使用道具 举报

VVA

1

主题

308

帖子

308

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-6 09:37:36 | 显示全部楼层
只要阅读这些帖子
双击列表框
正在运行的对话框
AutoLISP宝箱
在dcl列表框中双击
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:46:29 | 显示全部楼层
谢谢你,VVA,它很有用,我知道该做什么^
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 09:58:15 | 显示全部楼层
非常有趣的VVA。
 
干杯
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 06:19 , Processed in 0.949270 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表