Về vấn đề lisp hatch nhanh
28 phút trước, mr.thanh2610 đã nói:Mình không hiểu code lắm nên hỏi anh em để chỉnh đơn vị bên lisp là độ trùng với đơn vị bên bản vẽ ấy mà, chứ mỗi lần chỉnh góc là phải quy đổi
Sửa lại cho bạn nhập góc theo độ nhé:
(defun c:SF(/ p dt ans ten sc dt angrad)
(setvar "cmdecho" 0)
(initget "B B1 B2 BK G GD GD1 GL GL1 GL2 D D1 C K N N1 TO GO GO1")
(setq ans (getkword "\n Chon kieu hatch < B/B1/B2/BK/G/GD/GD1/GL/GL1/GL2/D/D1/C/K/N/N1/TO/GO/GO1 > : "))
(or (and ang (or (= (type ang) 'int) (= (type ang) 'real))) (setq ang 0.00))
(setq ang (cond ((getreal (strcat "\nNhap goc theo do <" (rtos ang 2 2) ">: "))) (ang)))
(setq angrad (*(/ ang 180) pi))
(if (= ans "B")
(progn
(setq ten "AR-CONC" sc 20.0
ten2 "ANSI32" sc2 200.0)
)
)
(if (= ans "B1")
(progn
(setq ten "AR-CONC" sc 20.0)
)
)
(if (= ans "B2")
(progn
(setq ten "GRAVEL" sc 100.0)
)
)
(if (= ans "BK")
(progn
(setq ten "SOLID" sc 200.0)
)
)
(if (= ans "G")
(progn
(setq ten "ANSI31" sc 400.0)
)
)
(if (= ans "GD")
(progn
(setq ten "AR-B816" sc 10.0)
)
)
(if (= ans "GD1")
(progn
(setq ten "FLGSTONE" sc 500.0)
)
)
(if (= ans "GL")
(progn
(setq ten "NET" sc 1500.0)
)
)
(if (= ans "GL1")
(progn
(setq ten "ANGLE" sc 700.0)
)
)
(if (= ans "GL2")
(progn
(setq ten "AR-HBONE" sc 20.0)
)
)
(if (= ans "D")
(progn
(setq ten "HOUND" sc 500.0)
)
)
(if (= ans "D1")
(progn
(setq ten "EARTH" sc 500.0)
)
)
(if (= ans "C")
(progn
(setq ten "AR-SAND" sc 20.0)
)
)
(if (= ans "K")
(progn
(setq ten "AR-RROOF" sc 500.0)
)
)
(if (= ans "N")
(progn
(setq ten "AR-RSHKE" sc 30.0)
)
)
(if (= ans "N1")
(progn
(setq ten "SPANTILE" sc 400.0)
)
)
(if (= ans "TO")
(progn
(setq ten "ANSI32" sc 200.0)
)
)
(if (= ans "GO")
(progn
(setq ten "WOOD8" sc 700.0)
)
)
(if (= ans "GO1")
(progn
(setq ten "WOOD2" sc 500.0)
)
)
(setvar "hpname" ten)
(setvar "hpscale" sc)
(setvar "hpang" angrad)
(initdia)
(command "hatch")
(while (< 0 (getvar "CMDACTIVE"))
(command pause)
)
(princ)
)
- Tải lisp
- 437360_sf.lsp
Cách dùng
- Tải tệp 437360_sf.lsp về máy.
- 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 SF để chạy lisp.
Mã nguồn 437360_sf.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/176415-nh%E1%BB%9D-ch%E1%BB%89nh-s%E1%BB%ADa-v%E1%BB%81-v%E1%BA%A5n-%C4%91%E1%BB%81-lisp-hatch-nhanh/
(defun c:SF(/ p dt ans ten sc dt angrad)
(setvar "cmdecho" 0)
(initget "B B1 B2 BK G GD GD1 GL GL1 GL2 D D1 C K N N1 TO GO GO1")
(setq ans (getkword "\n Chon kieu hatch < B/B1/B2/BK/G/GD/GD1/GL/GL1/GL2/D/D1/C/K/N/N1/TO/GO/GO1 > : "))
(or (and ang (or (= (type ang) 'int) (= (type ang) 'real))) (setq ang 0.00))
(setq ang (cond ((getreal (strcat "\nNhap goc theo do <" (rtos ang 2 2) ">: "))) (ang)))
(setq angrad (*(/ ang 180) pi))
(if (= ans "B")
(progn
(setq ten "AR-CONC" sc 20.0
ten2 "ANSI32" sc2 200.0)
)
)
(if (= ans "B1")
(progn
(setq ten "AR-CONC" sc 20.0)
)
)
(if (= ans "B2")
(progn
(setq ten "GRAVEL" sc 100.0)
)
)
(if (= ans "BK")
(progn
(setq ten "SOLID" sc 200.0)
)
)
(if (= ans "G")
(progn
(setq ten "ANSI31" sc 400.0)
)
)
(if (= ans "GD")
(progn
(setq ten "AR-B816" sc 10.0)
)
)
(if (= ans "GD1")
(progn
(setq ten "FLGSTONE" sc 500.0)
)
)
(if (= ans "GL")
(progn
(setq ten "NET" sc 1500.0)
)
)
(if (= ans "GL1")
(progn
(setq ten "ANGLE" sc 700.0)
)
)
(if (= ans "GL2")
(progn
(setq ten "AR-HBONE" sc 20.0)
)
)
(if (= ans "D")
(progn
(setq ten "HOUND" sc 500.0)
)
)
(if (= ans "D1")
(progn
(setq ten "EARTH" sc 500.0)
)
)
(if (= ans "C")
(progn
(setq ten "AR-SAND" sc 20.0)
)
)
(if (= ans "K")
(progn
(setq ten "AR-RROOF" sc 500.0)
)
)
(if (= ans "N")
(progn
(setq ten "AR-RSHKE" sc 30.0)
)
)
(if (= ans "N1")
(progn
(setq ten "SPANTILE" sc 400.0)
)
)
(if (= ans "TO")
(progn
(setq ten "ANSI32" sc 200.0)
)
)
(if (= ans "GO")
(progn
(setq ten "WOOD8" sc 700.0)
)
)
(if (= ans "GO1")
(progn
(setq ten "WOOD2" sc 500.0)
)
)
(setvar "hpname" ten)
(setvar "hpscale" sc)
(setvar "hpang" angrad)
(initdia)
(command "hatch")
(while (< 0 (getvar "CMDACTIVE"))
(command pause)
)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [NHỜ CHỈNH SỬA] Về vấn đề lisp hatch nhanh. Xem đúng bài viết #437360 để đọc hướng dẫn và trao đổi thêm.