Jump to content

nhờ làm lisp vẽ tường....

THử cái này xem (mình chưa thử với xline nhưng arc, circle, plinespline thì đc)

(Defun c:o2 ()
(vl-load-com)
(command "undo" "be")

(if (= droff nil)
(setq droff1 2.00)
(setq droff1 droff)
)
(setq
droff (GETREAL (strcat "\nNhap do rong offset: <" (rtos droff1 2 2) ">"))
)
(if (= droff nil)
(setq droff droff1)
)



(setq SS (ssget (list (cons 0 "ellipse,lwpolyline,spline,line,circle"))))
(setq i 0)
(setq N (sslength ss))
(while (< i N)
(setq TEXTENT (ssname SS i))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)

(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0))
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01))
(setq goc (angle diemchuan diemdinhhuong))
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) droff))
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) droff))

(command ".offset" droff textent diembentrai textent diembenphai "")

(setq i (1+ i))
(setvar "osmode" luubatdiem)
)

(command "undo" "end")
(princ)
)  

sửa cái code

(setq SS (ssget (list (cons 0 "ellipse,lwpolyline,spline,line,circle"))))

thêm cái xline là được

 

(setq SS (ssget (list (cons 0 "ellipse,lwpolyline,spline,line,xline,circle"))))

 

 

thank bạn nhé :D

Cách dùng

  1. Tải tệp 183816_o2.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 O2 để chạy lisp.

Mã nguồn 183816_o2.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/60339-y%C3%AAu-c%E1%BA%A7u-nh%E1%BB%9D-l%C3%A0m-lisp-v%E1%BA%BD-t%C6%B0%E1%BB%9Dng/
(Defun c:o2 ()
(vl-load-com)
(command "undo" "be")

(if (= droff nil)
(setq droff1 2.00)
(setq droff1 droff)
)
(setq
droff (GETREAL (strcat "\nNhap do rong offset: <" (rtos droff1 2 2) ">"))
)
(if (= droff nil)
(setq droff droff1)
)



(setq SS (ssget (list (cons 0 "ellipse,lwpolyline,spline,line,circle"))))
(setq i 0)
(setq N (sslength ss))
(while (< i N)
(setq TEXTENT (ssname SS i))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)

(setq diemchuan (vlax-curve-getPointAtDist TEXTENT 0))
(setq diemdinhhuong (vlax-curve-getPointAtDist TEXTENT 0.01))
(setq goc (angle diemchuan diemdinhhuong))
(setq diembentrai (polar diemchuan (- goc (/ pi 2)) droff))
(setq diembenphai (polar diemchuan (+ goc (/ pi 2)) droff))

(command ".offset" droff textent diembentrai textent diembenphai "")

(setq i (1+ i))
(setvar "osmode" luubatdiem)
)

(command "undo" "end")
(princ)
)  

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Yêu cầu] nhờ làm lisp vẽ tường..... Xem đúng bài viết #183816 để đọc hướng dẫn và trao đổi thêm.

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