Chuyển đến nội dung
Diễn đàn CADViet
Đăng nhập để thực hiện theo  
cuongkhan

[Hỏi] Lỗi khi sử dụng lisp vẽ cửa sổ

Các bài được khuyến nghị

tôi gặp phải lỗi này khi sử dụng file vẽ cửa sổ = second point :; error: bad argument type: lentityp nil

và file vẽ cửa đi = Hay vao huong cua: ; error: no function definition: L3D_KHONGTHANGHANG

xin hướng dẫn cách khắc phục

Nội dung lisp:

(defun c:w1(/ data_m l1 l2 p1 p2 check)

(defun wd_import(/ p3 p4 p5 p6)
(setq data_m (ssget))
(setq p1 (getpoint "\nfirst point :") p2 (getpoint "\nsecond point :"))
(setq l1 nil l2 nil check 1)
(if (not (= nil data_m)) (progn
(setq l1 (entget (ssname data_m 0)))
(setq l2 (entget (ssname data_m 1)))
(if (or (= nil l1) (not (= "LINE" (cdr (assoc 0 l1))))) (setq check 0))
(if (or (= nil l2) (not (= "LINE" (cdr (assoc 0 l2))))) (setq check 0))
(if (not (= 0 (-(sslength data_m) 2))) (setq check 0))
(if (= 1 check) (progn
(setq p3 (cdr (assoc 10 l1))) (setq p3 (list (nth 0 p3) (nth 1 p3)))
(setq p4 (cdr (assoc 11 l1))) (setq p4 (list (nth 0 p4) (nth 1 p4)))
(setq p5 (cdr (assoc 10 l2))) (setq p5 (list (nth 0 p5) (nth 1 p5)))
(setq p6 (cdr (assoc 11 l2))) (setq p6 (list (nth 0 p6) (nth 1 p6)))
(if (not (= nil (inters p3 p4 p5 p6 nil))) (setq check 0))
))
) (setq check 0))
(princ)
)

(defun wd_procced()

(defun mkv(/ p3 p4 p5 p6 p7 p8 p9 ls1 ls2 getom ll1)

(setq p3 (cdr (assoc 10 l1)))
(setq p4 (cdr (assoc 11 l1)))
(setq p5 (cdr (assoc 10 l2)))
(setq p6 (cdr (assoc 11 l2)))
(if (> (abs (- (nth 1 p1) (nth 1 p3)))
(abs (- (nth 1 p3) (nth 1 p4))) ) (setq check 0))
(if (> (abs (- (nth 1 p1) (nth 1 p4)))
(abs (- (nth 1 p3) (nth 1 p4))) ) (setq check 0))
(if (> (abs (- (nth 1 p2) (nth 1 p5)))
(abs (- (nth 1 p5) (nth 1 p6))) ) (setq check 0))
(if (> (abs (- (nth 1 p2) (nth 1 p6)))
(abs (- (nth 1 p5) (nth 1 p6))) ) (setq check 0))
(if (= 0 check) (princ "\ninvalid data") (progn
(setq ls1 (arlst (list (nth 1 p1) (nth 1 p2) (nth 1 p3) (nth 1 p4) )))
; (princ ls1)
(setq p7 (list (nth 0 p3) (nth 0 ls1) 0))
(setq p8 (list (nth 0 p3) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p3) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p3) (nth 3 ls1) 0))
(mkline p7 p8 l1)

(setq ls1 (arlst (list (nth 1 p1) (nth 1 p2) (nth 1 p5) (nth 1 p6) )))
; (princ ls1)
(setq p7 (list (nth 0 p5) (nth 0 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p5) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 3 ls1) 0))
(mkline p7 p8 l1)

(setq p7 (list (nth 0 p3) (nth 1 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p3) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 2 ls1) 0))
(mkline p7 p8 l1)

(setq getom (getvar "osmode"))
(setvar "osmode" 0)

(setq ls2 (arlst (list (nth 0 p3) (nth 0 p5))))
(setq p7 (list (nth 0 ls2) (nth 1 ls1) 0))
(setq p8 (list (nth 1 ls2) (nth 2 ls1) 0))

(setq ll1 (list
(cons 0 "line")
(cons 8 (getvar "clayer"))
))

(drawrt2 p7 p8 ll1)

(setvar "osmode" getom)
(command "erase" data_m "")

))
(princ)
)

