长圆孔LSP,求改
(defun c:tt ()(setvar "CMDECHO" 0)
(if (and (setq r (getdist "\n半径 :"))
(setq pt (getpoint "\n插入点 :"))
(setq pta (getpoint pt "\n另一点 :"))
)
(progn
(setq ang(angle pt pta)
di(distance pt pta)
ptb(polar pt ang r)
pt1(polar ptb (+ ang (/ pi 2)) r)
pt2(polar pt1 ang (- di (* r 2)))
pt3(polar ptb (+ ang (/ pi -2)) r)
pt4(polar pt3 ang (- di (* r 2)))
)
(command "_.PLINE" "non" pt1 "non" pt2 "A" "non" pt4 "L" "non" pt3 "A" "CL")
)
)
(setvar "CMDECHO" 1)
(princ)
)
该程序来自明经http://bbs.mjtd.com/forum.php?mod=viewthread&tid=101568
想求人改一下,将长圆孔的长度值(即程序中: \n插入点 :" 到 \n另一点 :"之间的距离)改为圆孔两圆心间的距离。另外,(if (and (setq r (getdist "\n半径 :"))可不可以加个默认数值。谢谢
http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 皇上快溜的微博 琴剑江山_10184 发表于 2016-6-18 09:51
第三行是不是有点问题,运行一直是r为5。(or (setq r (getdist "\n半径 <5>:")) (setq r 5))改成这样可以传递r值 蛮不错的 感谢分享~
学习了~
谁可以帮我改改。谢谢 本帖最后由 Andyhon 于 2016-6-17 23:01 编辑
(defun c:tt ()
(setvar "CMDECHO" 0)
(if (and
(setq r (getdist "\n半径 :"))
(setq pt (getpoint "\n插入点 :"))
(setq pta (getpoint pt "\n另一点 :"))
)
(progn
(setq ang(angle pt pta)
<90(/ Pi 2)
;; di (distance pt pta)
;; ptb(polar pt ang r)
pt1(polar pt (- ang <90) r)
pt2(polar pt (+ ang <90) r)
pt3(polar pta (- ang <90) r)
pt4(polar pta (+ ang <90) r)
)
(command "_.PLINE" "non" pt1 "non" pt3 "A" "non" pt4 "L" "non" pt2 "A" "CL")
)
)
(setvar "CMDECHO" 1)
(princ)
)
Andyhon 发表于 2016-6-17 22:37 static/image/common/back.gif
老大,这个程序不行啊?报错 错误: 参数类型错误: numberp: nil Andyhon 发表于 2016-6-17 22:37 static/image/common/back.gif
可能我图片中表达意思有点模糊
原程序定义的“长圆孔长度值”是两圆弧两端象限点之间的距离,
现在想让“长圆孔长度值”定义两圆弧之圆心间的距离
另外,程序中R值的输入,可不可以帮忙设个默认数值,谢谢你 本帖最后由 Andyhon 于 2016-6-17 23:04 编辑
sorry!已订正
R:
ref: http://bbs.mjtd.com/thread-172545-1-1.html
皇上快溜 发表于 2016-6-17 21:34 static/image/common/back.gif
谁可以帮我改改。谢谢
(defun c:tt ()
(setvar "CMDECHO" 0)
(or (setq r (getdist "\n半径 <5>:") r 5))
(if (and
(setq pt (getpoint "\n插入点 :"))
(setq pta (getpoint pt "\n另一点 :"))
)
(progn
(setq ang(angle pt pta)
di (distance pt pta)
ptb(polar pt ang r);
pt1(polar ptb (+ ang (/ pi 2)) r)
pt2(polar pt1 ang di)
pt3(polar ptb (+ ang (/ pi -2)) r)
pt4(polar pt3 ang di)
)
(command "_.PLINE" "non" pt1 "non" pt2 "A" "non" pt4 "L" "non" pt3 "A" "CL")
)
)
(setvar "CMDECHO" 1)
(princ)
)
谢谢Andyhon,谢谢琴剑江山。程序很好用,,, 楼上俩位老大,我这还有一个程序想请二位轻轻改动一下
(defun c:yk()
(setq ptcen (getpoint "\n输入圆心:"))
(setq rr (getdist ptcen "\n指定半径<默认:1>:"))
(if (null rr)(setq rr 1.0))
(command "circle" "non" ptcen rr)
(command "move" (entlast) "" ptcen pause)
(princ))
是个画圆并将其移动一个距离的程序。给定圆心点后,空格键确认程序默认的圆径数值。紧接着就是移动动作。现在想让程序执行移动命令是,也有个默认的移动距离数值,以鼠标拖拽放向为移动方向,以空格键结束。最后面那里不知该怎么弄。或者,以你们专业的编程章法,根本不用那么累赘。就是想在给定点的,默认偏移距离(正交)上,画一个有默认数值的圆 琴剑江山_10184 发表于 2016-6-18 09:51 static/image/common/back.gif
你好,我这个小lsp想请你改一下。在9楼
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=172551
页:
[1]
2