明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1681|回复: 1

[已解答] 画中心线程序,请帮忙改成 以比例加长

[复制链接]
发表于 2013-5-30 10:23:32 | 显示全部楼层 |阅读模式
下面的程序是 画中心线的,请帮忙改成“以比例加长的”。现在只能加长固定长度。
想改成:
如果是圆就以圆的直径加长一定比例的长度,如果是直线就以两直线的平均长度加长一定比例的长度


;;;━━━━━━━━━━━━━━
(DEFUN C:cx()
(setq old_osm (getvar "osmode"))
(setvar "osmode" 0)
(if (null (tblsearch "layer" "中心线"))
  (command "layer" "n" "中心线" "c" "4" "中心线" "lt" "center" "中心线" "")
)
(setq sel_id "OK"
       cx_ent1 (entsel "\n请选取直线LINE&圆弧ARC&圆CIRCLE:"))
(while (and sel_id cx_ent1)
  (setq cx_dat1 (entget (car cx_ent1))
        cx_nam1 (cdr (assoc 0 cx_dat1)))
  (if (and (/= "LINE"   cx_nam1)
           (/= "ARC"    cx_nam1)
           (/= "CIRCLE" cx_nam1))
   (setq cx_ent1 (entsel "\r请选取直线LINE&圆弧ARC&圆CIRCLE:"))
   (setq sel_id nil)
  )
)
(if (and cx_ent1 (null sel_id))
  (progn
   (setq cx_lay "中心线")
   (if (= "LINE" cx_nam1)
    (progn
     (setq cx_ent2 (entsel "\n请选取另一直线:"))
     (if cx_ent2
      (progn
       (setq cx_dat2 (entget (car cx_ent2))
             cx_nam2 (cdr (assoc 0 cx_dat2)))
       (if (/= "LINE" cx_nam2)
        (exit)
        (progn
         (setq cx_pt1 (trans (cdr (assoc 10 cx_dat1)) 0 1)
               cx_pt2 (trans (cdr (assoc 11 cx_dat1)) 0 1)
               cx_pt3 (trans (cdr (assoc 10 cx_dat2)) 0 1)
               cx_pt4 (trans (cdr (assoc 11 cx_dat2)) 0 1)
               cx_pt5 (trans (cadr cx_ent1) 0 1))
         (if (<= (distance cx_pt1 cx_pt5) (distance cx_pt2 cx_pt5))
          (setq cx1_pt cx_pt1 cx2_pt cx_pt2)
          (setq cx1_pt cx_pt2 cx2_pt cx_pt1)
         )
         (if (<= (distance cx_pt3 cx_pt5) (distance cx_pt4 cx_pt5))
          (setq cx3_pt cx_pt3 cx4_pt cx_pt4)
          (setq cx3_pt cx_pt4 cx4_pt cx_pt3)
         )
         (setq cx_pnt1 (polar cx1_pt (angle cx1_pt cx3_pt) (* 0.5 (distance cx1_pt cx3_pt)))
               cx_pnt2 (polar cx2_pt (angle cx2_pt cx4_pt) (* 0.5 (distance cx2_pt cx4_pt))))
         (command "line" (polar cx_pnt1 (angle cx_pnt2 cx_pnt1) (- -1.5 (distance cx_pnt1 cx_pnt2)))
                         (polar cx_pnt2 (angle cx_pnt1 cx_pnt2) (- -1.5 (distance cx_pnt1 cx_pnt2))) "")
         (command "chprop" (entlast) "" "c" "4" "lt" "center" "la" cx_lay "")
        )
       )
      )
     )
    )
    (progn
     (setq cx_pt (trans (cdr (assoc 10 cx_dat1)) 0 1)
           cx_rad (cdr (assoc 40 cx_dat1)))
     (command "line" (list (+ (+ 1.5 cx_rad) (car cx_pt)) (cadr cx_pt))
                     (list (- (car cx_pt) (+ 1.5 cx_rad)) (cadr cx_pt)) "")
     (command "chprop" (entlast) "" "c" "4" "lt" "center" "la" cx_lay "")
     (command "line" (list (car cx_pt) (+ (+ 1.5 cx_rad) (cadr cx_pt)))
                     (list (car cx_pt) (- (cadr cx_pt) (+ 1.5 cx_rad))) "")
     (command "chprop" (entlast) "" "c" "4" "lt" "center" "la" cx_lay "")
    )
   )
  )
)
(setvar "osmode" old_osm)
(princ)
)
 楼主| 发表于 2013-5-30 11:08:13 | 显示全部楼层
已解决了,不用回复了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-23 21:16 , Processed in 0.177392 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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