正文阅读

AutoCAD圆角标注相关

发布时间:2012-4-28 19:47 Saturday|类别: 机械 |编辑:中原

    恩,或许有同事或者同学会有用。先上效果图

    点击查看原图

    完成这个动作很麻烦,先要延长到交点,然后再打断,然后再变换图层,才能正常标注,很伤脑筋。。。于是求助某论坛做了个程序。

    ;绘制圆弧切线
    (defun c:tt (/ last_obj last_se obj obj_data obj_data_list obj_i obj_name n plst ss var1 var2 )
      (princ "\n<----圆弧切线---->")
      (princ "\n请选择圆弧,多段线/<退出>...")
      (setq var1 (getvar "cmdecho"))
      (setq var2 (getvar "osmode"))
      (setvar "cmdecho" 0)
      (setvar "osmode" 0)
      (setq n 0)
      (setq obj (ssget '((0 . "*POLYLINE,ARC"))))
      (if obj
        (repeat (sslength obj)
          (setq ent (entget (ssname obj n)))
          (if (= (cdr (assoc 0 ent)) "ARC")
            (progn
                    (setq plst (sys_get_pt_arc_tan ent))
              (command "_.line" (car plst)  (caddr plst) "")
              (command "_.line" (cadr plst) (caddr plst) "")
            )
          )
          (if (= (cdr (assoc 0 ent)) "LWPOLYLINE")
                  (progn
                    (setq last_obj (ssget "p"))
                    (setq obj_data_list '())
              (setq ss (ssadd (ssname obj n)))
                    (command "_undo" "mark")
                    (command "_explode" ss)
                    (setq last_se (ssget "p"))
                    (if (not (eq last_se last_obj))
                      (progn
                        (setq obj_i -1)
                        (repeat (sslength last_se)
                                (setq obj_name (ssname last_se (setq obj_i (1+ obj_i))))
                                (setq obj_data (entget obj_name))
                                (if (= (cdr (assoc 0 obj_data)) "ARC")
                                  (setq obj_data_list (append (list obj_data) obj_data_list))
                                )
                        )
                      )
                    )
                    (command "_undo" "back")
                    (if obj_data_list
                      (foreach i obj_data_list
                              (setq plst (sys_get_pt_arc_tan i))
                  (command "_.line" (car plst)  (caddr plst) "")
                  (command "_.line" (cadr plst) (caddr plst) "")
                      )
                    )
                  )
          )
          (setq n (+ n 1))
        )
      )
      (setvar "cmdecho" var1)
      (setvar "osmode" var2)
      (princ)
    )
    (defun sys_get_pt_arc_tan (ent / cen jdq jdz p1 p2 p3 p4 p5 rad)
      (setq cen (cdr (assoc 10 ent)));获取圆弧圆心
      (setq rad (cdr (assoc 40 ent)));获取圆弧半径
      (setq jdq (cdr (assoc 50 ent)));获取起始角度
      (setq jdz (cdr (assoc 51 ent)));获取终止角度
      (setq p1 (polar cen jdq rad);获取圆弧起始点
            p2 (polar cen jdz rad);获取圆弧终止点
            p3 (polar p1 (+ (/ pi 2) jdq) rad);获取起始点切线方向的半径点
            p4 (polar p2 (+ (/ pi 2) jdz) rad);获取终止点切线方向的半径点
            p5 (inters p1 p3 p2 p4 nil);切线交点
      )
      (if (not p5)
        (princ "\n切线无交点...")
        (list p1 p2 p5)
      )
    )

     

    使用办法:

    1.复制代码保存为tt.lsp,存到某个地方;

    2.工具-自定义-界面-lisp文件上右键选择加载,确定

    3.敲入tt命令使用,可框选,选则圆弧即可

     

    顺便,常用的还有个打断于点,这个有图标命令,但是木有快捷键,两只手总比一只手有速度,于是自己做了一个:

    ;打断于点
    (defun c:dd ()
    (command "_break" pause "f" pause "@")
    )

     

关键字词

评论:

ehiuan
2012-11-19 16:58
这个功能你用 D 命令设计标尺线应该就能简单解决。定义全局样式,固定延长线,即使你选的两点不一样,延伸线也会一样。

发表评论:

您也可以直接填写QQ到下面的输入框中,点击获取用户资料实现自动调用您的QQ资料