Jump to content

Lisp lệnh ACI trong chủ đề “Kéo cung tròn thành đường tròn?”

Chào Tue_NV

Xin phép bổ sung phần Properties (thuộc tính : layer, color, linetype, lineweight)

dùng Entdel thay cho Command Erase.

(defun c:AtC(/ ar ent ds val); Arc to Circle
 (defun dxf(id ent) (cdr (assoc id ent)) )

 (setq ar (car(entsel "\n Chon arc :")))
 (setq ent (entget ar)
ds (list (cons 0 "CIRCLE") (cons 10 (dxf 10 ent)) (cons 40 (dxf 40 ent)) ))
 (setq ds (append ds (list (cons 8 (dxf 8 ent)))) );layer
 (if (setq val (dxf 62 ent));color
   (setq ds (append ds (list (cons 62 val))) )
   )
 (if (setq val (dxf 6 ent));line type
   (setq ds (append ds (list (cons 6 val))) )
   )
 (if (setq val (dxf 370 ent));line weight
   (setq ds (append ds (list (cons 370 val))) )
   )
 (entmake ds)
 (entdel ar)
 (princ)
)

Chào anh gia bách

Lời đầu tiên Tue_NV xin cảm ơn anh gia bách rất nhiều vì sự chia sẻ

Nếu để gán thuộc tính của arc cho circle thì mình vẫn có thể sử dụng lệnh MA được mà

(defun c:ACi(/ ar ent)
(setq ar (car(entsel "\n Chon arc :")))
(setq ent (entget ar))
(entmake (list (cons 0 "CIRCLE") (cons 10 (cdr(assoc 10 ent))) (cons 40 (cdr(assoc 40 ent)))))

(command "MATCHPROP" ar (entlast) "")
(entdel ar)
(princ)
)

Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.

Cách dùng

  1. Chép mã nguồn, lưu thành tệp 60808_aci.lsp.
  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 ACI để chạy lisp.

Mã nguồn 60808_aci.lsp (trích từ bài viết gốc)

(defun c:AtC(/ ar ent ds val); Arc to Circle
 (defun dxf(id ent) (cdr (assoc id ent)) )

 (setq ar (car(entsel "\n Chon arc :")))
 (setq ent (entget ar)
ds (list (cons 0 "CIRCLE") (cons 10 (dxf 10 ent)) (cons 40 (dxf 40 ent)) ))
 (setq ds (append ds (list (cons 8 (dxf 8 ent)))) );layer
 (if (setq val (dxf 62 ent));color
   (setq ds (append ds (list (cons 62 val))) )
   )
 (if (setq val (dxf 6 ent));line type
   (setq ds (append ds (list (cons 6 val))) )
   )
 (if (setq val (dxf 370 ent));line weight
   (setq ds (append ds (list (cons 370 val))) )
   )
 (entmake ds)
 (entdel ar)
 (princ)
)

(defun c:ACi(/ ar ent)
(setq ar (car(entsel "\n Chon arc :")))
(setq ent (entget ar))
(entmake (list (cons 0 "CIRCLE") (cons 10 (cdr(assoc 10 ent))) (cons 40 (cdr(assoc 40 ent)))))

(command "MATCHPROP" ar (entlast) "")
(entdel ar)
(princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Kéo cung tròn thành đường tròn?. Xem đúng bài viết #60808 để đọc hướng dẫn và trao đổi thêm.

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