song宋_74729 发表于 2022-9-9 10:23:17

快速改色

分享源码

;快速改色 命令gs
;修改自阿甘的代码,修改面板风格
(vl-load-com)
(defun c:gs (/ fname fn x dclid lin)
       (setq fname (vl-filename-mktemp nil nil ".dcl" ))
       (setq fn (open fname "w" ))
       (foreach x '(
                   "buttonGL:button{horizontal_margin=none;vertical_margin=none;} //自定义按钮"
                   "ksgs : dialog{"
                   "label=\"快速改色V1.2-Sammy\";"
                     "   :column{"
                                                                ":boxed_column{label=\"改对像颜色\";"
                   "   :row{"
                   "      :image_button{key=\"1\";color=1;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"2\";color=2;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"3\";color=3;width=5;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :image_button{key=\"4\";color=4;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"5\";color=5;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"6\";color=6;width=5;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :image_button{key=\"7\";color=7;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"8\";color=8;width=5;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"9\";color=9;width=5;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :buttonGL{key=\"11\";label=\"随层\";width=5;height=1.6;horizontal_margin=none;}"
                   "      :buttonGL{key=\"12\";label=\"随块\";width=5;height=1.6;horizontal_margin=none;}"
                   "      :buttonGL{key=\"10\";label=\"其它\";width=5;height=1.6;horizontal_margin=none;}"
                   "   }"
                   "    }"
                     "   :column{"
                                                                ":boxed_column{label=\"改图层颜色\";"
                   "   :row{"
                   "      :image_button{key=\"51\";color=1;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"52\";color=2;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"53\";color=3;width=4;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :image_button{key=\"54\";color=4;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"55\";color=5;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"56\";color=6;width=4;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :image_button{key=\"57\";color=7;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"58\";color=8;width=4;height=1.6;horizontal_margin=none;}"
                   "      :image_button{key=\"59\";color=9;width=4;height=1.6;horizontal_margin=none;}"
                     "}"
                   "   :row{"
                   "      :buttonGL{key=\"60\";label=\"其它\";width=4;height=1.6;horizontal_margin=none;}"
                   "    }"
                   "   }"
                   "   cancel_button;"
                   "    }"
                     "}"
                     "}"
            )
            (princ x fn)
            (write-line "" fn)
       )
       (close fn)
       (setq fn (open fname "r" ))
       (setq dclid (load_dialog fname))
       (while (or (eq (substr (setq lin (vl-string-right-trim "\" fn)" (vl-string-left-trim "(write-line \"" (read-line fn)))) 1 2) "//" ) (eq (substr lin 1 (vl-string-search " " lin)) "" ) (not (eq (substr lin (+ (vl-string-search " " lin) 1) 9) " : dialog" ))))
       (new_dialog (substr lin 1 (vl-string-search " " lin)) dclid)
       (action_tile "1" "(done_dialog 1)")
       (action_tile "2" "(done_dialog 2)")
       (action_tile "3" "(done_dialog 3)")
       (action_tile "4" "(done_dialog 4)")
       (action_tile "5" "(done_dialog 5)")
       (action_tile "6" "(done_dialog 6)")
       (action_tile "7" "(done_dialog 7)")
       (action_tile "8" "(done_dialog 8)")
       (action_tile "9" "(done_dialog 9)")      
       (action_tile "10" "(done_dialog 10)")
       (action_tile "11" "(done_dialog 11)")                        
       (action_tile "12" "(done_dialog 12)")                        
       (action_tile "51" "(done_dialog 51)")
       (action_tile "52" "(done_dialog 52)")
       (action_tile "53" "(done_dialog 53)")
       (action_tile "54" "(done_dialog 54)")
       (action_tile "55" "(done_dialog 55)")
       (action_tile "56" "(done_dialog 56)")
       (action_tile "57" "(done_dialog 57)")
       (action_tile "58" "(done_dialog 58)")
       (action_tile "59" "(done_dialog 59)")
       (action_tile "60" "(done_dialog 60)")
       (action_tile "61" "(done_dialog 61)")
       (action_tile "cancel" "(done_dialog 0)" )
       (setq re (start_dialog))
       (cond
         ((= re 1) (GL:gs1))
         ((= re 2) (GL:gs2))
         ((= re 3) (GL:gs3))
         ((= re 4) (GL:gs4))
         ((= re 5) (GL:gs5))
         ((= re 6) (GL:gs6))
         ((= re 7) (GL:gs7))
         ((= re 8) (GL:gs8))      
         ((= re 9) (GL:gs9))      
         ((= re 10) (GL:gsqt))
         ((= re 11) (GL:gs11))      
         ((= re 12) (GL:gs12))      
         ((= re 51) (GL:gcs1))
         ((= re 52) (GL:gcs2))
         ((= re 53) (GL:gcs3))
         ((= re 54) (GL:gcs4))
         ((= re 55) (GL:gcs5))
         ((= re 56) (GL:gcs6))
         ((= re 57) (GL:gcs7))
         ((= re 58) (GL:gcs8))      
         ((= re 59) (GL:gcs9))      
         ((= re 60) (GL:gcsqt))
         ((= re 61) (GL:gcs11))
       )
       (unload_dialog dclid)
       (close fn)
       (vl-file-delete fname)
       (princ)
)

