Jump to content

Lisp lệnh BRK trong chủ đề “Lisp biến 1 phần của đoạn thẳng trở thành nét Hidden2.”

Sửa lỗi trong trường hợp gọi lệnh trong hệ tọa độ của người sử dụng UCS
và bổ sung phần các điểm chọn trùng với 2 đầu mút.

Cách dùng

  1. Tải tệp 79984_brk.lsp về máy.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh BRK để chạy lisp.

Mã nguồn 79984_brk.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/15057-lisp-bi%E1%BA%BFn-1-ph%E1%BA%A7n-c%E1%BB%A7a-%C4%91o%E1%BA%A1n-th%E1%BA%B3ng-tr%E1%BB%9F-th%C3%A0nh-n%C3%A9t-hidden2/?tab=comments#comment-79984
(defun c:brk(/ cobj ent ov pt1 pt2 tmp vl); brk -> Break Curve
 ;;  By : Gia_Bach, www.CadViet.com      ;;  
 (vl-load-com)
 (command "undo" "be")
 (setq vl '("osmode" "orthomode" "cmdecho") ; Sys Var list
ov (mapcar 'getvar vl))              ; Get Old values
 (mapcar 'setvar vl '(545 0 0))
 (if (and (setq Ent (car (entsel "\nChon doi tuong can chia :")))
 (wcmatch (cdr (assoc 0 (entget ent))) "*LINE,ARC")
 (not (redraw ent 3))
 (setq pt1 (getpoint "\nDiem dau :"))
 (setq pt2 (getpoint pt1 "\nDiem cuoi :" ))
 (not (redraw ent 4)))
   (progn
     (if (not (tblsearch "LTYPE" "HIDDEN2"))
(command "._linetype" "_load" "HIDDEN2" "acad.lin" ""))
     (setq cObj (vlax-ename->vla-object Ent)
  pt1 (vlax-curve-getClosestPointto cObj (trans pt1 1 0))
  pt2 (vlax-curve-getClosestPointto cObj (trans pt2 1 0)))
     (if (eq (vla-get-Objectname cobj)"AcDb2dPolyline")
(progn
(command "._pedit" ent "")
(setq cObj (vlax-ename->vla-object (entlast)))))
     (if (> (vlax-curve-getParamAtPoint cObj pt1)
   (vlax-curve-getParamAtPoint cObj pt2))
(setq tmp pt1 pt1 pt2 pt2 tmp) )      
     (command "._break" ent "_non" (trans pt2 0 1) "_non" (trans pt2 0 1))
     (if (equal pt1 (vlax-curve-getStartPoint cObj) 0.001)
(command "change" ent "" "p" "c" "8" "lt" "hidden2" "")
(progn
(command "._break" ent "_non" (trans pt1 0 1) "_non" (trans pt1 0 1))
(command "change" (entlast) "" "p" "c" "8" "lt" "hidden2" "")  ))
     (command "undo" "e")      )
   (alert "Khong hop le !"))
 (mapcar 'setvar vl ov) ; reset Sys Vars
 (princ))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Lisp biến 1 phần của đoạn thẳng trở thành nét Hidden2.. Xem đúng bài viết #79984 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 3)