Lisp lệnh EDD trong chủ đề “Hỏi về Lisp (thuật toán, ý tưởng, coding,...)”
Mình làm lisp như sau:
Để sửa các đối tượng là text, att trong block thuộc tính, giá trị dim.
Nhưng ko biết sai chổ nào mà dim không tài nào sửa được.
Các bác xoi giúp với. Cám ơn!
(defun duy:docgt (/ dchon) (setq dchon (car (nentselp "\nChon"))) (while (or (null dchon) (and (= (cdr (assoc 1 (entget dchon))) nil) ) ) (princ "\nDoi tuong khong hop le") (setq dchon (car (nentselp "\nChon"))) ) dchon) (defun c:edd (/ doituong noidung suathanh DTMs) (command "undo" "be") (setq doituong (duy:docgt)) (setq noidung (cdr (assoc 1 (entget doituong)))) (setq suathanh (lisped noidung)) (setq DTMs (subst (cons 1 suathanh) (assoc 1 (entget doituong)) (entget doituong))) (entmod DTMs) (command ".move" doituong "" "_non" (list 0 0 0) "_non" (list 0 0 0)) (command "undo" "end") (princ) )
Em Xơi giúp anh đây : (né dùng vl....) :lol:
(defun duy:docgt (/ dchon) (setq dchon (nentselp "\nChon")) (if (eq (type (car(last dchon))) 'ENAME) (setq dchon (car (last dchon))) (setq dchon (car dchon)) ) (while (or (null dchon) (and (= (cdr (assoc 1 (entget dchon))) nil) ) ) (princ "\nDoi tuong khong hop le") (setq dchon (nentselp "\nChon")) (if (eq (type (car(last dchon))) 'ENAME) (setq dchon (car (last dchon))) (setq dchon (car dchon)) ) ) dchon ) ;;;;; (defun c:edd (/ doituong noidung suathanh DTMs) (command "undo" "be") (setq doituong (duy:docgt)) (setq noidung (cdr (assoc 1 (entget doituong)))) (setq suathanh (lisped noidung)) (setq DTMs (subst (cons 1 suathanh) (assoc 1 (entget doituong)) (entget doituong))) (entmod DTMs) (command ".move" doituong "" "_non" (list 0 0 0) "_non" (list 0 0 0)) (command "undo" "end") (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
- Chép mã nguồn, lưu thành tệp 232217_edd.lsp.
- 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ẽ.
- Gõ lệnh EDD để chạy lisp.
Mã nguồn 232217_edd.lsp (trích từ bài viết gốc)
(defun duy:docgt (/ dchon)
(setq dchon (car (nentselp "\nChon")))
(while
(or
(null dchon)
(and (= (cdr (assoc 1 (entget dchon))) nil)
)
)
(princ "\nDoi tuong khong hop le")
(setq dchon (car (nentselp "\nChon")))
)
dchon)
(defun c:edd (/ doituong noidung suathanh DTMs)
(command "undo" "be")
(setq doituong (duy:docgt))
(setq noidung (cdr (assoc 1 (entget doituong))))
(setq suathanh (lisped noidung))
(setq DTMs (subst (cons 1 suathanh) (assoc 1 (entget doituong)) (entget doituong)))
(entmod DTMs)
(command ".move" doituong "" "_non" (list 0 0 0) "_non" (list 0 0 0))
(command "undo" "end")
(princ)
)
(defun duy:docgt (/ dchon)
(setq dchon (nentselp "\nChon"))
(if (eq (type (car(last dchon))) 'ENAME) (setq dchon (car (last dchon))) (setq dchon (car dchon)) )
(while
(or
(null dchon)
(and (= (cdr (assoc 1 (entget dchon))) nil)
)
)
(princ "\nDoi tuong khong hop le")
(setq dchon (nentselp "\nChon"))
(if (eq (type (car(last dchon))) 'ENAME) (setq dchon (car (last dchon))) (setq dchon (car dchon)) )
)
dchon
)
;;;;;
(defun c:edd (/ doituong noidung suathanh DTMs)
(command "undo" "be")
(setq doituong (duy:docgt))
(setq noidung (cdr (assoc 1 (entget doituong))))
(setq suathanh (lisped noidung))
(setq DTMs (subst (cons 1 suathanh) (assoc 1 (entget doituong)) (entget doituong)))
(entmod DTMs)
(command ".move" doituong "" "_non" (list 0 0 0) "_non" (list 0 0 0))
(command "undo" "end")
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Hỏi về Lisp (thuật toán, ý tưởng, coding,...). Xem đúng bài viết #232217 để đọc hướng dẫn và trao đổi thêm.