AutoLISP程序语言设计课件.pptVIP

  • 58
  • 0
  • 约2.73万字
  • 约 67页
  • 2016-12-22 发布于浙江
  • 举报
p p0 p5 p1 p4 p8 p6 p9 p2 p10 p3 p7 练习4:编写参数化绘制平键的Autolisp自定义函数。 (defun c:key() (setq p (getpoint 输入插入点:)) (setq l (getreal 平键的长度:)) (setq b (getreal 平键的宽度:)) (setq a (getreal 输入倾角:)) (setq ang (/ (* pi a) 180)) (setq pi2 (/ pi 2)) (setq r (/ b 2)) (setq l1(- l b)) (setq p1 (polar p (+ ang pi2) r)) (setq p2 (polar p1 ang l1)) (setq p3 (polar p2 (- ang pi2) b)) (setq p4 (polar p3 ang (- l1))) (command pline p1 p2 a p3 l p4 a p1 ) ) 练习5:编写参数化绘制带键槽的轴段横截面图形的Autolisp自定义函数。 (defun c:sect() (setq p0 (getpoint 输入插入点:)) (setq r (getdist p0 输入半径:)) (setq b (getreal 键槽的宽度:)) (setq t1 (getreal 键槽的深度:)) (setq b1 (/ b 2)) (setq a1 (sqrt (- (* r r) (* b1 b1)))) (setq ang (atan (/ b1 a1))) (setq p1 (polar p0 ang r)) (setq p2 (polar p0 0 (- r))) (setq p3 (polar p0 (- ang) r)) (setq p4 (list (- (car p1) t1) (cadr p1))) (setq p5 (list (car p4) (cadr p3))) (command arc p1 p2 p3) (command line p1 p4 p5 p3 ) (setvar HPNAME ANSI31) (setvar HPSCALE 3) (command bhatch p0 ) ) 5)(atoi 字符串) 功能:将字符串化为整型数。示例: Command:(atoi 415) 415 6)(atof 字符串) 功能:将字符串化为实型数。示例: Command:(atof 5) 5.0 7)(rtos 数) 功能:按着AutoCAD系统变量LUNITS和LUPREC定义的记数方式和精度将数转化为字符串。示例:设LUNITS=2(十进制),LUPREC=4 Command:(rtos 3.7) 3.7000 8)(angtos 角度) 功能:按着AutoCAD系统变量LUNITS和LUPREC定义的记数方式和精度将弧度数转化为字符串。示例:设LUNITS=0(度),LUPREC=4 Command:(angtos 3.14) 180 9)(ascii 字符串) 功能:求出字符串第一个字符的ASCII值。示例: Command:(ascii Access) 65 10)(chr 数) 功能:求出整型数所代表的ASCII字符。示例: Command:(chr 65) A (4)字符串处理函数 1)(strcat 字符串1 字符串2 …) 功能:将所列的字符串合并为一个字符串。示例: Command:(strcat C A D) CAD 2)(strlen 字符串) 功能:求出字符串的长度。示例: Command:(strlen AutoCAD) 7 3)(substr 字符串 起始位 [长度]) 功能:按要求求出字符串的一个子串。示例: Command:(substr AutoCAD 5 3) CAD (5)表处理函数 1)(list 表达式 …) 功能:用所列表达式组成一个表。示例: Command:(list C A D) (C A D) Command:(list 1.2 2.3) (1.20 2.30

文档评论(0)

1亿VIP精品文档

相关文档