代码改变世界

AutoCAD LISP绘制左右对称心型图案

2011-03-27 14:58 by 精诚所至 金石为开, 489 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP根据输入对角点自动绘制左右对称心型图案,代码如下。(defun c:test() (setvar "cmdecho" 0) (setq pt1 (getpoint "\n第一角点:")) (setq pt3 (getcorner pt1 "\n另一角点:")) (setq pt2 (list (car pt3) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt3))) (command "pline" pt1 pt3 pt2 pt4 " 阅读全文

AutoCAD LISP绘制四圆孔

2011-03-27 14:43 by 精诚所至 金石为开, 514 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP根据输入角点和圆半径绘制四圆孔,代码如下。(defun c:test() (setvar "cmdecho" 0) (setq pt1 (getpoint "\n第一角点:")) (setq pt3 (getpoint "\另一角点:")) (setq pt2 (list (car pt3) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt3))) (setq rr (getdist pt1 "\n圆半径:")) (if (null rr) (s 阅读全文

AutoCAD LISP凹型图

2011-03-27 14:29 by 精诚所至 金石为开, 425 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP根据输入左下角点、宽度和高度绘制”凹“行型图,代码如下。(defun c:test() (setvar "cmdecho" 0) (setq pt1 (getpoint "\n选取图形左下角点:")) (setq ww (getdist pt1 "\n宽度:")) (if (null ww) (setq ww 100)) (setq hh (getdist pt1 "\n高度<50>:")) (if (null hh) (setq hh 50)) (setq ww3 (/ ww 阅读全文

AutoCAD LISP利用子程序绘制田字格

2011-03-27 13:35 by 精诚所至 金石为开, 761 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP利用子程序绘制田字格,代码如下。(defun c:pbox() (get_pbox_data) (draw_pbox) (prin1) ) (defun get_pbox_data() (setq pa (getpoint "请输入左下角点:")) (setq ww (getdist pa "\n宽度:")) (setq hh (getdist pa "\n高度:")) ) (defun draw_pbox() (setq pb (polar pa 0 ... 阅读全文

AutoCAD LISP循环判断语句绘制多个圆内接正多边形

2011-03-27 00:14 by 精诚所至 金石为开, 679 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP循环判断,根据输入的正多边形边数,语句绘制多个圆内接正多边形,代码如下。(defun c:test() (setq n (getint "请输入正多边形边数N:")) (setq en (entsel "\n选取欲作内接多边形的圆:")) (setq i 0) (while en (setq endata (entget (car en))) (setq entype (cdr (assoc 0 endata))) (if (= entype "CIRCLE") (progn ... 阅读全文

AutoCAD LISP循环判断自动绘制楼梯

2011-03-26 23:57 by 精诚所至 金石为开, 729 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP REPEAT循环判断根据左下角点、楼梯高度、高度和阶数自动绘制楼梯,代码如下。(defun c:test() (setq pa (getpoint "请输入左下角点:")) (setq ww (getdist pa "\n请输入楼梯宽度:")) (setq hh (getdist pa "\n请输入楼梯高度:")) (setq n (getint "\n请输入楼梯阶数:")) (setq pb (polar pa 0 ww)) (setq pc (polar pb (/ pi 2) hh) 阅读全文

AutoCAD LISP循环判断求A到B的整数和

2011-03-26 23:42 by 精诚所至 金石为开, 452 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP循环判断求A到B的整数和,比如求100以内的整数和,输入起始值为0,终止值为100即可,代码如下。(defun c:test() (setq nums (getint "请输入起始值:")) (setq nume (getint "\n请输入终止值:")) (setq snum 0) (setq nn (+ 1 (- nume nums))) (setq numadd nums) (repeat nn (setq snum (+ snum numadd)) (setq numadd (... 阅读全文

AutoCAD LISP 循环选择语句cond

2011-03-26 23:25 by 精诚所至 金石为开, 2780 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP 循环选择语句cond,相比if语句更加简洁,代码如下。(defun c:test() (initget "A0 A1 A2 A3 A4") (setq size (getkword "请输入图纸大小A0,A1,A2,A3,A4<A3>:")) (if (= size nil) (setq size "A3")) (setq size (strcase size)) (cond ((= size "A0") (setq p2 '(1189 841))) ((= size 阅读全文

AutoCAD LISP绘制标准图框

2011-03-26 22:25 by 精诚所至 金石为开, 1125 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP绘制标准图框,if选择语句,绘制A1,A2,A3,A4图框,代码如下。(defun c:test() (setq size (getstring "请输入图纸大小AO,A1,A2,A3,A4<A3>:")) (if (= size "") (setq size "A3") ) (setq size (strcase size)) (if (= size "A0") (setq p2 '(1189 841))) (if (= size "A1") (se 阅读全文

AutoCAD LISP自然数的和

2011-03-26 22:04 by 精诚所至 金石为开, 431 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP自然数的和,根据输入的数值,求自然数的和,代码如下。(defun c:test() (setq intputin (getint "请输入数值:")) (setq snum 1) (setq sum 0) (repeat intputin (setq sum (+ snum sum)) (setq snum (+ 1 snum)) ) (princ "1+2+3+……+") (princ intputin) (princ "=") (princ su... 阅读全文

《空口言》孙燕姿

2011-03-26 21:52 by 精诚所至 金石为开, 179 阅读, 0 推荐, 收藏, 编辑
摘要:2011年3月26日晚9点51分402 阅读全文

AutoCAD LISP简单IF判断语句

2011-03-26 21:48 by 精诚所至 金石为开, 3431 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP简单判断语句,代码如下。(defun c:test() (setq cenpt (getpoint "输入圆心:")) (setq rad (getdist cenpt "\n输入圆半径:")) (if (> rad 0) (progn (command "circle" cenpt rad) (command "chprop" (entlast) "" "c" 3 "") (princ "\n画图任务完成" 阅读全文

AutoCAD LISP以圆心为中点,圆的缩放操作

2011-03-26 21:26 by 精诚所至 金石为开, 712 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP圆放大缩小操作,代码如下。(defun c:cira() (setvar "cmdecho" 0) (setq cir (entsel "Select CIRCLE to <Scale 0.5>:")) (setq cir_data (entget (car cir))) (setq old_rad_list (assoc 40 cir_data)) (setq old_rr (cdr old_rad_list)) (setq new_rr (* old_rr 0.5)) (setq new_ra... 阅读全文

AutoCAD LISP绘制圆内接五边形

2011-03-26 20:42 by 精诚所至 金石为开, 515 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP绘制圆内接五边形,代码如下。(defun c:test() (setvar "cmdecho" 0) (setq en (entsel "Select CIRCLE:")) (setq en_data (entget (car en))) (setq cenpt (cdr (assoc 10 en_data))) (setq rr (cdr (assoc 40 en_data))) (command "polygon" 5 cenpt "i" rr) (prin1) ) (p... 阅读全文

AutoCAD LISP在直线中点绘制圆

2011-03-26 20:22 by 精诚所至 金石为开, 682 阅读, 0 推荐, 收藏, 编辑
摘要:AutoCAD LISP在直线中点绘制圆,代码如下。(defun c:mcir() (setvar "cmdecho" 0) (setq en (entsel "Select a LINE:")) (setq en_data (entget (car en))) (setq pts (assoc 10 en_data)) (setq pt1 (cdr pts)) (setq px1 (car pt1)) (setq py1 (cadr pt1)) (setq pte (assoc 11 en_data)) ... 阅读全文
上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 51 下一页