;-----------------------------------------------------------------
;改对像颜色
;1红.2黄.3绿.4青.5蓝.6品红.7白.8灰.9浅灰               
(defun GL:gs1()(GL:gdxys 1));红色
(defun GL:gs2()(GL:gdxys 2))
(defun GL:gs3()(GL:gdxys 3))
(defun GL:gs4()(GL:gdxys 4))
(defun GL:gs5()(GL:gdxys 5))
(defun GL:gs6()(GL:gdxys 6))
(defun GL:gs7()(GL:gdxys 7))
(defun GL:gs8()(GL:gdxys 8))
(defun GL:gs9()(GL:gdxys 9))
(defun GL:gs11()(GL:gdxys 256))
(defun GL:gs12()(GL:gdxys 0))
(defun GL:gsqt(/ yanse)
(if (setq yanse (acad_colordlg 1))
(GL:gdxys yanse)
)
)
;改对像颜色子程序
(defun GL:gdxys (dxys / en i obj ss)
(if (setq ss (ssget))
   (progn
    (setq i 0)
    (repeat (sslength ss)
   (setq en (ssname ss i));取像素名
   (setq obj (vlax-ename->vla-object en));转换像素
   (vla-put-color obj dxys);改对像颜色
   (setq i (1+ i))
    )
   ))
(princ)
)

;-----------------------------------------------------------------      
;改图层颜色
(defun GL:gcs1()(GL:gtcys 1))
(defun GL:gcs2()(GL:gtcys 2))
(defun GL:gcs3()(GL:gtcys 3))
(defun GL:gcs4()(GL:gtcys 4))
(defun GL:gcs5()(GL:gtcys 5))
(defun GL:gcs6()(GL:gtcys 6))
(defun GL:gcs7()(GL:gtcys 7))
(defun GL:gcs8()(GL:gtcys 8))
(defun GL:gcs9()(GL:gtcys 9))
(defun GL:gcs11()(GL:gtcys 256))
(defun GL:gcsqt(/ yanse)
(if (setq yanse (acad_colordlg 1))
(GL:gtcys yanse)
)
)
;改图层颜色子程序
(defun GL:gtcys (yanse / acaddoc acadobj en i lay layobj obj ss vlay vlay1)
(setq AcadObj (vlax-get-Acad-object)
            AcadDoc (vla-get-ActiveDocument AcadObj)
            LayObj (vla-get-layers AcadDoc)
)
(if (setq ss (ssget))
   (progn
    (setq i 0)
    (repeat (sslength ss)
   (setq en (ssname ss i);取像素名
         obj (vlax-ename->vla-object en);转换像素
         lay (vla-get-layer obj);图层名
         vlay (vla-item LayObj lay);转为VL图层名
   )
   (if (= (equal vlay vlay1) nil)
      (progn
       (vla-put-color vlay yanse);改图层颜色
       (setq vlay1 vlay)
   ))
   (setq i (1+ i))
    )
   ))
(princ)
)






spp_wall 发表于 2022-9-9 10:51:25

支持!!!!!!!!

zm880928 发表于 2022-9-9 11:06:28

好像不能改快的颜色

lxl217114 发表于 2022-9-9 11:39:38

作者自己也发过
http://bbs.mjtd.com/thread-185715-1-1.html

自贡黄明儒 发表于 2022-9-9 14:51:59

本帖最后由 自贡黄明儒 于 2022-9-9 14:54 编辑

超级格式刷,想改就刷,为了颜色专门写一个程序不值得。

song宋_74729 发表于 2022-9-9 14:58:56

自贡黄明儒 发表于 2022-9-9 14:51
超级格式刷,想改就刷,为了颜色专门写一个程序不值得。

超级格式刷,想改就刷
可以分享吗?

utopio 发表于 2022-9-9 15:33:40

自贡黄明儒 发表于 2022-9-9 14:51
超级格式刷,想改就刷,为了颜色专门写一个程序不值得。

这个看着不错。

magicheno 发表于 2022-9-9 21:43:14

感谢分享源码~
页: [1]
查看完整版本: 快速改色