杜阳 发表于 2014-7-17 17:50:50

各位大师,请帮忙

本帖最后由 杜阳 于 2014-7-17 17:53 编辑

我想选择一条多段线,定量偏移后,起点与起点连接,终点与终点连接,最后形成一个闭合的多段线,引用了一个老师的一段代码,自己加了一些,代码如下:
(Defun C:Pc(/ Ss1 ss2 p1 p2 p3 p4 Pt1 Pt2)
(vl-load-com)
(Setvar "Cmdecho" 0)
    (Setq Pt1 (Getvar "Vsmin"))
    (Setq Pt2 (Getvar "Vsmax"))
    (Setq Ss1 (Entsel "\n 选择线:"))
    (Setq Ss2 (vla-offset (vlax-ename->vla-object (car ss1)) 0.3))
    (Setq p1 (vlax-curve-getstartpoint (car ss1)))
    (Setq p2 (vlax-curve-getendpoint (car ss1)))
    (Setq p3 (vlax-curve-getstartpoint (car ss2)))
    (Setq p4 (vlax-curve-getendpoint (car ss2)))
(Vl-Cmdf "line" p1 p3 "" "line" p2 p4 "")
(Vl-Cmdf ".Pedit" Ss1 "Yes" "J" "C" Pt1 Pt2 "" "")
(Setvar "Cmdecho" 1)
(Princ)
)

偏移执行了,连接和闭合没有执行,请大师给予修改教导,谢谢了

xyp1964 发表于 2014-7-17 19:41:51

(defun c:tt ()
(setvar "cmdecho" 0)
(setq s1 (car (entsel "\n选择线: ")))
(vla-offset (vlax-ename->vla-object s1) 100)
(setq s2 (entlast)
        p1 (vlax-curve-getstartpoint s1)
        p2 (vlax-curve-getendpoint s1)
        p3 (vlax-curve-getstartpoint s2)
        p4 (vlax-curve-getendpoint s2)
)
(vl-cmdf "line" p1 p3 "")
(setq s3 (entlast))
(vl-cmdf "line" p2 p4 "")
(setq s4 (entlast))
(vl-cmdf ".pedit" "m" s1 s2 s3 s4 "" "j" 0 "")
(princ)
)

杜阳 发表于 2014-7-17 21:26:09

xyp1964 发表于 2014-7-17 19:41 static/image/common/back.gif


谢谢院长   你是老师   我敬佩你祝福你写出更多的代码成为中国的lee

杜阳 发表于 2014-7-17 21:43:29

xyp1964 发表于 2014-7-17 19:41 static/image/common/back.gif


院长你好,实现了我的理想中的执行,我想再追问一个 就是在多段线端点的地方自动绘制一个定量的圆,这个怎么实现   是不是先得到多段线的点列表,然后在每个点那里绘制一个定量圆这个思路对吗谢谢
页: [1]
查看完整版本: 各位大师,请帮忙