输入字体时候自动切换到指定图层
从网上看到个源码,试用了下,功能是只要输入字体图层就自动改为指定的图层,填充和标注同理。请问各位可不可以帮忙改成输入字体时候只是输入的字体本身是指定的图层,但是当前图层不变的。填充和标注也是这种效果的。
(vl-load-com)
(if (not COMSTART)
(setq COMSTART
(vlr-editor-reactor
NIL
'((:vlr-commandwillstart . COMS)
;;(:vlr-commandended . COME)
)
)
)
)
(defun COMS (OBJREACTOR LSTCOMMAND)
(setq lst1 '("DIMLINEAR" "DIMANGULAR" "DIMARC"
"DIMDIAMETER" "DIMORDINATE" "DIMRADIUS"
"DIMJOGGED" "DIMALIGNED" "DIMCONTINUE"
"DIMBASELINE"
)
)
(setq lst2 '("HATCH" "BHATCH"))
(setq lst3 '("TEXT" "DTEXT" "MTEXT"))
(COND ((member (car LSTCOMMAND) lst2)
(IF (/= (GETVAR "CLAYER") "HATCH")
(setvar "clayer" "001-建筑-墙体填充") ;_打剖面线时自动切换到"001-建筑-墙体填充"层
)
)
((member (car LSTCOMMAND) lst1)
(IF (/= (GETVAR "CLAYER") "DIM")
(setvar "clayer" "001-建筑-标注") ;_标注尺寸时自动切换到"001-建筑-标注"层
)
)
((member (car LSTCOMMAND) lst3)
(IF (/= (GETVAR "CLAYER") "TXT")
(setvar "clayer" "002-平面-文字") ;_打文字时自动切换到"002-平面-文字"层
)
)
)
(princ)
)
对反应器不熟,大概改了下还能用
(vl-load-com)
(if (not COMSTART)
(setq COMSTART
(vlr-editor-reactor
NIL
(list '(:vlr-commandwillstart . COMS) '(:vlr-commandended . COME))
)
)
)
(defun COMS (OBJREACTOR LSTCOMMAND / lst1 lst2 lst3)
(setq lst1 '("DIMLINEAR" "DIMANGULAR" "DIMARC"
"DIMDIAMETER" "DIMORDINATE" "DIMRADIUS"
"DIMJOGGED" "DIMALIGNED" "DIMCONTINUE"
"DIMBASELINE"
)
)
(setq lst2 '("HATCH" "BHATCH"))
(setq lst3 '("TEXT" "DTEXT" "MTEXT"))
(COND ((member (car LSTCOMMAND) lst2)
(setq clayer (GETVAR "CLAYER"))
(IF (/= (GETVAR "CLAYER") "HATCH")
(setvar "clayer" "001-建筑-墙体填充") ;_打剖面线时自动切换到"001-建筑-墙体填充"层
)
)
((member (car LSTCOMMAND) lst1)
(setq clayer (GETVAR "CLAYER"))
(IF (/= (GETVAR "CLAYER") "DIM")
(setvar "clayer" "001-建筑-标注") ;_标注尺寸时自动切换到"001-建筑-标注"层
)
)
((member (car LSTCOMMAND) lst3)
(setq clayer (GETVAR "CLAYER"))
(IF (/= (GETVAR "CLAYER") "TXT")
(setvar "clayer" "002-平面-文字") ;_打文字时自动切换到"002-平面-文字"层
)
)
)
(princ)
)
(defun COME (OBJREACTOR LSTCOMMAND / lst1 lst2 lst3)
(setq lst1 '("DIMLINEAR" "DIMANGULAR" "DIMARC"
"DIMDIAMETER" "DIMORDINATE" "DIMRADIUS"
"DIMJOGGED" "DIMALIGNED" "DIMCONTINUE"
"DIMBASELINE"
)
)
(setq lst2 '("HATCH" "BHATCH"))
(setq lst3 '("TEXT" "DTEXT" "MTEXT"))
(if (or (member (car LSTCOMMAND) lst1) (member (car LSTCOMMAND) lst2) (member (car LSTCOMMAND) lst3)) (setvar "clayer" clayer))
(princ)
) (vl-load-com)
(setq olayer (GETVAR "CLAYER"))
(if (not COMSTART)
(setq COMSTART
(vlr-editor-reactor
NIL
'((:vlr-commandwillstart . COMS)
;;(:vlr-commandended . COME)
)
)
)
)
(defun COMS (OBJREACTOR LSTCOMMAND)
(setq lst1 '("DIMLINEAR" "DIMANGULAR" "DIMARC"
"DIMDIAMETER""DIMORDINATE" "DIMRADIUS"
"DIMJOGGED" "DIMALIGNED" "DIMCONTINUE"
"DIMBASELINE"
)
)
(setq lst2 '("HATCH" "BHATCH"))
(setq lst3 '("TEXT" "DTEXT" "MTEXT"))
(COND ((member (car LSTCOMMAND) lst2)
(IF (/= olayer "HATCH")
(setvar "clayer" "001-建筑-墙体填充") ;_打剖面线时自动切换到"001-建筑-墙体填充"层
)
)
((member (car LSTCOMMAND) lst1)
(IF (/= olayer "DIM")
(setvar "clayer" "001-建筑-标注") ;_标注尺寸时自动切换到"001-建筑-标注"层
)
)
((member (car LSTCOMMAND) lst3)
(IF (/= olayer "TXT")
(setvar "clayer" "002-平面-文字") ;_打文字时自动切换到"002-平面-文字"层
)
)
(t (setvar "clayer" olayer))
)
(princ)
)
(setvar "clayer" olayer)输入完文字后需要手动re一下才能恢复原图层
845245015 发表于 2020-9-10 08:10
输入完文字后需要手动re一下才能恢复原图层
刚刚试验了下,我当前层是“0”,加载程序后,我输入文字(填充/标注),文字(填充/标注)确实改成了指定层,re或者输入其它命令,自动变为“0”层。(到这一步没问题)
但是有个问题是:我后来手动切换到其它层后,re或者输入其它命令,它还是会自动换回“0”层。 start4444 发表于 2020-9-10 14:11
对反应器不熟,大概改了下还能用
(vl-load-com)
非常感谢!正是我想要的效果。 AutoCAD 现在已经默认提供了你所需的功能。
Hatch,Dimension, Text/Mtext都可以设置创建的默认图层。 e2002 发表于 2020-9-10 17:56
AutoCAD 现在已经默认提供了你所需的功能。
Hatch,Dimension, Text/Mtext都可以设置创建的默认图层。
什么版本cad才有这功能? luohonghe 发表于 2020-9-11 14:44
什么版本cad才有这功能?
大佬,这个要怎么设置,怎么使用? e2002 发表于 2020-9-10 17:56
AutoCAD 现在已经默认提供了你所需的功能。
Hatch,Dimension, Text/Mtext都可以设置创建的默认图层。
大佬,这个要怎么设置,怎么使用? 出个教程,可以吗?
页:
[1]
2