|
本帖最后由 snowing1221 于 2017-10-19 16:03 编辑
复制粘贴到一个记事本中,保存,然后改后缀名.LSP
打开cad,输入ap,右下角点击“内容”
点击添加,把刚才存好的文件加进去,就好了
那个存好的文件所在目录,在cad的选项中添加到支持文件搜索路径里
这样每次打开cad,都可以用这些快捷键
(defun c:A()
(princ "弧变圆")
(setq ss(ssget(list (cons 0 "ARC")) ))
(setq long(sslength ss)
count 0)
(while(< count long)
(setq en(ssname ss count))
(setq eed(entget en))
(setq ED(assoc 40 eed) )
(setq pp3(assoc 8 eed) )
(setq p3 (cdr pp3) )
(setq R (cdr ED) )
(setq PO(assoc 10 eed) )
(setq PP (cdr PO) )
(COMMAND "CLAYER" p3)
(COMMAND "CIRCLE" PP R "")
(SETQ count ( + 1 count) ))
(command "erase" ss ""))
(defun c:da(/ n pt da st )
(setq pt(getpoint"pick a point please:"))
(setq ti(menucmd"m=$(edtime,$(getvar,date),yyyy.mo.dd)"))
(setq st(strcat ti))
(princ(strcat"\n the current date is:" st))
(COMMAND "LAYER" "M" "TXT""""")
(command "clayer" "TEXT")
(setq d( getvar "USERR1"))
(command "USERR1" (GETVAR "DIMSCALE"))
(princ "\签名\n")
(princ d)
(setq d( getvar "USERR1"))
(setq d1(* (* 3 d)0.6 ))
(SETQ GGI (STRCAT "ZCZ" " " ST ))
(command"text""j""m" pt D1 0 GGI))
(defun c:`()
(command "aidimprec" "0" ))
(defun c:s1()
(command "aidimprec" "1" ))
(defun c:s2()
(command "aidimprec" "2" ))
(defun c:s3()
(command "aidimprec" "3" ))
(defun c:s4()
(command "aidimprec" "4" ))
(defun c:sr()
(command "aidimprec" "6" ))
(defun c:S()
(SETVAR "OSMODE" 183)
(COMMAND "LAYER" "on" "0" "" )
(command "clayer" "0")
(command "line"))
(defun c:bb()
(setq dd (getstring "\nplease give blockname:"))
(setq pp (getpoint "\nplease give point"))
(command "insert" dd pp""""""))
(defun c:GC()
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "_tolerance"))
(defun c:ff()
(command "fillet""t""T""R"0)
(COMMAND "FILLET"))
(defun c:f()
(command "clayer" "0")
(SETQ R (GETREAL " \n R"))
(command "fillet""t""T""R"R)
(COMMAND "FILLET"))
(defun c:CS()
(SETQ QQ (SSGET))
(SETQ P (GETPOINT "POINT"))
(command "COPY" QQ """M" P ))
(defun c:CF()
(command "clayer" "0")
(SETQ R (GETREAL "\n d"))
(command "chamfer""t""T""D"R R)
(COMMAND "chamfer"))
(defun c:CA()
(command "chamfer""t""T""A"))
(defun c:UU()
(setvar "osmode" 37)
(command "UCS""N"))
(defun c:R()
(SETVAR "ORTHOMODE" 1)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 0)
(command "clayer" "DIM")
(command "_dimordinate"))
(defun c:R1()
(SETVAR "ORTHOMODE" 1)
(SETVAR "dimdec" 1)
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "_dimordinate")
)
(defun c:R2()
(SETVAR "ORTHOMODE" 1)
(SETVAR "dimdec" 2)
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "_dimordinate"))
(defun c:R3()
(SETVAR "ORTHOMODE" 1)
(SETVAR "dimdec" 3)
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "_dimordinate"))
(defun c:R4()
(SETVAR "ORTHOMODE" 1)
(SETVAR "dimdec" 4)
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "_dimordinate"))
(defun c:SD()
(COMMAND "LAYER" "u" "*" "" )
(command "QSAVE"))
(defun c:D()
(SETVAR "OSMODE" 183)
(command "_dist"))
(defun c:DF()
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "DIMLINEAR"))
(defun c:DG()
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(command "DIMALIGNED"))
(defun c:DR()
(command "clayer" "DIM")
(command "DIMRADIUS"))
(defun c:DQ()
(command "clayer" "DIM")
(command "DIMDIAMETER"))
(defun c:DW()
(command "clayer" "DIM")
(command "DIMARC"))
(defun c:DX()
(command "clayer" "DIM")
(command "DIMANGULAR"))
(defun c:QQ()
(command "MATCHPROP"))
(defun c:SF()
(command "LIST"))
(defun c:SW()
(command "_SPLINE"))
(defun c:CC()
(command "MIRROR"))
(defun c:EE()
(command "OFFSET"))
(defun c:FE()
(command "QLEADER"))
(defun c:W()
(command "MOVE"))
(defun c:C()
(SETVAR "OSMODE" 183)
(command "clayer" "0")
(command "CIRCLE"))
(defun c:mm()
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 0)
(command "clayer" "dim")
(setq p1(getpoint))
(setq p2(getpoint p1))
(command "dimlinear" p1 p2 "t" "M<>"))
(defun c:st()
(SETVAR "OSMODE" 183)
(command "stretch"))
(defun c:HH()
(command "DIM1" "N" "%%C<>"))
(defun c:NT()
(command "DIM1" "N" "<>TYP"))
(defun c:NB()
(setq QQ1 (getstring " back\n "))
(setq BB(strcase QQ1))
(command "DIM1" "N" (strcat "<>" bb)))
(defun c:N()
(command "DIM1" "N"))
(defun c:NN()
(setq BB1 (getstring " 1,2,3....&\n "))
(SETQ BB(strcat "(" BB1 "X" ")"))
(command "DIM1" "N" (strcat "<>" BB)))
(defun c:DE()
(princ "\n上下公差")
(SETQ A1(GETSTRING "\n Upper tolerance:"))
(SETQ A2(GETSTRING "\n Lower tolerance:"))
(if (= A1 "")(progn
(SETQ A3(strcat A2 "^" "\ "))
(command "DIM1" "N" (strcat"<>\\H0.6x;\\S" A3))))
(if (= A2 "")(progn
(SETQ A3(strcat A1 "^" "\ "))
(command "DIM1" "N" (strcat"<>\\H0.6x;\\S" A3))))
(if(AND (/= A1 "")(/= A2 ""))(progn
(SETQ A3(strcat A1 "^" A2))
(command "DIM1" "N" (strcat"<>\\H0.6x;\\S" A3))))
)
(defun c:DDE()
(princ "\n对称公差")
(SETQ A4(GETSTRING "\n symmetry tolerance:"))
(SETQ A3(strcat A4 "^" " "))
(command "DIM1" "N" (strcat "<>\\H0.6x;\\S" "%%p" A3)))
(defun c:REF()
(command "DIM1" "N" "<>(REF)"))
(defun c:GG()
(COMMAND "LAYER" "M" "TEMP" "" )
(COMMAND "LAYER" "C" 15 "TEMP" "")
(command "clayer" "TEMP")
(COMMAND "LAYER" "ON" "TEMP" "" )
(SETVAR "OSMODE" 183)
(command "xline" "h" ))
(defun c:VV()
(COMMAND "LAYER" "M" "TEMP" "" )
(COMMAND "LAYER" "C" 15 "TEMP" "")
(command "clayer" "TEMP")
(COMMAND "LAYER" "ON" "TEMP" "" )
(SETVAR "OSMODE" 183)
(command "xline" "v" ))
(defun C:NG (/ PT1 PT2 PT3 PT4)
(graphscr)
(COMMAND "CLAYER" "DIM")
(setq PT1 (getpoint "1ST corner "))(terpri)
(setq PT3 (getcorner "2nd corner "PT1))(terpri)
(setq PT2 (list (car PT1)(cadr PT3)))
(setq PT4 (list (car PT3)(cadr PT1)))
(command "pline" PT1 PT2 PT3 PT4 "C")
(command "pline" PT1 PT3 "")
(command "pline" PT2 PT4 "")
)
(defun c:RR();dimradius
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 1)
(command "clayer" "dim")
(command "dimradius"))
(defun c:DD();dimdiameter
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 2)
(command "clayer" "dim")
(command "dimdiameter"))
(defun C:DC (/ ss1 count emax e #ent bb et1 ed)
(SETVAR "CMDECHO" 0)
(PROMPT "\n FORMER CIRCLE ")
(IF (SETQ SS1 (SSGET (LIST (CONS 0 "CIRCLE"))))
(PROGN
(setq count 0)
(setq emax (SSLENGTH Ss1))
(SETQ E (getdist "\n CIRCLE Radii"))
(IF (NULL E)
(PROGN
(SETQ #ENT (CAR (ENTSEL "\n CIRCLE:..")))
(SETQ E (ENTGET #ENT))
(SETQ BB (ASSOC 40 E))
(SETQ ET1 (CDR (ASSOC 0 E)))
)
(PROGN
(SETQ E (/ E 2.0))
(SETQ BB (CONS 40 E))
)
)
(WHILE (< COUNT EMAX)
(setq EN (ssname ss1 COUNT)
ED (ENTGET EN)
)
(SETQ ED (SUBST BB (assoc 40 ed) ED))
(ENTMOD ed)
(SETQ COUNT (1+ COUNT))
)
)
(PROMPT "\n No Section:...")
)
(princ)
)
(defun c:WR()
(setq ssd (ssget))
(setq sl (sslength ssd))
(setq count 0)
(while (< count sl)
(setq en (ssname ssd count))
(setq ed (entget en))
(SETQ SS (CDR (ASSOC 0 ED)))
(if (OR (= SS "ARC") (= SS "LINE"))
(progn
(command "pedit" en "" "j" ssd "" "")))
(setq count (1+ count))
)
)
(defun C:CB ()
(SETVAR "CMDECHO" 0)
(princ "CHOOSE.../n")
(SETQ SS1 (SSGET))
(setq count 0)
(setq emax (SSLENGTH Ss1))
(PROMPT "\n BOLCK NAME")
(SETQ E (GETSTRING))
(SETQ BB (CONS 2 E))
(IF
(= "" E)
(PROGN
(SETQ E (CAR (ENTSEL "\nBLOCK..:")))
(SETQ E(ENTGET E))
(SETQ BB(ASSOC 2 E))
(SETQ ET1 (CDR(ASSOC 0 E)))
)
)
(WHILE (< COUNT EMAX)
(setq EN (ssname ss1 COUNT)
ED (ENTGET EN)
ET (CDR(ASSOC 0 ED))
SBB1 (ASSOC 2 ED)
)
(IF
(= ET "INSERT")
(PROGN
(SETQ ED (SUBST BB SBB1 ED))
(ENTMOD ed)
(SETQ COUNT (1+ COUNT))
)
(SETQ COUNT (1+ COUNT))
)
)
(PROMPT "\nCHANGE IS Over!")
(SETQ
ss1 nil
emax nil
count nil
e nil
bb nil
et1 nil
EN NIL
ED NIL
ET NIL
sbb1 nil
)
)
(DEFUN C:ddc(/ n a b p1 p2 p3 p4 p5 di dis zi oo oldo)
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(GRAPHSCR)
(COMMAND "SETVAR" "CLAYER" "DIM")
(setq oldo (getvar "osmode"))
(SETQ OO (GETVAR "ORTHOMODE"))
(SETQ A (ENTSEL))
(IF A
(PROGN
(SETQ B (ENTGET (CAR A)))
(SETQ P1 (cdr (ASSOC 10 B)))
(SETQ P2 (cdr (ASSOC 11 B)))
(setq x3 (/ (+ (car p2) (car p1)) 2))
(setq y3 (/ (+ (cadr p2) (cadr p1)) 2))
(setq p3 (list x3 y3))
(SETQ P3 (TRANS P3 0 1))
(SETVAR "ORTHOMODE" 0)
(SETQ P4 (getpoint P3 "\n please pick a point :"))
(SETQ DI (distance P1 P2))
(setq di (/ di (expt 2 0.5)))
(setq st (getstring "\n PLEASE ENTER THE NUM OF chamfer(1):"))
(setq zzi (getint "\n PLEASE ENTER THE precision(1):"))
(if (null zzi )
(setq zzi 1))
(SETQ DIS (RTOS DI 2 zzi))
(if (/= st "")
(progn
(SETQ ZI (STRCAT "C" DIS "(" ST "X" ")")))
(SETQ ZI (STRCAT "C" DIS)))
(setvar "osmode" 183)
(COMMAND "QLEADER" P3 P4 """"ZI"")
)
(PROMPT "\n Nothing select!please try!")
)
(SETVAR "ORTHOMODE" OO)
(setvar "osmode" oldo)
(princ)
(setq x3 nil
y3 nil
)
)
(DEFUN C:ba()
(command "clayer" "TEXT")
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(setq DD1 (* BLLY 0.8))
(setq d1 (* 3 DD1) )
(GRAPHSCR)
(setq old (getvar "orthomode"))
(setq oldO (getvar "OSMODE"))
(setvar "orthomode" 0)
(setvar "osmode" 183)
(SETQ GGII (STRCAT "enter revision no(" "A" ")"))
(SETQ aa (GETSTRING GGII))
(if (= "" aa) (setq aa "A"))
(setq A (strcase aa))
(setq d "t")
(while d
(SETQ P (GETPOINT "\n please pick A Point:"))
(command "ucs" "n" p )
(COMMAND "CLAYER" "TEXT")
(command "text" "j" "m" '(0 0) d1 0 A "" )
(setq xyA (list 0 (* 3 DD1)))
(setq xyB (list (* -3 DD1) (* -2 DD1)))
(SETQ XYC (LIST (* 3 DD1) (* -2 DD1)))
(COMMAND "PLINE" XYA XYB XYC XYA "")
(IF p (= p NIL)
(SETQ D NIL))
)
(setvar "orthomode" old)
(setvar "osmode" 183))
(DEFUN C:BS();插入基准
(SETVAR "INSUNITS" 4)
(SETVAR "ORTHOMODE" 1)
(SETVAR "OSMODE" 183)
(command "clayer" "DIM")
(BILLY)
(SETQ PT1(GETPOINT "PLEASE CHOOSE 1 POINT"))
(SETQ PT2(GETPOINT PT1 "PLEASE CHOOSE 2 POINT"))
(SETQ PT1X(CAR PT1))
(SETQ PT1Y (CADR PT1))
(SETQ PT2X(CAR PT2))
(SETQ PT2Y (CADR PT2))
(IF (= PT1Y PT2Y)
(PROGN
(SETQ PT3 (LIST (+ (* 3 BLLY) PT2X) PT1Y))
(SETQ PT4 (LIST (- PT2X (* 3 BLLY)) PT1Y))
))
(IF (= PT1X PT2X)
(PROGN
(SETQ PT3 (LIST PT1X (+ (* 3 BLLY) PT2Y) ))
(SETQ PT4 (LIST PT1X (- PT2Y (* 3 BLLY)) ))))
(SETVAR "OSMODE" 183)
(COMMAND "PLINE" PT1 PT4 "")
(COMMAND "PLINE" PT3 PT4 "")
(SETQ SS1 (entlast))
(COMMAND "CHANGE" ss1 "" "P" "C" 2 "")
(SETQ PT4(GETPOINT PT2 "PLEASE CHOOSE 3 POINT"))
(SETQ PT4X(CAR PT4))
(SETQ PT4Y (CADR PT4))
(SETQ YY1(DISTANCE PT2 PT4))
(SETQ W (/ (* 3 BLLY) YY1))
(SETQ PPX (+ (* W PT2X) (* (- 1 W) PT4X) ))
(SETQ PPY(+ (* W PT2Y) (* (- 1 W) PT4Y) ))
(COMMAND "PLINE" PT2 (LIST PPX PPY) "" )
(SETQ SS2 (entlast))
(COMMAND "CHANGE" ss2 "" "P" "C" 2 "")
(COMMAND "INSERT" "D:\\soft\\CAD\\BS.DWG" PT4 BLLY BLLY ""))
(DEFUN C:CR ()
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(setq DD1 BLLY)
(setq d1 (* 3 DD1))
(GRAPHSCR)
(setq old (getvar "orthomode"))
(setq oldO (getvar "OSMODE"))
(setvar "orthomode" 0)
(setq d "t")
(while d
(setvar "osmode" 512)
(SETQ P (GETPOINT "\n please pick A Point:"))
(COMMAND "CLAYER" "DIM")
(setvar "osmode" 0)
(command "text" "j" "m" P d1 "" "\\U+2104" "" )
(IF p (= p NIL)
(SETQ D NIL))
)
(setvar "orthomode" old)
(setvar "osmode" oldo))
(DEFUN C:ZZ()
(COMMAND "UCS" "E"))
(DEFUN C:SA()
(COMMAND "LTSCALE"))
(defun c:cnn()
(PRINC "全部弧中心线")
(SETQ SS (SSGET '((0 . "ARC")) ))
(COMMAND "UCS" "W")
(SETVAR "OSMODE" 183)
(setq long(sslength ss)
count 0)
(while(< count long)
(setq en(ssname ss count))
(setq eed(entget en))
(setq ED(assoc 40 eed) )
(setq r (cdr ED) )
(setq EE(assoc 10 eed))
(setq cc(CDR EE))
(setq ccx (car cc))
(setq ccy (cadr cc))
(command "line" (list (- ccx ( * 1.1 r)) ccy) (list (+ ccx ( * 1.1 r)) ccy) "" )
(setq ss1 (entlast))
(COMMAND "CHANGE" ss1 "" "P" "C" 1 "")
(COMMAND "CHANGE" ss1 "" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss1 "" "P" "LA" 0 "")
(COMMAND "CHANGE" ss1 "" "P" "S"0.5 "")
(command "line" (list ccx (- ccy ( * 1.1 r)) ) (list ccx (+ ccy ( * 1.1 r))) "")
(setq ss4 (entlast))
(COMMAND "CHANGE" ss4"" "P" "C" 1 "")
(COMMAND "CHANGE" ss4"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss4"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss4 "" "P" "S" 0.5 "")
(SETQ count ( + 1 count) ))
(SETVAR "OSMODE" 183))
(defun c:cen()
(PRINC "全部圆中心线")
(SETQ SS (SSGET '((0 . "circle")) ))
(COMMAND "UCS" "W")
(SETVAR "OSMODE" 183)
(setq long(sslength ss)
count 0)
(while(< count long)
(setq en(ssname ss count))
(setq eed(entget en))
(setq ED(assoc 40 eed) )
(setq r (cdr ED) )
(setq EE(assoc 10 eed))
(setq cc(CDR EE))
(setq ccx (car cc))
(setq ccy (cadr cc))
(command "line" (list (- ccx (+ r 0.5)) ccy) (list (+ ccx ( + r 0.5)) ccy) "" )
(setq ss1 (entlast))
(COMMAND "CHANGE" ss1 "" "P" "C" 1 "")
(COMMAND "CHANGE" ss1 "" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss1 "" "P" "LA" 0 "")
(COMMAND "CHANGE" ss1 "" "P" "S"0.5 "")
(command "line" (list ccx (- ccy ( + r 0.5)) ) (list ccx (+ ccy ( + r 0.5))) "")
(setq ss4 (entlast))
(COMMAND "CHANGE" ss4"" "P" "C" 1 "")
(COMMAND "CHANGE" ss4"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss4"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss4 "" "P" "S" 0.5 "")
(SETQ count ( + 1 count) ))
(SETVAR "OSMODE" 183))
(defun c:JJ()
(SETVAR "OSMODE" 183)
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(PRINC "\n 寻找局部试图坐标系原点")
(setq ss(ssget(list (cons 0 "DIMENSION")) ))
(COMMAND "UCS" "W")
(setq long(sslength ss)
count 0)
(while(< count long)
(setq en(ssname ss count))
(setq eed(entget en))
(setq ED(assoc 10 eed) )
(SETQ PO(CDR ED))
(COMMAND "UCS" "N" PO)
(SETQ count ( + 1 count) ))
(setq zzi (getint "\n PLEASE ENTER THE precision(1):"))
(if (null zzi )
(setq zzi 1))
(SETVAR "dimdec" ZZI)
(WHILE
(SETVAR "OSMODE" 183)
(SETVAR "ORTHOMODE" 1)
(SETQ PP1(GETPOINT))
(SETQ PP2 (GETPOINT PP1 ))
(command "clayer" "dim")
(COMMAND "_dimordinate" PP1 PP2 "")
)
)
(defun c:CE()
(PRINC "单圆中心线")
(vl-load-com)
(command "ucs" "w")
(SETVAR "OSMODE" 183)
(setq rc (ssget))
(setq long (sslength rc)
count 0
SCIA NIL
SCIB NIL
SCIC NIL
SCID NIL)
(while (< count long)
(setq en(ssname rc count))
(setq mycl (vlax-ename->vla-object en))
(setq ss (vla-getboundingbox mycl'minpoint'maxpoint))
(setq A(vlax-safeArray-get-element minpoint 0)
B(vlax-safearray-get-element minpoint 1)
C(vlax-safearray-get-element maxpoint 0)
D(vlax-safearray-get-element maxpoint 1))
(setq SCIA (CONS A SCIA)
SCIB(CONS B SCIB)
SCIC(CONS C SCIC)
SCID(CONS D SCID))
(SETQ count ( + 1 count)
))
(SETQ SCIA(VL-SORT SCIA (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIB(VL-SORT SCIB (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIC(VL-SORT SCIC (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(SETQ SCID(VL-SORT SCID (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(setq aa(nth 0 SCIA))
(SETQ bb(nth 0 SCIB))
(setq cc(nth 0 SCIC))
(setq dd(nth 0 SCID))
(setq r1 (- dd bb))
(setq r2 (- cc aa))
(SETQ cenx (/ (+ aa cc) 2.0))
(SETQ ceny (/ (+ bb dd) 2.0))
(command "line" (list cenx (+ dd 0.5))
(list cenx (- bb 0.5)) "" )
(setq ss1 (entlast))
(COMMAND "CHANGE" ss1"" "P" "C" 1 "")
(COMMAND "CHANGE" ss1"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss1"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss1 "" "P" "S" 0.5 "")
(command "line" (list (- aa 0.5) ceny)
(list (+ cc 0.5) ceny) "")
(setq ss2 (entlast))
(COMMAND "CHANGE" ss2"" "P" "C" 1 "")
(COMMAND "CHANGE" ss2"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss2"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss2 "" "P" "S" 0.5 "")
(SETVAR "OSMODE" 183))
(defun c:aa();dimlinear 精 1
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 1)
(command "clayer" "dim")
(command "dimlinear"))
(defun c:as();dimlinear 精 2
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 2)
(command "clayer" "dim")
(command "dimlinear"))
(defun c:ad();dimlinear 精3
(BILLY)
(SETVAR "DIMSCALE" BLLY)
(SETQ DD (GETVAR "DIMLFAC"))
(setq ddq ( / 1 DD ))
(PRINC "\n form 倍数=" )
(PRINC ddq)
(setq dq (getreal "\n 如果不同于该放大倍数请重新设定;"))
(if (null dq )
(setq dq ddq))
(setq ddd ( / 1 dq ))
(setvar "DIMLFAC" ddd)
(SETVAR "OSMODE" 183)
(SETVAR "dimdec" 3)
(command "clayer" "dim")
(command "dimlinear"))
(defun c:CG()
(PRINC "水平(-)中心线")
(vl-load-com)
(command "ucs" "w")
(SETVAR "OSMODE" 183)
(setq rc (ssget))
(setq long (sslength rc)
count 0
SCIA NIL
SCIB NIL
SCIC NIL
SCID NIL)
(while (< count long)
(setq en(ssname rc count))
(setq mycl (vlax-ename->vla-object en))
(setq ss (vla-getboundingbox mycl'minpoint'maxpoint))
(setq A(vlax-safeArray-get-element minpoint 0)
B(vlax-safearray-get-element minpoint 1)
C(vlax-safearray-get-element maxpoint 0)
D(vlax-safearray-get-element maxpoint 1))
(setq SCIA (CONS A SCIA)
SCIB(CONS B SCIB)
SCIC(CONS C SCIC)
SCID(CONS D SCID))
(SETQ count ( + 1 count)
))
(SETQ SCIA(VL-SORT SCIA (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIB(VL-SORT SCIB (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIC(VL-SORT SCIC (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(SETQ SCID(VL-SORT SCID (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(setq aa(nth 0 SCIA))
(SETQ bb(nth 0 SCIB))
(setq cc(nth 0 SCIC))
(setq dd(nth 0 SCID))
(setq r1 (- dd bb))
(SETQ ceny (/ (+ bb dd) 2.0))
(command "line" (list (- aa 0.5) ceny)
(list (+ cc 0.5) ceny) "")
(setq ss2 (entlast))
(COMMAND "CHANGE" ss2"" "P" "C" 1 "")
(COMMAND "CHANGE" ss2"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss2"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss2 "" "P" "S" 0.5 "")
(SETVAR "OSMODE" 183))
(defun c:CV()
(PRINC "垂直(|)中心线")
(vl-load-com)
(command "ucs" "w")
(SETVAR "OSMODE" 183)
(setq rc (ssget))
(setq long (sslength rc)
count 0
SCIA NIL
SCIB NIL
SCIC NIL
SCID NIL)
(while (< count long)
(setq en(ssname rc count))
(setq mycl (vlax-ename->vla-object en))
(setq ss (vla-getboundingbox mycl'minpoint'maxpoint))
(setq A(vlax-safeArray-get-element minpoint 0)
B(vlax-safearray-get-element minpoint 1)
C(vlax-safearray-get-element maxpoint 0)
D(vlax-safearray-get-element maxpoint 1))
(setq SCIA (CONS A SCIA)
SCIB(CONS B SCIB)
SCIC(CONS C SCIC)
SCID(CONS D SCID))
(SETQ count ( + 1 count)
))
(SETQ SCIA(VL-SORT SCIA (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIB(VL-SORT SCIB (FUNCTION (LAMBDA (e1 e2 )(< e1 e2)))))
(SETQ SCIC(VL-SORT SCIC (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(SETQ SCID(VL-SORT SCID (FUNCTION (LAMBDA (e1 e2 )(> e1 e2)))))
(setq aa(nth 0 SCIA))
(SETQ bb(nth 0 SCIB))
(setq cc(nth 0 SCIC))
(setq dd(nth 0 SCID))
(setq r2 (- cc aa))
(SETQ cenx (/ (+ aa cc) 2.0))
(command "line" (list cenx (+ dd 0.5))
(list cenx (- bb 0.5)) "" )
(setq ss1 (entlast))
(COMMAND "CHANGE" ss1"" "P" "C" 1 "")
(COMMAND "CHANGE" ss1"" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss1"" "P" "LA" 0 "")
(COMMAND "CHANGE" ss1 "" "P" "S" 0.5 "")
(SETVAR "OSMODE" 183) )
(defun c:1()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 1 "")
(COMMAND "CHANGE" ss "" "P" "LT" "CENTER" "")
(COMMAND "CHANGE" ss "" "P" "LA" "0" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun c:2()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 2 "")
(COMMAND "CHANGE" ss "" "P" "LT" "BYLAYER" "")
(COMMAND "CHANGE" ss "" "P" "LA" "DIM" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun c:3()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 3 "")
(COMMAND "CHANGE" ss "" "P" "LT" "DASHED" "")
(COMMAND "CHANGE" ss "" "P" "LA" "0" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun c:4()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 4 "")
(COMMAND "CHANGE" ss "" "P" "LT" "BYLAYER" "")
(COMMAND "CHANGE" ss "" "P" "LA" "TEXT" ""))
(defun c:5()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 5 "")
(COMMAND "CHANGE" ss "" "P" "LT" "PHANTOM" "")
(COMMAND "CHANGE" ss "" "P" "LA" "DIM" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun c:6()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 6 "")
(COMMAND "CHANGE" ss "" "P" "LT" "BYLAYER" "")
(COMMAND "CHANGE" ss "" "P" "LA" "0" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun c:7()
(setq ss(ssget))
(COMMAND "CHANGE" ss "" "P" "C" 7 "")
(COMMAND "CHANGE" ss "" "P" "LT" "BYLAYER" "")
(COMMAND "CHANGE" ss "" "P" "LA" "0" "")
(COMMAND "CHANGE" ss "" "P" "S" 1 ""))
(defun C:ER()
(command "ucs" "w")
(SETVAR "CMDECHO" 0)
(SETQ SS1 (SSGET '(( 0 . "DIMENSION") )))
(SETQ DD1(GETPOINT " \n垂直方向尺寸"))
(setq ddx (car dd1))
(setq count 0)
(setq emax (SSLENGTH Ss1))
(WHILE (< COUNT EMAX)
(setq EN (ssname ss1 COUNT))
(setq ED (ENTGET EN))
(setq eed (assoc 14 ed))
(setq SUCC (cdr (assoc 70 ed)))
(setq eedx (cdr eed ))
(setq eedy(cadr eedx))
(if(OR ( = SUCC 166) (= SUCC 38)(= SUCC 6))
(progn
(setq BB (LIST 14 DDX EEDY 0 ))
(SETQ ED (SUBST BB EED ED))
(ENTMOD ed)))
(SETQ COUNT (1+ COUNT))
)
(PROMPT "\n No Section:...")
(princ)
)
(defun C:ES()
(command "ucs" "w")
(SETVAR "CMDECHO" 0)
(SETQ SS1 (SSGET '(( 0 . "DIMENSION") )))
(SETQ DD1(GETPOINT " \n水平方向尺寸"))
(setq ddx (cdr dd1))
(setq ddy (car ddx))
(setq count 0)
(setq emax (SSLENGTH Ss1))
(WHILE (< COUNT EMAX)
(setq EN (ssname ss1 COUNT))
(setq ED (ENTGET EN))
(setq eed (assoc 14 ed))
(setq SUCC (cdr (assoc 70 ed)))
(setq eedx (cdr eed ))
(setq eedy(car eedx))
(if(OR ( = SUCC 102) (= SUCC 230))
(progn
(setq BB (LIST 14 EEDY DDy 0 ))
(SETQ ED (SUBST BB EED ED))
(ENTMOD ed)))
(SETQ COUNT (1+ COUNT))
)
(PROMPT "\n No Section:...")
(princ))
(defun c:ZE()
(command "ZOOM""E")
)
(defun c:RT()
(command "ROTATE")
)
(defun c:XA()
(SETVAR "OSMODE" 183)
(command "XLINE""A") )
(DEFUN C:SE()
(setvar "insunits" 4)
(SETVAR "CMDECHO" 0)
(SETVAR "blipmode" 0)
(COMMAND "LAYER" "M" "TEMP" "" )
(COMMAND "LAYER" "C" 15 "TEMP" "")
(command "clayer" "0")
(COMMAND "LAYER" "off" "TEMP" "")
(COMMAND "LAYER" "M" "TEXT" "" )
(COMMAND "LAYER" "C" 4 "TEXT" "")
(COMMAND "LAYER" "M" "DIM" "" )
(COMMAND "LAYER" "C" 2 "DIM" "")
(COMMAND "LAYER" "P" "N" "TEMP" "")
(COMMAND "LAYER" "ON" "text" "" )
(COMMAND "LAYER" "ON" "dim" "" )
(COMMAND "LAYER" "ON" "0" "" )
(command "-style" "standard" "simplex.shx" "" "0.8" "" "" "" "" )
(alert "格式化完成"))
(DEFUN C:SQ()
(COMMAND "STYLE" "DIM" "simplex.shx,gbcbig.shx" "" "0.8" "" "" "" "" ))
(DEFUN C:BG()
(SETVAR "INSUNITS" 4)
(COMMAND "CLAYER" "TEXT")
(SETQ PT(GETPOINT "PLEASE CHOOSE A POINT"))
(COMMAND "INSERT" "D:\\SOFT\\CAD\\mingxi.DWG" PT """"""))
(DEFUN C:ZC()
(SETVAR "INSUNITS" 4)
(COMMAND "CLAYER" "TEXT")
(SETQ PT(GETPOINT "PLEASE CHOOSE A POINT"))
(COMMAND "INSERT" "D:\\SOFT\\CAD\\ZC.DWG" PT """"""))
(COMMAND "CLAYER" "0")
(SETQ GGI (STRCAT qpath" " tex16 ))
(COMMAND "CLAYER" "defpoints")
(COMMAND "TEXT" "S" "" "J" "C" PpO "4" "" GGI )
(setq count (1+ count)))
(COMMAND "CLAYER" "0")
(COMMAND "LAYER" "OFF" "*" "" "")
(COMMAND "LAYER" "ON" "0" "" )
(COMMAND "LAYER" "ON" "defpoints" "" )
(command "ucs" "w" )
(COMMAND "_copyclip" ) )
(defun c:GT()
(SETQ OP (ENTGET (CAR(NENTSEL " \n图层名称\n"))))
(SETQ AA (CDR(ASSOC 1 OP)))
(print AA)
(setq ss(ssget))
(SETQ DD (GETINT"\n颜色代码\n"))
(COMMAND "LAYER" "M" AA "")
(COMMAND "CHANGE" ss "" "P" "C" DD "")
(COMMAND "CHANGE" ss "" "P" "LA" AA "")
)
(defun c:GB()
(SETQ OP (ENTGET (CAR(NENTSEL " \nCHOOSE\n"))))
(SETQ VL (CDR(ASSOC 8 OP)))
(PRINC VL)
(setq ss(ssget (list (cons 8 VL))))
(COMMAND "UCS" "W")
(COMMAND "CLAYER" VL)
(COMMAND "_cutclip" SS "")
(COMMAND "_pasteblock" )
)
(defun c:WW()
(if (null DIS) (setq DIS 1))
(SETQ AAD DIS)
(SETQ BB (RTOS DIS 2 0))
(SETQ GGII (STRCAT "输入序号(" BB ")"))
(SETQ DIS (GETINT GGII))
(if ( null DIS) (setq DIS AAD))
(WHILE
(SETQ BB (RTOS DIS 2 0))
(SETQ GGIII (STRCAT "\n选择图层(" BB ")"))
(SETQ D ( * (- DIS 1) 7.37 ))
(SETVAR "OSMODE" 0)
(SETQ OP (ENTGET (CAR(NENTSEL GGIII))))
(SETQ GGI (CDR(ASSOC 8 OP)))
(princ GGI)
(SETVAR "ORTHOMODE" 0)
(SETVAR "OSMODE" 512)
(SETQ YSQ1 (GETPOINT " "))
(SETQ YSQ2 (GETPOINT YSQ1 " "))
(SETQ YY1(DISTANCE YSQ1 YSQ2))
(SETQ YSQ1X(CAR YSQ1))
(SETQ YSQ1Y(CADR YSQ1))
(SETQ YSQ2X(CAR YSQ2))
(SETQ YSQ2Y(CADR YSQ2))
(SETQ GSY (- YSQ2Y 2))
(SETQ W (/ 5 YY1))
(SETQ PPX (+ (* W YSQ1X) (* (- 1 W) YSQ2X) ))
(SETQ PPY(+ (* W YSQ1Y) (* (- 1 W) YSQ2Y) ))
(SETVAR "OSMODE" 0)
(COMMAND "CLAYER" "TEXT")
(command "donut" "0" (getvar "ltscale") YSQ1 "")
(COMMAND "LINE" YSQ1 (LIST PPX PPY) "" )
(COMMAND "CIRCLE" YSQ2 5 )
(COMMAND "TEXT" "J" "C"(LIST YSQ2X GSY) "4" "" DIS)
(setq ssS (entlast))
(COMMAND "CHANGE" ssS "" "P" "LA" "TEXT" "")
(setq pathlength (strlen GGI))
(SETQ BBQ( - pathlength 16))
(setq VVL (substr GGI 16 ))
(setq VB (substr VVL 1 1 ))
(IF (/= VB " ") (SETQ VL VVL) (SETQ VL (substr GGI 17 )))
(setq VLL (substr GGI 1 14))
(SETQ PO (LIST 0 D))
(SETQ P1 (LIST -100 D))
(SETVAR "CLAYER" "TEXT")
(COMMAND "TEXT" P1 "3" "" VL )
(setq ss1 (entlast))
(COMMAND "CHANGE" ss1 "" "P" "C" 4 "")
(COMMAND "TEXT" PO "3" "" VLL )
(setq ss2 (entlast))
(COMMAND "CHANGE" ss2 "" "P" "C" 4 "")
(COMMAND "LAYER" "OFF" GGI "")
(SETQ DIS(+ DIS 1)))
)
(DEFUN C:RS()
(COMMAND "LAYON"))
(DEFUN C:FS()
(COMMAND "LAYOFF"))
(DEFUN C:XS()
(COMMAND "LAYISO"))
(DEFUN C:FR()
(COMMAND "_REFEDIT"))
(DEFUN C:FC()
(COMMAND "_REFCLOSE" ""))
(defun c:SS()
(setvar "cmdecho" 1)
(setq en (ssget (list '(0 . "spline,arc,line,ellipse,LWPOLYLINE"))))
(setq i 0)
(setq ll 0)
(repeat (sslength en)
(setq ss (ssname en i))
(setq endata (entget ss))
(command "lengthen" ss "")
(setq dd (getvar "perimeter"))
(setq ll (+ dd ll))
(setq i (1+ i))
)
(princ "所选线条总长为:")(princ ll)(princ)
)
|
评分
-
查看全部评分
|