建筑电气CAD快捷lisp分享.docx
- 文档编号:28183300
- 上传时间:2023-07-09
- 格式:DOCX
- 页数:50
- 大小:27.28KB
建筑电气CAD快捷lisp分享.docx
《建筑电气CAD快捷lisp分享.docx》由会员分享,可在线阅读,更多相关《建筑电气CAD快捷lisp分享.docx(50页珍藏版)》请在冰豆网上搜索。
建筑电气CAD快捷lisp分享
;打开超大图纸,将此文件直接拖入cad即可。
ree底图处理-rrr改变颜色-r1数字加减乘除-rdd递增刷(框选)-rff修改块名-rgg复制文字
;;;______________________________________
;;;名称:
底图处理
;;;功能:
将建筑图变成电气图
;;;命令:
ree
;;;______________________________________
(DEFUNC:
ree()
(PROMPT"\n处理底图")
(SETVAR"CMDECHO"0)
(VL-LOAD-COM)
(COMMAND"LAYER""U""*""")
(command"undo""be")
(command"fillet""r""0")
(setqchklay(tblsearch"layer""电"))
(if(=chklaynil)(command"layer""n""电""c""3""电"""))
(COMMAND"LAYER""S""电""F""PUB_DIM,WINDOW_TEXT,*DOOR_FIRE_TEXT,*DOOR*FIRE*IDEN,*DOOR*IDEN,DIM*IDEN"
"C""251""DOTE,*HATCH,*HATC*PATT,*HATC*SOLD,DIM_ELEV"
"C""8""*EVTR,*STAIR,家具厨卫,石材造型,厨卫,SURFACE,LVTRY,LATRINE,RAIL,DIM_SYMB,*COLU*CONC"
"C""9""*WALL*,WINDOW,*DOOR,*DOOR_FIRE,COLUMN,0,PUB_TEXT""")
(PROMPT"\r处理完毕")
(command"undo""e")
(COMMAND"REGEN")
(SETVAR"CMDECHO"1)
(PRINC)
)
;;;______________________________________
;;;名称:
改变颜色
;;;功能:
;;;命令:
rrr
;;;______________________________________
(defunc:
rrr(/c)
(setqcmd(getvar"cmdecho"))
(setvar"cmdecho"0)
(setqDocument(vla-get-ActiveDocument(vlax-get-acad-object)))
(setqBlocks(vla-get-blocksDocument))
(vla-StartUndoMarkDocument)
(setqc(acad_colordlg8))
(If(progn
(princ"\n请选择要更改颜色的图元:
")
(setqssa(ssget))
)
(vlax-forObj(vla-get-ActiveSelectionSetDocument)
(vl-catch-all-apply'vla-put-color(listObjc))
(if(="AcDbBlockReference"(vla-get-objectnameObj))
(progn
(vlax-forBlkObj(vla-itemBlocks(vla-get-nameObj))
(vl-catch-all-apply'vla-put-color(listBlkObjc))
)
(if(=:
vlax-true(vla-get-hasattributesObj))
(foreachAttObj(vlax-safearray->list
(vlax-variant-value(vla-getattributesObj))
)
(vl-catch-all-apply'vla-put-color(listAttObjc))
)
)
)
)
)
)
(vla-EndUndoMarkDocument)
(vlax-release-objectBlocks)
(vlax-release-objectDocument)
(setvar"cmdecho"cmd)
(princ)
)
;;;______________________________________
;;;名称:
数字加减乘除
;;;功能:
将CAD数字进行加法计算,在命令行输出结果
;;;命令:
r1、r2、r3、r4
;;;______________________________________
;结果自动复制到剪贴板,支持天正文字、天正标高
(setqGL-precision3);3为计算结果保留位数自己根据需要修改
;不出现对话框,直接计算命令:
r1=加法r2=减法r3=乘法r4=除法
(defunc:
r1()(GL:
jiafa))
(defunc:
r2()(GL:
jianfa))
(defunc:
r3()(GL:
chengfa))
(defunc:
r4()(GL:
chufa))
(defunGL:
jiafa()(GL:
Galculate(GL:
GetNumber"+")))
(defunGL:
jianfa()(GL:
Galculate(GL:
GetNumber"-")))
(defunGL:
chengfa()(GL:
Galculate(GL:
GetNumber"*")))
(defunGL:
chufa()(GL:
Galculate(GL:
GetNumber"/")))
(vl-load-com)
(command"cal")(command);先调用cal,否则后面cal函数无法使用
(setqGL-result"");计算结果,全局变量
(setqGL-lst(list""))
(defunc:
tt5(/file)
(if(not(setqfile(openGL-text"r")))
(progn
(setqfile(openGL-text"w"))
(closefile)
)
(closefile)
)
(GL-xxjsq)
)
(defunGL-xxjsq(/fnamefnxdclidlinrefiletxtvaluereason)
(if(notGL-result)
(setqGL-result"")
)
(setqfname(vl-filename-mktempnilnil".dcl"))
(setqfn(openfname"w"))
(foreachx'(
"xxjsq:
dialog{"
"label=\"阿甘CAD计算器V1.1\";"
":
boxed_column{"
"label=\"自动计算\";"
":
row{"
":
button{key=\"1\";label=\"+\";width=4;}"
":
button{key=\"2\";label=\"-\";width=4;}"
":
button{key=\"3\";label=\"*\";width=4;}"
":
button{key=\"4\";label=\"/\";width=4;}"
"}"
"spacer_1;"
"}"
":
boxed_column{"
"label=\"手动计算\";"
":
row{"
":
edit_box{width=35;key=\"5\";allow_accept=true;}"
":
button{"
"is_default=true;"
"key=\"6\";"
"label=\"计算\";"
"width=4;"
"}"
"}"
"spacer_1;"
":
row{"
":
button{key=\"11\";label=\"C↑\";width=4;}"
":
button{key=\"12\";label=\"C↓\";width=4;}"
":
button{key=\"8\";label=\"拾取\";width=4;}"
":
button{key=\"10\";label=\"插算式\";width=4;}"
":
button{key=\"7\";label=\"插结果\";width=4;}"
"}"
"spacer_1;"
"}"
":
list_box{key=\"9\";label=\"历史记录\";width=40;height=10;}"
"cancel_button;"
"}"
)
(princxfn)
(write-line""fn)
)
(closefn)
(setqfn(openfname"r"))
(setqdclid(load_dialogfname))
(while(or(eq(substr(setqlin(vl-string-right-trim"\"fn)"(vl-string-left-trim"(write-line\""(read-linefn))))12)"//")(eq(substrlin1(vl-string-search""lin))"")(not(eq(substrlin(+(vl-string-search""lin)1)9)":
dialog"))))
(new_dialog(substrlin1(vl-string-search""lin))dclid)
(start_list"9")
(if(equalGL-lst(list""))
(progn
(setqfile(openGL-text"r")
txt(read-linefile)
)
(while(/=txtnil)
(setqGL-lst(appendGL-lst(listtxt)))
(setqtxt(read-linefile))
)
(closefile)
(setqGL-lst(cdrGL-lst))
(setqGL-lst(reverseGL-lst))
)
)
(mapcar'add_listGL-lst)
(end_list)
(set_tile"5"GL-result)
(mode_tile"5"2)
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object"WScript.Shell")'Sendkeys"{End}")
(action_tile"5""(setqGL-result$Value)")
(action_tile"1""(done_dialog1)")
(action_tile"2""(done_dialog2)")
(action_tile"3""(done_dialog3)")
(action_tile"4""(done_dialog4)")
(action_tile"6""(GL:
key6)")
(action_tile"7""(done_dialog7)")
(action_tile"8""(done_dialog8)")
(action_tile"9""(GL:
update-edit$value$reason)")
(action_tile"10""(done_dialog10)")
(action_tile"11""(GL:
key11)")
(action_tile"12""(GL:
key12)")
(action_tile"cancel""(done_dialog0)")
(setqre(start_dialog))
(cond
((=re1)(GL:
jiafa)(GL:
update)(GL-xxjsq))
((=re2)(GL:
jianfa)(GL:
update)(GL-xxjsq))
((=re3)(GL:
chengfa)(GL:
update)(GL-xxjsq))
((=re4)(GL:
chufa)(GL:
update)(GL-xxjsq))
((=re7)(GL:
crjswzGL-result))
((=re8)(GL:
key8))
((=re10)(GL:
crjswz(strcatGL-Num"="GL-result)))
)
(unload_dialogdclid)
(closefn)
(vl-file-deletefname)
(princ)
)
;拾取
(defunGL:
key8(/num)
(if(setqnum(GL:
GetNumber"+"))
(progn
(if(/=GL-result"")
(setqGL-result(strcatGL-result"+"num))
(setqGL-result(strcatGL-resultnum))
)
))
(GL-xxjsq)
)
;提取数字和运算符
(defunGL:
GetNumber(ope/ennumiregexsstexttn)
(setqregex(vlax-create-object"Vbscript.RegExp"));引用正则表达式控件
(vlax-put-propertyregex"IgnoreCase"0);不忽略大小写
(vlax-put-propertyregex"Global"1);全文匹配,而不是只匹配第一处
(setqss(ssget'((0."*TEXT,TCH_ELEVATION,DIMENSION"))));只拾取文字、天正标高
(ifss
(progn
(setqi0Num"")
(repeat(sslengthss)
(setqen(ssnamessi))
(setqGL-ed(entgeten))
(if(="DIMENSION"(cdr(assoc0GL-ed)))(setqtext(atof(rtos(cdr(assoc42GL-ed))23)))(setqtext(cdr(assoc1GL-ed))));补充标注文字提取
(vlax-put-propertyregex"Pattern""[^0-9\\+\\-\\*\\/\\.\\(\\)]");匹配数字和运算符
(setqtext(vlax-invoke-methodregex"Replace"text""))
(if(/=text"")
(progn
(if(=Num"");表达式加括号
(if(wcmatchtext"*`+*,*`-*,*`**,*`/*")
(setqNum(strcat"("text")")TNnil)
(setqNumtextTNnil)
)
(setqTNT)
)
(ifTN;表达式加括号
(if(wcmatchtext"*`+*,*`-*,*`**,*`/*")
(setqNum(strcatNumope"("text")"))
(setqNum(strcatNumopetext))
)
)
;(if(=Num"")(setqNumtextTNnil)(setqTNT));表达式不加括号
;(ifTN(setqNum(strcatNumopetext)));表达式不加括号
)
)
(setqi(1+i))
)
))
Num
)
;计算
(defunGL:
Galculate(Num)
(ifNum
(progn
(if(setqGL-result(cal(strcatNum"*""1.0")));*1.0将整数转换为小数,整数只能介于-32768和32767之间
(progn
(setqGL-result(rtosGL-result2GL-precision))
(set-clip-stringGL-result);向系统剪贴板写入文字
(setqGL-NumNum)
(princ(strcat"\n表达式:
"Num"="GL-result">>>>计算结果:
"GL-result))
(princ)
)
(alert(strcatNum"表达式语法错误!
"))
)))
)
;向系统剪贴板写入文字
(defunset-clip-string(STR/HTMLRESULT)
(and(=(typeSTR)'STR)
(setqHTML(vlax-create-object"htmlfile"))
(setqRESULT(vlax-invoke
(vlax-get(vlax-getHTML'PARENTWINDOW)
'CLIPBOARDDATA
)
'SETDATA
"Text"
STR
)
)
(vlax-release-objectHTML)
)
)
;;;______________________________________
;;;名称:
递增刷(框选)方向下上左右
;;;功能:
刷文本末尾或首部的数字递增指定值
;;;命令:
rddlangjs2012.2.27
;;;______________________________________
(defunc:
rdd(/abbbboxccocolcvdbakdcl_redclnameee1e2enentent1errsubfilenfunikeykkll1lenlstlst1lst2lst3
msgnamenewlistorerrpixptpt1pt2ssbaksissss1ssparmst2st3st4streamtempnametxt1txt2txt3txtlongvvs
wbakxyzz
)
(defunllt:
match(ptcolssparmfun/abccocvee1e2entilenlstmsgpixpt1pt2sissss1xy);带有刷子的ssget功能子程序
;,caoyin老大明经“拜新年“帖子提供,langjs修改
(defund_brush(colxylen/abc)
(grvecs(listcol(list(-x(setqa(*len1.5)))(-ylen))(list(-xa)(setqb(-y(*len7.5))))col(list(-x
(setqc
(*len0.5)
)
)y
)(list(-xc)b)
col(list(+xc)y)(list(+xc)b)col(list(+xa)(-ylen))(list(+xa)b)col(list(-x(setqa
(*len
4.5
)
)
)b
)(list(+xa)b)col
(list(-xa)b)(list(-x(setqc(*len6.5)))(-y(*len9)))col(list(+xa)b)(list(+xc)
(setqa(-y
(*len9)
)
)
)col(list(-xc)a)
(list(-xc)(setqb(-y(*len17))))col(list(+xc)a)(list(+xc)b)col(list(-xc)(setqa
(-y
(*len
10
)
)
)
)(list(+xc)a)col
(list(-xc)(setqa(-y(*len11))))(list(+xc)a)col(list(-xc)(setqa(-y(*len13))))
(list(+xc)a)col(list(-xc)(setqa(-y(*len14))))(list(+xc)a)col(list(-xc)b)
(list(+xc)b)col(list(-xc)b)(list(-x(*len11))(setqa(-y(*len21.5))))col(list(-x
(*len2)
)b
)(list(-x
(*len
6.5
)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 建筑 电气 CAD 快捷 lisp 分享
![提示](https://static.bdocx.com/images/bang_tan.gif)