明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 901|回复: 1

请解决我的问题

[复制链接]
发表于 2008-3-13 10:16 | 显示全部楼层 |阅读模式

最近,我编写了一个关于四条直线倒圆角的程序。CAD命令只能对两条直线进行倒圆角,可是风管一般都是双线,当遇到两段风管进行倒圆角的时候,就要执行两次命令。故我编写了以下程序,以实现一次命令四直线倒角的功能。但是,程序执行到最后三行的时候,出现问题。于是,我把程序中每一行单独拷贝出来在CAD中执行却又是正确的,不知为何,请高手指点一二,程序如下:

(defun c:DW (/ a b c d e f)
(defun getmidpoint(pt1 pt2)
  (polar pt1 (angle pt1 pt2) (* (distance pt1 pt2) 0.5))
)
(setq a (getint "请输入倒角半径"))
(setq b (getint "请输入管径"))
(setq c (entsel "请选择倒角直线"))
(setq d (entsel "请选择倒角直线"))
(command "fillet" "r" a "fillet" c d)
(setq e (entlast))
(setq f (cdr (assoc 10 (entget e))))
(setq a1 (car f))
(setq a2 (cadr f))
(setq g (cdr (assoc 10 (entget (car c)))))
(setq a3 (car g))
(setq a4 (cadr g))
(setq h (cdr (assoc 10 (entget (car d)))))
(setq a5 (car h))
(setq a6 (cadr h))
(setq y1 (+ a4 (/ (* 50 (- a4 a2)) (- a3 a1))))
(setq x1 (+ a3 50))
(setq i (list x1 y1))
(if (< (distance f i) (distance f g))
(progn
(setq y1 (+ a4 (/ (* 50 (- a2 a4)) (- a3 a1))))
(setq x1 (- a3 50))
(setq i (list x1 y1))
);progn
);if
(command "offset" b c i "")
(setq of1 (cdr (assoc 10 (entget (entlast)))))
(setq of2 (cdr (assoc 11 (entget (entlast)))))
(setq ob1 (getmidpoint of1 of2))
(setq y3 (+ a6 (/ (* 50 (- a6 a2)) (- a5 a1))))
(setq x3 (+ a5 50))
(setq j (list x3 y3))
(if (< (distance f j) (distance f h))
(progn
(setq y3 (+ a6 (/ (* 50 (- a2 a6)) (- a5 a1))))
(setq x3 (- a5 50))
(setq j (list x3 y3))
);progn
);if
(command "offset" b d j "")
(setq of4 (cdr (assoc 11 (entget (entlast)))))
(setq of3 (cdr (assoc 10 (entget (entlast)))))
(setq ob2 (getmidpoint of3 of4))
(setq m (+ a b))
(command "fillet" "r" m "fillet" ob1 ob2)
(command "erase" ob1 "")
(command "erase" ob2 "")
)

谢谢!

发表于 2008-3-13 17:53 | 显示全部楼层

...

(setq ob1 (getmidpoint of1 of2))

...
(setq ob2 (getmidpoint of3 of4))

...

ob1,ob2求得的是点,不是线啊,把getmidpoint 改成画线子程序再试试

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 13:10 , Processed in 0.347718 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表