二种写法,改变线型颜色,命令1~257
本帖最后由 lxf20190917 于 2024-2-18 12:49 编辑下面说下二种更改线型的代码写法
一、常规的写法,先定义一个函数,再逐行写命令,从1~257。
演示方法一:
;定义函数 ($lxf:chang-color$ "bylayer")
;程序开始
(defun $lxf:chang-color$ (color_number / ss)
(setvar "cmdecho" 0)
(setq ss (ssget))
(while ss
(if ss (progn(vl-cmdf "_.CHANGE" ss "" "PROPERTIES" "C" color_number "")
(princ (strcat "\n *颜色改为<" color_number "> _BY 糯米88*"))
(setq ss (ssget))))(princ)
)
(princ)
)快捷命令为1~257,可以根据自己习惯修改。(defun c:1()($lxf:chang-color$ "1"))
(defun c:2()($lxf:chang-color$ "2"))
(defun c:3()($lxf:chang-color$ "3"))
(defun c:4()($lxf:chang-color$ "4"))
(defun c:5()($lxf:chang-color$ "5"))
(defun c:6()($lxf:chang-color$ "6"))
(defun c:7()($lxf:chang-color$ "7"))
(defun c:8()($lxf:chang-color$ "8"))
(defun c:9()($lxf:chang-color$ "9"))
(defun c:10()($lxf:chang-color$ "10"))
(defun c:11()($lxf:chang-color$ "11"))
(defun c:12()($lxf:chang-color$ "12"))
(defun c:13()($lxf:chang-color$ "13"))
(defun c:14()($lxf:chang-color$ "14"))
(defun c:15()($lxf:chang-color$ "15"))
(defun c:16()($lxf:chang-color$ "16"))
(defun c:17()($lxf:chang-color$ "17"))
(defun c:18()($lxf:chang-color$ "18"))
(defun c:19()($lxf:chang-color$ "19"))
(defun c:20()($lxf:chang-color$ "20"))
(defun c:21()($lxf:chang-color$ "21"))
(defun c:22()($lxf:chang-color$ "22"))
(defun c:23()($lxf:chang-color$ "23"))
(defun c:24()($lxf:chang-color$ "24"))
(defun c:25()($lxf:chang-color$ "25"))
(defun c:26()($lxf:chang-color$ "26"))
(defun c:27()($lxf:chang-color$ "27"))
(defun c:28()($lxf:chang-color$ "28"))
(defun c:29()($lxf:chang-color$ "29"))
(defun c:30()($lxf:chang-color$ "30"))
(defun c:31()($lxf:chang-color$ "31"))
(defun c:32()($lxf:chang-color$ "32"))
(defun c:33()($lxf:chang-color$ "33"))
(defun c:34()($lxf:chang-color$ "34"))
(defun c:35()($lxf:chang-color$ "35"))
(defun c:36()($lxf:chang-color$ "36"))
(defun c:37()($lxf:chang-color$ "37"))
(defun c:38()($lxf:chang-color$ "38"))
(defun c:39()($lxf:chang-color$ "39"))
(defun c:40()($lxf:chang-color$ "40"))
(defun c:41()($lxf:chang-color$ "41"))
(defun c:42()($lxf:chang-color$ "42"))
(defun c:43()($lxf:chang-color$ "43"))
(defun c:44()($lxf:chang-color$ "44"))
(defun c:45()($lxf:chang-color$ "45"))
(defun c:46()($lxf:chang-color$ "46"))
(defun c:47()($lxf:chang-color$ "47"))
(defun c:48()($lxf:chang-color$ "48"))
(defun c:49()($lxf:chang-color$ "49"))
(defun c:50()($lxf:chang-color$ "50"))
(defun c:51()($lxf:chang-color$ "51"))
(defun c:52()($lxf:chang-color$ "52"))
(defun c:53()($lxf:chang-color$ "53"))
(defun c:54()($lxf:chang-color$ "54"))
(defun c:55()($lxf:chang-color$ "55"))
(defun c:56()($lxf:chang-color$ "56"))
(defun c:57()($lxf:chang-color$ "57"))
(defun c:58()($lxf:chang-color$ "58"))
(defun c:59()($lxf:chang-color$ "59"))
(defun c:60()($lxf:chang-color$ "60"))
(defun c:61()($lxf:chang-color$ "61"))
(defun c:62()($lxf:chang-color$ "62"))
(defun c:63()($lxf:chang-color$ "63"))
(defun c:64()($lxf:chang-color$ "64"))
(defun c:65()($lxf:chang-color$ "65"))
(defun c:66()($lxf:chang-color$ "66"))
(defun c:67()($lxf:chang-color$ "67"))
(defun c:68()($lxf:chang-color$ "68"))
(defun c:69()($lxf:chang-color$ "69"))
(defun c:70()($lxf:chang-color$ "70"))
(defun c:71()($lxf:chang-color$ "71"))
(defun c:72()($lxf:chang-color$ "72"))
(defun c:73()($lxf:chang-color$ "73"))
(defun c:74()($lxf:chang-color$ "74"))
(defun c:75()($lxf:chang-color$ "75"))
(defun c:76()($lxf:chang-color$ "76"))
(defun c:77()($lxf:chang-color$ "77"))
(defun c:78()($lxf:chang-color$ "78"))
(defun c:79()($lxf:chang-color$ "79"))
(defun c:80()($lxf:chang-color$ "80"))
(defun c:81()($lxf:chang-color$ "81"))
(defun c:82()($lxf:chang-color$ "82"))
(defun c:83()($lxf:chang-color$ "83"))
(defun c:84()($lxf:chang-color$ "84"))
(defun c:85()($lxf:chang-color$ "85"))
(defun c:86()($lxf:chang-color$ "86"))
(defun c:87()($lxf:chang-color$ "87"))
(defun c:88()($lxf:chang-color$ "88"))
(defun c:89()($lxf:chang-color$ "89"))
(defun c:90()($lxf:chang-color$ "90"))
(defun c:91()($lxf:chang-color$ "91"))
(defun c:92()($lxf:chang-color$ "92"))
(defun c:93()($lxf:chang-color$ "93"))
(defun c:94()($lxf:chang-color$ "94"))
(defun c:95()($lxf:chang-color$ "95"))
(defun c:96()($lxf:chang-color$ "96"))
(defun c:97()($lxf:chang-color$ "97"))
(defun c:98()($lxf:chang-color$ "98"))
(defun c:99()($lxf:chang-color$ "99"))
(defun c:100()($lxf:chang-color$ "100"))
(defun c:101()($lxf:chang-color$ "101"))
(defun c:102()($lxf:chang-color$ "102"))
(defun c:103()($lxf:chang-color$ "103"))
(defun c:104()($lxf:chang-color$ "104"))
(defun c:105()($lxf:chang-color$ "105"))
(defun c:106()($lxf:chang-color$ "106"))
(defun c:107()($lxf:chang-color$ "107"))
(defun c:108()($lxf:chang-color$ "108"))
(defun c:109()($lxf:chang-color$ "109"))
(defun c:110()($lxf:chang-color$ "110"))
(defun c:111()($lxf:chang-color$ "111"))
(defun c:112()($lxf:chang-color$ "112"))
(defun c:113()($lxf:chang-color$ "113"))
(defun c:114()($lxf:chang-color$ "114"))
(defun c:115()($lxf:chang-color$ "115"))
(defun c:116()($lxf:chang-color$ "116"))
(defun c:117()($lxf:chang-color$ "117"))
(defun c:118()($lxf:chang-color$ "118"))
(defun c:119()($lxf:chang-color$ "119"))
(defun c:120()($lxf:chang-color$ "120"))
(defun c:121()($lxf:chang-color$ "121"))
(defun c:122()($lxf:chang-color$ "122"))
(defun c:123()($lxf:chang-color$ "123"))
(defun c:124()($lxf:chang-color$ "124"))
(defun c:125()($lxf:chang-color$ "125"))
(defun c:126()($lxf:chang-color$ "126"))
(defun c:127()($lxf:chang-color$ "127"))
(defun c:128()($lxf:chang-color$ "128"))
(defun c:129()($lxf:chang-color$ "129"))
(defun c:130()($lxf:chang-color$ "130"))
(defun c:131()($lxf:chang-color$ "131"))
(defun c:132()($lxf:chang-color$ "132"))
(defun c:133()($lxf:chang-color$ "133"))
(defun c:134()($lxf:chang-color$ "134"))
(defun c:135()($lxf:chang-color$ "135"))
(defun c:136()($lxf:chang-color$ "136"))
(defun c:137()($lxf:chang-color$ "137"))
(defun c:138()($lxf:chang-color$ "138"))
(defun c:139()($lxf:chang-color$ "139"))
(defun c:140()($lxf:chang-color$ "140"))
(defun c:141()($lxf:chang-color$ "141"))
(defun c:142()($lxf:chang-color$ "142"))
(defun c:143()($lxf:chang-color$ "143"))
(defun c:144()($lxf:chang-color$ "144"))
(defun c:145()($lxf:chang-color$ "145"))
(defun c:146()($lxf:chang-color$ "146"))
(defun c:147()($lxf:chang-color$ "147"))
(defun c:148()($lxf:chang-color$ "148"))
(defun c:149()($lxf:chang-color$ "149"))
(defun c:150()($lxf:chang-color$ "150"))
(defun c:151()($lxf:chang-color$ "151"))
(defun c:152()($lxf:chang-color$ "152"))
(defun c:153()($lxf:chang-color$ "153"))
(defun c:154()($lxf:chang-color$ "154"))
(defun c:155()($lxf:chang-color$ "155"))
(defun c:156()($lxf:chang-color$ "156"))
(defun c:157()($lxf:chang-color$ "157"))
(defun c:158()($lxf:chang-color$ "158"))
(defun c:159()($lxf:chang-color$ "159"))
(defun c:160()($lxf:chang-color$ "160"))
(defun c:161()($lxf:chang-color$ "161"))
(defun c:162()($lxf:chang-color$ "162"))
(defun c:163()($lxf:chang-color$ "163"))
(defun c:164()($lxf:chang-color$ "164"))
(defun c:165()($lxf:chang-color$ "165"))
(defun c:166()($lxf:chang-color$ "166"))
(defun c:167()($lxf:chang-color$ "167"))
(defun c:168()($lxf:chang-color$ "168"))
(defun c:169()($lxf:chang-color$ "169"))
(defun c:170()($lxf:chang-color$ "170"))
(defun c:171()($lxf:chang-color$ "171"))
(defun c:172()($lxf:chang-color$ "172"))
(defun c:173()($lxf:chang-color$ "173"))
(defun c:174()($lxf:chang-color$ "174"))
(defun c:175()($lxf:chang-color$ "175"))
(defun c:176()($lxf:chang-color$ "176"))
(defun c:177()($lxf:chang-color$ "177"))
(defun c:178()($lxf:chang-color$ "178"))
(defun c:179()($lxf:chang-color$ "179"))
(defun c:180()($lxf:chang-color$ "180"))
(defun c:181()($lxf:chang-color$ "181"))
(defun c:182()($lxf:chang-color$ "182"))
(defun c:183()($lxf:chang-color$ "183"))
(defun c:184()($lxf:chang-color$ "184"))
(defun c:185()($lxf:chang-color$ "185"))
(defun c:186()($lxf:chang-color$ "186"))
(defun c:187()($lxf:chang-color$ "187"))
(defun c:188()($lxf:chang-color$ "188"))
(defun c:189()($lxf:chang-color$ "189"))
(defun c:190()($lxf:chang-color$ "190"))
(defun c:191()($lxf:chang-color$ "191"))
(defun c:192()($lxf:chang-color$ "192"))
(defun c:193()($lxf:chang-color$ "193"))
(defun c:194()($lxf:chang-color$ "194"))
(defun c:195()($lxf:chang-color$ "195"))
(defun c:196()($lxf:chang-color$ "196"))
(defun c:197()($lxf:chang-color$ "197"))
(defun c:198()($lxf:chang-color$ "198"))
(defun c:199()($lxf:chang-color$ "199"))
(defun c:200()($lxf:chang-color$ "200"))
(defun c:201()($lxf:chang-color$ "201"))
(defun c:202()($lxf:chang-color$ "202"))
(defun c:203()($lxf:chang-color$ "203"))
(defun c:204()($lxf:chang-color$ "204"))
(defun c:205()($lxf:chang-color$ "205"))
(defun c:206()($lxf:chang-color$ "206"))
(defun c:207()($lxf:chang-color$ "207"))
(defun c:208()($lxf:chang-color$ "208"))
(defun c:209()($lxf:chang-color$ "209"))
(defun c:210()($lxf:chang-color$ "210"))
(defun c:211()($lxf:chang-color$ "211"))
(defun c:212()($lxf:chang-color$ "212"))
(defun c:213()($lxf:chang-color$ "213"))
(defun c:214()($lxf:chang-color$ "214"))
(defun c:215()($lxf:chang-color$ "215"))
(defun c:216()($lxf:chang-color$ "216"))
(defun c:217()($lxf:chang-color$ "217"))
(defun c:218()($lxf:chang-color$ "218"))
(defun c:219()($lxf:chang-color$ "219"))
(defun c:220()($lxf:chang-color$ "220"))
(defun c:221()($lxf:chang-color$ "221"))
(defun c:222()($lxf:chang-color$ "222"))
(defun c:223()($lxf:chang-color$ "223"))
(defun c:224()($lxf:chang-color$ "224"))
(defun c:225()($lxf:chang-color$ "225"))
(defun c:226()($lxf:chang-color$ "226"))
(defun c:227()($lxf:chang-color$ "227"))
(defun c:228()($lxf:chang-color$ "228"))
(defun c:229()($lxf:chang-color$ "229"))
(defun c:230()($lxf:chang-color$ "230"))
(defun c:231()($lxf:chang-color$ "231"))
(defun c:232()($lxf:chang-color$ "232"))
(defun c:233()($lxf:chang-color$ "233"))
(defun c:234()($lxf:chang-color$ "234"))
(defun c:235()($lxf:chang-color$ "235"))
(defun c:236()($lxf:chang-color$ "236"))
(defun c:237()($lxf:chang-color$ "237"))
(defun c:238()($lxf:chang-color$ "238"))
(defun c:239()($lxf:chang-color$ "239"))
(defun c:240()($lxf:chang-color$ "240"))
(defun c:241()($lxf:chang-color$ "241"))
(defun c:242()($lxf:chang-color$ "242"))
(defun c:243()($lxf:chang-color$ "243"))
(defun c:244()($lxf:chang-color$ "244"))
(defun c:245()($lxf:chang-color$ "245"))
(defun c:246()($lxf:chang-color$ "246"))
(defun c:247()($lxf:chang-color$ "247"))
(defun c:248()($lxf:chang-color$ "248"))
(defun c:249()($lxf:chang-color$ "249"))
(defun c:250()($lxf:chang-color$ "250"))
(defun c:251()($lxf:chang-color$ "251"))
(defun c:252()($lxf:chang-color$ "252"))
(defun c:253()($lxf:chang-color$ "253"))
(defun c:254()($lxf:chang-color$ "254"))
(defun c:255()($lxf:chang-color$ "255"))
(defun c:256()($lxf:chang-color$ "bylayer"))
(defun c:257()($lxf:chang-color$ "Byblock"))
(princ)
二、简易写法
(DEFUN $dfg:lxf_numcolor$ (/ I X)
(setq I 1)
(REPEAT 257
(cond ((= i 256)
(progn (setq X
(STRCAT "(defun c:"
(ITOA I)
"()(setvar \"cmdecho\" 0)(princ \" "
(STRCAT
" 颜色改为< "
"随层"
" >号色 \")(if (setq ss (ssget))"
"(vl-cmdf \"change\" ss \"\" \"properties\" \"c\" \""
"bylayer"
"\" \"\")))"
)
"(princ)"
)
)
(if X
(PROGN (EVAL (READ X)))
)
)
)
((= i 257)
(progn (setq X
(STRCAT "(defun c:"
(ITOA I)
"()(setvar \"cmdecho\" 0)(princ \" "
(STRCAT
" 颜色改为< "
"随层"
" >号色 \")(if (setq ss (ssget))"
"(vl-cmdf \"change\" ss \"\" \"properties\" \"c\" \""
"Byblock"
"\" \"\")))"
)
"(princ)"
)
)
(if X
(PROGN (EVAL (READ X)))
)
)
)
(t
(progn (setq X
(STRCAT
"(defun c:"
(ITOA I)
"()(setvar \"cmdecho\" 0)(princ \" "
(STRCAT " 颜色改为< "
(ITOA I)
" >号色 \")(if (setq ss (ssget))"
"(vl-cmdf \"change\" ss \"\" \"properties\" \"c\" \""
(ITOA I)
"\" \"\")))"
)
"(princ)"
)
)
(if X
(PROGN (EVAL (READ X)))
)
)
)
)
(setq I (1+ I))
)
)(defun c:jzys();加载颜色 更改颜色快捷命令为1~257
($dfg:lxf_numcolor$))
谢谢分享。
颜色是0~256,没有257 学习了,感谢楼主分享 437271963 发表于 2024-2-19 17:42
颜色是0~256,没有257
257,我加了一个随块。 ;一次定义N个命令1~255
(defun c:tt (/ i)
(setq i 1)
(repeat 255
(eval (read (strcat "(defun c:" (itoa i) "()($lxf:chang-color$ \"" (itoa i) "\"))")))
(setq i (1+ i))
)
(princ)
)
谢谢分享 方便好用 学习了,感谢楼主分享
页:
[1]