(defun mkh(/ p3 p4 p5 p6 p7 p8 p9 ls1 ls2 getom ll1)

(setq p3 (cdr (assoc 10 l1)))
(setq p4 (cdr (assoc 11 l1)))
(setq p5 (cdr (assoc 10 l2)))
(setq p6 (cdr (assoc 11 l2)))

(if (> (abs (- (nth 0 p1) (nth 0 p3)))
(abs (- (nth 0 p3) (nth 0 p4))) ) (setq check 0))
(if (> (abs (- (nth 0 p1) (nth 0 p4)))
(abs (- (nth 0 p3) (nth 0 p4))) ) (setq check 0))
(if (> (abs (- (nth 0 p2) (nth 0 p5)))
(abs (- (nth 0 p5) (nth 0 p6))) ) (setq check 0))
(if (> (abs (- (nth 0 p2) (nth 0 p6)))
(abs (- (nth 0 p5) (nth 0 p6))) ) (setq check 0))

(if (= 0 check) (princ "\ninvalid data") (progn

(setq ls1 (arlst (list (nth 0 p1) (nth 0 p2) (nth 0 p3) (nth 0 p4) )))
; (princ ls1)
(setq p7 (list (nth 0 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p3) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 3 ls1) (nth 1 p3) 0))
(mkline p7 p8 l1)

(setq ls1 (arlst (list (nth 0 p1) (nth 0 p2) (nth 0 p5) (nth 0 p6) )))
; (princ ls1)
(setq p7 (list (nth 0 ls1) (nth 1 p5) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p5) 0))
(setq p8 (list (nth 3 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)

(setq p7 (list (nth 1 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 2 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)

(setq getom (getvar "osmode"))
(setvar "osmode" 0)

(setq ls2 (arlst (list (nth 1 p3) (nth 1 p5))))
(setq p7 (list (nth 1 ls1) (nth 0 ls2) 0))
(setq p8 (list (nth 2 ls1) (nth 1 ls2) 0))

(setq ll1 (list
(cons 0 "line")
(cons 8 (getvar "clayer"))
))

(drawrt3 p7 p8 ll1)

(setvar "osmode" getom)
(command "erase" data_m "")


))
(princ)
)

(setvar "cmdecho" 0) (command "undo" "mark") (setvar "cmdecho" 1)
(if (= 0 check) (princ "\ninvalid data") (progn
(if (< (abs (- (nth 0 (cdr (assoc 10 l1)))
(nth 0 (cdr (assoc 11 l1))) )) 0.00001) (mkv))
(if (< (abs (- (nth 1 (cdr (assoc 10 l1)))
(nth 1 (cdr (assoc 11 l1))) )) 0.00001) (mkh))


))

(princ)

)
(wd_import)
(ai_undo_push)
(wd_procced)
(ai_undo_pop)
)


