vken7az2p 发表于 2006-5-19 18:37:00

[讨论]:[0519]如何将此倾斜矩形绘制程序简化?

本帖最后由 作者 于 2006-5-19 20:16:02 编辑 <br /><br /> <P>[讨论]:如何将此倾斜矩形绘制程序简化?</P>
<P>小弟练习将绘制矩形可以使用倾斜角度方式绘出,<BR>但个人认为程序应该可以简化,<BR>因此放上来请各位高手指点<BR>烦请各位可以提供宝贵的意见~<BR>谢谢~</P>
<P>(defun c:test ()<BR>(setq pt1 (getpoint "\n 长度方向基点:") )<BR>(setq pt2 (getpoint pt1 "\n 长度方向终点:") )<BR>(setq pt3 (getpoint pt2 "\n 宽度方向:") )<BR>(setq ofs (getdist pt2 "\n 宽度距离:") )<BR>(command "_.line" pt1 pt2 "")<BR>(setq en1 (entlast))<BR>(setq ob1 (entget en1))<BR>(command "_.offset" ofs en1 pt3 "" )<BR>(setq en2 (entlast))<BR>(setq ob2 (entget en2))<BR>(command "_.line" (cdr (assoc 10 ob1))&nbsp; (cdr (assoc 10 ob2) ) "")<BR>(setq en3 (entlast))<BR>(command "_.line" (cdr (assoc 11 ob1))&nbsp; (cdr (assoc 11 ob2) ) "")<BR>(setq en4 (entlast))</P>
<P>(setq ss (ssadd)) <BR>(ssadd en1 ss)<BR>(ssadd en2 ss)<BR>(ssadd en3 ss)<BR>(ssadd en4 ss)<BR>(setq i 0)</P>
<P>&nbsp; (while (&lt; i (sslength ss))<BR>&nbsp;&nbsp;&nbsp; (setq ssa-ent (ssname ss i))<BR>&nbsp;&nbsp;&nbsp; (setq ent-p (cdr (assoc 0 (entget ssa-ent))))<BR>&nbsp;&nbsp;&nbsp; (if&nbsp;(not (null ent-p))&nbsp;&nbsp;;判断原图元是否已串入多义线<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if (or (= ent-p "LWPOLYLINE") (= ent-p "POLYLINE"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;判断原图元属性<BR>&nbsp;(command "pedit" ssa-ent "j" ss "" "")<BR>&nbsp;(command "pedit" ssa-ent "y" "j" ss "" "")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>&nbsp;&nbsp;&nbsp; )<BR>&nbsp;&nbsp;&nbsp; (setq i (1+ i))<BR>&nbsp; )<BR>)<BR></P>

xxsheng 发表于 2006-5-19 18:41:00

vken7az2p发表于2006-5-19 18:37:00static/image/common/back.gif回复:(vken7az2p):如何将此倾斜矩形绘制程序简化?
:如何将此倾斜矩形绘制程序简化?
小弟练习将绘制矩形可以使用倾斜角度方式绘出,但个人认为程序应该可以简化,因此放上

第一个问题,,,程序名c;box,,,你使用过没有?<BR>

vken7az2p 发表于 2006-5-19 20:04:00

<P>谢谢 <A name=14236><FONT color=#000066><B>xxsheng</B></FONT></A>&nbsp;兄的指教</P>
<P>立刻改进~</P>

ZZXXQQ 发表于 2006-5-21 08:45:00


(defun c:test ()
(setq pt1 (getpoint "\n 长度方向基点:"))
(setq pt2 (getpoint pt1 "\n 长度方向终点:"))
(setq pt3 (getdist pt2 "\n 宽度尺寸:"))
(setq pt4 (polar pt2 (+ (angle pt1 pt2) (/ pi 2)) pt3))
(setq pt5 (polar pt1 (+ (angle pt1 pt2) (/ pi 2)) pt3))
(command "pline" pt1 pt2 pt4 pt5 "c")
(princ)
)

jxphklibin 发表于 2007-3-7 10:32:00

改成根据对角点坐标绘制倾斜矩形更好

lijiao 发表于 2007-3-7 11:31:00

只要用的时候感觉舒服就是好程序

akklla 发表于 2007-3-7 12:08:00

小弟跟着学习了,多谢各位!

xxyyzzlg 发表于 2024-7-16 14:41:47

ZZXXQQ 发表于 2006-5-21 08:45


感谢分享,很简洁
页: [1]
查看完整版本: [讨论]:[0519]如何将此倾斜矩形绘制程序简化?