明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 570|回复: 0

[提问] (求助)大神们看能不能帮忙把垂直辅助线修剪改成框选的

[复制链接]
发表于 2022-4-12 12:11 | 显示全部楼层 |阅读模式
各位大神,能不能帮忙把以下[size=14.1176px]wyl219大神写的代码改成框选的
两根竖线是垂直的构造线
横线可以是构造线,也可以是多段线和直线

以下是[size=14.1176px]wyl219大神写的代码
(defun c:ttt ()
        (setq en1 (car (entsel "选择左下构造线")))
        (setq en2 (car (entsel "选择右上构造线")))
        (setq ed1 (entget en1))
        
        (setq ss (ssget "X" (list (cons 0 "XLINE")
                                                                                                (cons -4 "<AND")
                                                                                                (cons -4 "/=")
                                                                                                (assoc 11 ed1)
                                                                                                (cons -4 "/=")
                                                                                                (cons 11 (mapcar '- (cdr(assoc 11 ed1))))
                                                                                                (cons -4 "AND>") ;不与en1平行
                                                                                        )))
        
        (setq get_line (lambda (ed) (list (cdr (assoc 10 ed )) (mapcar '+  (cdr (assoc 10 ed ) ) (cdr (assoc 11 ed ))))))
        
        (setq line_en1 (get_line (entget en1)))
        (setq line_en2 (get_line (entget en2)));获取两个构造线上的一段
        
        
        (repeat (setq i (sslength ss))
                (setq i (1- i))
                (setq en_now (ssname  ss i))
                (setq ed_now (entget en_now))
                (setq line_now (get_line (entget en_now)))
               
                (setq pt1 (apply 'inters (append line_en1 line_now (list nil)) ));获取交点
                (setq pt2 (apply 'inters (append line_en2 line_now (list nil)) ));获取交点
               
                (if (or (< (nth 1 (assoc 11 ed_now)) 0)
                                        (< (nth 2 (assoc 11 ed_now)) 0)) ;这里条件还没琢磨透,当构造线是斜线的时候.可能会弄错
                        (progn;如果方向矢量xy中有一个小于0
                                (entmake_ray ed_now
                                        pt1
                                        (cdr (assoc 11 ed_now))
                                )
                                (entmake_ray ed_now
                                        pt2
                                        (mapcar '- (cdr (assoc 11 ed_now)))
                                )
                        )
                        (progn;如果方向矢量xy均大于0
                                (entmake_ray ed_now
                                        pt2
                                        (cdr (assoc 11 ed_now))
                                )
                                (entmake_ray ed_now
                                        pt1
                                        (mapcar '- (cdr (assoc 11 ed_now)))
                                )
                        )
                );end if
                (entdel en_now);删除原构造线
        )
)



(defun entmake_ray (ed dxf10 dxf11 / del_dxf)
        (setq del_dxf (list -1 0 330 5 100 100 10 11 )        );100出现了两次
        (foreach x del_dxf
                (setq ed (vl-remove (assoc x ed) ed))
        );删除无用的组码,对于颜色等,如果是随层,信息表里不会出现对应信息
        
        (setq ed (append
                                                 (list
                                                         (cons 0 "RAY")
                                                         (cons 100 "AcDbEntity")
                                                         (cons 100 "AcDbRay")
                                                         (cons 10 dxf10)
                                                         (cons 11 dxf11)
                                                 )
                                                 ed
                                         ));添加必要代码
        
        (entmake ed) ;生成对象
        
)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

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

本版积分规则

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

GMT+8, 2024-5-2 08:15 , Processed in 0.203678 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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