nalsur8 发表于 2022-7-6 09:38:55

添加倒角引线

此编码只能选择直线,不能选择多段线
如何更改代码,以便用户可以选择直线和多段线来添加尺寸/引线
 
TQ公司
 
 
(defun C:DCH(/ CL CHAM DL PT1 PT2 ANG ANG1 DIST PT3 PT4 DIST1 T1 H1 V1)
(defun *error* (msg) (setq *error* nil) (princ))
(setq old10 (getvar "ucsorg"))
(command "_ucs" "w")
(command "_ucsicon" "or")
(setvar "CMDECHO" 0)
(setq CL(getvar "CLAYER")
      CHAM(entget(car(entsel "\nSelect Chamfer to Dimension: ")))
      PT1(cdr(assoc 10 CHAM))
      PT2(cdr(assoc 11 CHAM))
      ANG(angle PT1 PT2)
      ANG1(angtos ANG 0 0)
      DIST(distance PT1 PT2))
(cond
    ((or(= ANG1 "45")(= ANG1 "135")(= ANG1 "225")(= ANG1 "315"))
      (setq PT3(polar PT1 ANG (/ DIST 2.0))
            PT4(getpoint "\nNote Location: ")
            DIST1(rtos(* DIST(abs(cos ANG))) 2 2)
            T1(strcat "C"DIST1))
   (command "leader" pt3 pt4 "" "" "" T1 "")
    )
    ((or(and(> ANG1 "0")(< ANG1 "45"))
      (and(> ANG1 "45")(< ANG1 "135"))
      (and(> ANG1 "135")(< ANG1 "225"))
      (and(> ANG1 "225")(< ANG1 "315"))
      (and(> ANG1 "315")(< ANG1 "360")))   
      (setq H1(getpoint "\nHorizontal Dimension Line Location: ")
            V1(getpoint "\nVertical Dimension Line Location: "))
      (command "layer" "s" DL "" "dim" "horizontal" PT1 PT2 H1 "" "vertical" PT1 PT2 V1 "" nil)
    )         
)
(command "layer" "s" CL "")
)

SunnyTurtle 发表于 2022-7-6 10:44:07

您好,我是lisp新手,所以我不完全理解您想要做什么,但您不能使用内置于中的chamfer命令吗https://www.cadtutor.net/forum/images/icons/icon20.pngutocad,允许对多段线进行倒角
这里有一个使用该功能的小lisp
 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PLC()

(setq ply (entsel "\nSelect Polyline you wish to Chamfer: "))
(setq disa (getreal "\nEnter distance from corner to chamfer: "))
(setq anga 45)
(command "chamfer" "angle" disa 315)
(command "chamfer" "polyline" ply)

);end defun PLC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
页: [1]
查看完整版本: 添加倒角引线