(defun c:w2(/ data_m l1 l2 p1 p2 check)

(defun wd_import(/ p3 p4 p5 p6)
(setq data_m (ssget))
(setq p1 (getpoint "\nfirst point :") p2 (getpoint "\nsecond point :"))
(setq l1 nil l2 nil check 1)
(if (not (= nil data_m)) (progn
(setq l1 (entget (ssname data_m 0)))
(setq l2 (entget (ssname data_m 1)))
(if (or (= nil l1) (not (= "LINE" (cdr (assoc 0 l1))))) (setq check 0))
(if (or (= nil l2) (not (= "LINE" (cdr (assoc 0 l2))))) (setq check 0))
(if (not (= 0 (-(sslength data_m) 2))) (setq check 0))
(if (= 1 check) (progn
(setq p3 (cdr (assoc 10 l1))) (setq p3 (list (nth 0 p3) (nth 1 p3)))
(setq p4 (cdr (assoc 11 l1))) (setq p4 (list (nth 0 p4) (nth 1 p4)))
(setq p5 (cdr (assoc 10 l2))) (setq p5 (list (nth 0 p5) (nth 1 p5)))
(setq p6 (cdr (assoc 11 l2))) (setq p6 (list (nth 0 p6) (nth 1 p6)))
(if (not (= nil (inters p3 p4 p5 p6 nil))) (setq check 0))
))
) (setq check 0))
(princ)
)

(defun wd_procced()

(defun mkv(/ p3 p4 p5 p6 p7 p8 p9 ls1 ls2 getom ll1)

(setq p3 (cdr (assoc 10 l1)))
(setq p4 (cdr (assoc 11 l1)))
(setq p5 (cdr (assoc 10 l2)))
(setq p6 (cdr (assoc 11 l2)))
(if (> (abs (- (nth 1 p1) (nth 1 p3)))
(abs (- (nth 1 p3) (nth 1 p4))) ) (setq check 0))
(if (> (abs (- (nth 1 p1) (nth 1 p4)))
(abs (- (nth 1 p3) (nth 1 p4))) ) (setq check 0))
(if (> (abs (- (nth 1 p2) (nth 1 p5)))
(abs (- (nth 1 p5) (nth 1 p6))) ) (setq check 0))
(if (> (abs (- (nth 1 p2) (nth 1 p6)))
(abs (- (nth 1 p5) (nth 1 p6))) ) (setq check 0))
(if (= 0 check) (princ "\ninvalid data") (progn
(setq ls1 (arlst (list (nth 1 p1) (nth 1 p2) (nth 1 p3) (nth 1 p4) )))
; (princ ls1)
(setq p7 (list (nth 0 p3) (nth 0 ls1) 0))
(setq p8 (list (nth 0 p3) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p3) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p3) (nth 3 ls1) 0))
(mkline p7 p8 l1)

(setq ls1 (arlst (list (nth 1 p1) (nth 1 p2) (nth 1 p5) (nth 1 p6) )))
; (princ ls1)
(setq p7 (list (nth 0 p5) (nth 0 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p5) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 3 ls1) 0))
(mkline p7 p8 l1)

(setq p7 (list (nth 0 p3) (nth 1 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 1 ls1) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 0 p3) (nth 2 ls1) 0))
(setq p8 (list (nth 0 p5) (nth 2 ls1) 0))
(mkline p7 p8 l1)

(setq ls2 (arlst (list (nth 0 p3) (nth 0 p5))))

(setq ll1 (list
(cons 0 "line")
(cons 8 (getvar "clayer"))
))

(if (< (nth 0 p1) (nth 0 ls2)) (progn
(setq p7 (list (nth 0 ls2) (nth 1 ls1) 0))
(setq p8 (list (nth 1 ls2) (nth 2 ls1) 0))
(setq p7 (list (* (+ (nth 0 p7) (nth 0 p8)) 0.5) (nth 1 p7) 0))
(drawrt2 p7 p8 ll1)

(setq p7 (list (- (nth 0 ls2) 70) (- (nth 1 ls1) 100) 0))
(setq p8 (list (- (nth 0 ls2) 70) (+ (nth 2 ls1) 100) 0))
(mkline p7 p8 ll1)

(setq p9 (list (+ (nth 0 p7) 70) (nth 1 p7) 0))
(mkline p7 p9 ll1)

(setq p9 (list (+ (nth 0 p8) 70) (nth 1 p8) 0))
(mkline p8 p9 ll1)
)(progn
(setq p7 (list (nth 0 ls2) (nth 1 ls1) 0))
(setq p8 (list (nth 1 ls2) (nth 2 ls1) 0))
(setq p8 (list (* (+ (nth 0 p7) (nth 0 p8)) 0.5) (nth 1 p8) 0))
(drawrt2 p7 p8 ll1)

(setq p7 (list (+ (nth 1 ls2) 70) (- (nth 1 ls1) 100) 0))
(setq p8 (list (+ (nth 1 ls2) 70) (+ (nth 2 ls1) 100) 0))
(mkline p7 p8 ll1)

(setq p9 (list (- (nth 0 p7) 70) (nth 1 p7) 0))
(mkline p7 p9 ll1)

(setq p9 (list (- (nth 0 p8) 70) (nth 1 p8) 0))
(mkline p8 p9 ll1)
))


(command "erase" data_m "")

))
(princ)
)

(defun mkh(/ p3 p4 p5 p6 p7 p8 p9 ls1 ls2 getom ll1)

(setq p3 (cdr (assoc 10 l1)))
(setq p4 (cdr (assoc 11 l1)))
(setq p5 (cdr (assoc 10 l2)))
(setq p6 (cdr (assoc 11 l2)))

(if (> (abs (- (nth 0 p1) (nth 0 p3)))
(abs (- (nth 0 p3) (nth 0 p4))) ) (setq check 0))
(if (> (abs (- (nth 0 p1) (nth 0 p4)))
(abs (- (nth 0 p3) (nth 0 p4))) ) (setq check 0))
(if (> (abs (- (nth 0 p2) (nth 0 p5)))
(abs (- (nth 0 p5) (nth 0 p6))) ) (setq check 0))
(if (> (abs (- (nth 0 p2) (nth 0 p6)))
(abs (- (nth 0 p5) (nth 0 p6))) ) (setq check 0))

(if (= 0 check) (princ "\ninvalid data") (progn

(setq ls1 (arlst (list (nth 0 p1) (nth 0 p2) (nth 0 p3) (nth 0 p4) )))
; (princ ls1)
(setq p7 (list (nth 0 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p3) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 3 ls1) (nth 1 p3) 0))
(mkline p7 p8 l1)

(setq ls1 (arlst (list (nth 0 p1) (nth 0 p2) (nth 0 p5) (nth 0 p6) )))
; (princ ls1)
(setq p7 (list (nth 0 ls1) (nth 1 p5) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p5) 0))
(setq p8 (list (nth 3 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)

(setq p7 (list (nth 1 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 1 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)
(setq p7 (list (nth 2 ls1) (nth 1 p3) 0))
(setq p8 (list (nth 2 ls1) (nth 1 p5) 0))
(mkline p7 p8 l1)

(setq getom (getvar "osmode"))
(setvar "osmode" 0)

(setq ll1 (list
(cons 0 "line")
(cons 8 (getvar "clayer"))
))
(setq ls2 (arlst (list (nth 1 p3) (nth 1 p5))))
;(princ ls2)

(if (> (nth 1 p1) (nth 1 ls2)) (progn

(setq p7 (list (nth 1 ls1) (nth 0 ls2) 0))
(setq p8 (list (nth 2 ls1) (nth 1 ls2) 0))
(setq p8 (list (nth 2 ls1) (* (+ (nth 1 p7) (nth 1 p8)) 0.5) 0))

(drawrt3 p7 p8 ll1)

(setq p7 (list (- (nth 1 ls1) 100) (+ (nth 1 ls2) 70) 0))
(setq p8 (list (+ (nth 2 ls1) 100) (+ (nth 1 ls2) 70) 0))
(mkline p7 p8 ll1)

(setq p9 (list (nth 0 p7) (- (nth 1 p7) 70) 0))
(mkline p7 p9 ll1)

(setq p9 (list (nth 0 p8) (- (nth 1 p8) 70) 0))
(mkline p8 p9 ll1)
)(progn
(setq p7 (list (nth 1 ls1) (nth 0 ls2) 0))
(setq p8 (list (nth 2 ls1) (nth 1 ls2) 0))
(setq p7 (list (nth 1 ls1) (* (+ (nth 1 p7) (nth 1 p8)) 0.5) 0))

(drawrt3 p7 p8 ll1)


(setq p7 (list (- (nth 1 ls1) 100) (- (nth 0 ls2) 70) 0))
(setq p8 (list (+ (nth 2 ls1) 100) (- (nth 0 ls2) 70) 0))
(mkline p7 p8 ll1)

(setq p9 (list (nth 0 p7) (+ (nth 1 p7) 70) 0))
(mkline p7 p9 ll1)

(setq p9 (list (nth 0 p8) (+ (nth 1 p8) 70) 0))
(mkline p8 p9 ll1)


))

(setvar "osmode" getom)

(command "erase" data_m "")


))
(princ)
)

(setvar "cmdecho" 0) (command "undo" "mark") (setvar "cmdecho" 1)
(if (= 0 check) (princ "\ninvalid data") (progn
(if (< (abs (- (nth 0 (cdr (assoc 10 l1)))
(nth 0 (cdr (assoc 11 l1))) )) 0.00001) (mkv))
(if (< (abs (- (nth 1 (cdr (assoc 10 l1)))
(nth 1 (cdr (assoc 11 l1))) )) 0.00001) (mkh))


))

(princ)

)
(wd_import)
(wd_procced)
)

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

tôi gặp phải lỗi này khi sử dụng file vẽ cửa sổ = second point :; error: bad argument type: lentityp nil

và file vẽ cửa đi = Hay vao huong cua: ; error: no function definition: L3D_KHONGTHANGHANG

xin hướng dẫn cách khắc phục

Nội dung lisp:


Hề hề hề,

Mình đã chạy thử cái lisp của bạn thì chả thấy nó có lỗi gì cả. Có điều chắc là lisp này bạn viết riêng cho bạn dùng nên mình chả biết cách dùng, cứ chạy liều mà thôi. Khi lísp yêu cầu chọn tập đối tượng thì mình chọn bừa một nhóm đối tượng bất kỳ, còn lúc lisp bảo chọn điểm mình cũng làm liếu như vậy nên kết quả là lísp in ra dòng chữ invalid data đúng như cái yêu cầu khi biến check = 0.

Làm sao để có biến check = 1 thì mình chưa mò được, vì thế chả biết khi đó lisp nó chạy ra răng nữa.....

Đọc qua cái lisp bạn gửi thì thấy có một số hàm mà mình chưa biết nó nằm chỗ mô, rất mong bạn chỉ giáo thêm:

1/- (ai_undo_push)

2/- (ai_undo_pop)

3/- (drawrt3 p7 p8 ll1)

4/- (arlst (list (nth 1 p3) (nth 1 p5)))

5/- (mkline p7 p8 l1)

Mình đã kiếm tìm trong help của CAD mà hổng thấy nên cũng chưa hiểu tác dụnbg của mấy cái hàm đó để mần chi.

 

Rất mong bạn kiểm tra lại và giải thích giùm.....

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

Tạo một tài khoản hoặc đăng nhập để nhận xét

Bạn cần phải là một thành viên để lại một bình luận

Tạo tài khoản

Đăng ký một tài khoản mới trong cộng đồng của chúng tôi. Điều đó dễ mà.

Đăng ký tài khoản mới

Đăng nhập

Bạn có sẵn sàng để tạo một tài khoản ? Đăng nhập tại đây.

Đăng nhập ngay
Đăng nhập để thực hiện theo  

×