Jump to content
InfoFile
Tác giả: ketxu
Bài viết gốc: 282390
Tên lệnh: dlp dls alp als
Lisp thêm tiền tố vào tên của hàng loạt layer

Nếu bạn k thích kiểu Old - New thì dùng tạm cái này < search nhanh cho bạn trên mạng - K có copyright - không viết >

 

(defun c:DLP ( / p x n ) (vl-load-com)
  (if (< 1 (setq x (strlen (setq p (strcat (strcase (getstring t "\nSpecify Prefix: ")) "*")))))
    (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
      (if (wcmatch (strcase (setq n (vla-get-name l))) p)
       ...
>>

Nếu bạn k thích kiểu Old - New thì dùng tạm cái này < search nhanh cho bạn trên mạng - K có copyright - không viết >

 

(defun c:DLP ( / p x n ) (vl-load-com)
  (if (< 1 (setq x (strlen (setq p (strcat (strcase (getstring t "\nSpecify Prefix: ")) "*")))))
    (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
      (if (wcmatch (strcase (setq n (vla-get-name l))) p)
        (vl-catch-all-apply 'vla-put-name (list l (substr n x)))
      )
    )
  )
  (princ)
)

(defun c:DLS ( / s x n ) (vl-load-com)
  (if (< 1 (setq x (strlen (setq s (strcat "*" (strcase (getstring t "\nSpecify Suffix: ")))))))
    (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
      (if (wcmatch (strcase (setq n (vla-get-name l))) s)
        (vl-catch-all-apply 'vla-put-name (list l (substr n 1 (- (strlen n) x -1))))
      )
    )
  )
  (princ)
)

(defun c:ALP ( / p w n ) (vl-load-com)
  (setq p (getstring t "\nSpecify Prefix: ") w (strcat (strcase p) "*"))
  (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (if (not (wcmatch (strcase (setq n (vla-get-name l))) w))
      (vl-catch-all-apply 'vla-put-name (list l (strcat p n)))
    )
  )
  (princ)
)

(defun c:ALS ( / s w n ) (vl-load-com)
  (setq s (getstring t "\nSpecify Suffix: ") w (strcat "*" (strcase s)))
  (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (if (not (wcmatch (strcase (setq n (vla-get-name l))) w))
      (vl-catch-all-apply 'vla-put-name (list l (strcat n s)))
    )
  )
  (princ)
)

Có 4 thằng : thêm trước (ALP), thêm sau (ALS), xóa trước (DLP), xóa sau (DLS)


<<

Filename: 282390_dlp_dls_alp_als.lsp
Tác giả: phamngoctukts
Bài viết gốc: 120652
Tên lệnh: gct
Viết lisp theo yêu cầu [phần 2]


Chào bạn hugo75!
Xin lỗi bạn tại mình chưa test thử nhiều lần nên mới bị vậy. Mình sửa cho bạn đây. Bạn muốn cái đường tròn liền với cái pline thì quả thực rất khó. Có lẽ chỉ có thể dùng qleader để mình nghiên cứu tiếp cho bạn. trong khi chờ đợi bạn dùng tạm cái này mình đã sửa lỗi trên rồi.

Filename: 120652_gct.lsp
Tác giả: hiepttr
Bài viết gốc: 282861
Tên lệnh: mp
Xin giúp lấy lại cao độ trong Nova

Tạm thế này đã

Bạn thử xem, nếu vướng chổ nào thì làm tiếp

 

Lisp tạo point:

(defun c:mp( / ss sl i x y z int_pt)
;make point
(prompt "\nChon vung co text cao do: ")
(setq ss (ssget '((0 . "TEXT") (40 . 3.6)))
sl (sslength ss)
i 0
)
(while (and ss (> (sslength ss) 0))
	(cond
		((setq z (distof (cdr (assoc 1 (entget (setq ent (ssname ss 0)))))))
		(setq x (car (setq int_pt (cdr (assoc 10 (entget (setq ent...
>>

Tạm thế này đã

Bạn thử xem, nếu vướng chổ nào thì làm tiếp

 

Lisp tạo point:

(defun c:mp( / ss sl i x y z int_pt)
;make point
(prompt "\nChon vung co text cao do: ")
(setq ss (ssget '((0 . "TEXT") (40 . 3.6)))
sl (sslength ss)
i 0
)
(while (and ss (> (sslength ss) 0))
	(cond
		((setq z (distof (cdr (assoc 1 (entget (setq ent (ssname ss 0)))))))
		(setq x (car (setq int_pt (cdr (assoc 10 (entget (setq ent (ssname ss 0)))))))
			  y (cadr int_pt)
			  i (1+ i))
		(entmake (list (cons 0 "POINT") (list 10 x y z)))
		)
	)
(ssdel ent ss)
)
(princ (strcat "\nDa tao " (itoa i) " point cao do !"))
(princ)
)

<<

Filename: 282861_mp.lsp
Tác giả: VUVUZELA
Bài viết gốc: 105317
Tên lệnh: sch
Xem giúp đoạn lisp của mình vẽ pline có nhập chiều dài và góc
Đối với HATCH thì viết như bác xài hàm entmod thì nó không động đậy được
BÁc thử xài đoạn mã này xem nhé


Bon ... on ... n

Filename: 105317_sch.lsp
Tác giả: 790312
Bài viết gốc: 122057
Tên lệnh: sd
Viết lisp theo yêu cầu [phần 2]

Bác Tue_nv có viết 1 lisp vẽ thép dưới sàn rất tiện mong các bác thêm giùm e dòng lệnh trước câu " đường kính móc tròn" một lựa chọn: "Có móc hay không móc" nếu Có thì "câu đường kính móc tròn" nếu Không thì hỏi "chiều dài đoạn xéo" khi nhập rồi sẽ vẽ nhưng đoạn đầu không phải móc mà cắt thép gồm 1 đoạn thẳng có chiều dài nhập vào và xéo 1 góc 30độ.Mong các bác sửa giúp.

Filename: 122057_sd.lsp
Tác giả: hantinh
Bài viết gốc: 283464
Tên lệnh: tk
[Hỏi] cách lấy về phần nguyên của phép chia

cho minh f hỏi thêm 1 chút nữa về cách viết lsp thong ke kiêu này đã đúng chưa vậy? cái đoạn chữ màu đỏ mình mới thêm vào. hiện nó báo lỗi và mình muốn sửa nó cho có thể chạy được. tks mọi người đã đọc

;=CHUONG TRINH THONG KE COT THEP CAU KIEN
;;;Chuong trinh bat loi
(defun loitk (s)                    ; If an error (such as CTRL-C) occurs
                                      ; while this...
>>

cho minh f hỏi thêm 1 chút nữa về cách viết lsp thong ke kiêu này đã đúng chưa vậy? cái đoạn chữ màu đỏ mình mới thêm vào. hiện nó báo lỗi và mình muốn sửa nó cho có thể chạy được. tks mọi người đã đọc

;=CHUONG TRINH THONG KE COT THEP CAU KIEN
;;;Chuong trinh bat loi
(defun loitk (s)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
  (cond
    ((= s "quit / exit abort") (princ))
    ((/= s "Function cancelled") (princ (strcat "\nError: " s)))
  )
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" OSM)
(SETQ *error* OLDERR)
(princ)
)
;;;CHUONG TRINH CON NHAP DU LIEU
(princ "\nThong ke cot thep H3.0 ");
(defun gpuser()
(princ "\nTHONG KE COT THEP H 3.0 by KY SU NGUYEN XUAN MINH DHXD HANOI") 
(princ "\n      Copyright HiTech Group 2004 ENG NGUYEN XUAN MINH") 
(setq base_point(getpoint "\nBase point : "))
(setq loai      (getint   "\nLoai (0-18) : "))
)
;;;
;;;Chuong trinh con ve thep loai 0
(defun veloai0()
(princ "\nCot thep bat ky") 
(setq chieudai (getreal    "\nChieu dai  : "))
)
;;;
;;;Chuong trinh con ve thep loai 1
(defun veloai1()
(princ "\nCot thep thang") 
(setq chieudai (getreal    "\nChieu dai  : "))
(command "_PLINE" ( polar (polar base_point 0 10) (/ pi 2) 2 ) "@30,0" "") 
(command "_TEXT" "_M" "@-15,3" 0 (rtos chieudai 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 2 
(defun veloai2()
(princ "\nCot thep uon hai dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon 1 : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai3(getreal   "\nChieu dai doan uon 2 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"@0,-6"
"") 
(command "_TEXT" "_M" "@-35,3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai3 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 3 
(defun veloai3()
(princ "\nCot thep uon mot dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon   : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai ( + chieudai1 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"") 
(command "_TEXT" "_M" "@-35,-3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 4 
(defun veloai4()
(princ "\nCot thep san") 
(setq chieudai1(getreal   "\nChieu dai thep : "))
(setq chieudai2(getreal   "\nChieu dai moc  : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 12) (/ pi 2) 4 ) 
"@-2,0" 
"_A"
"@0,-2"
"_L"
"@30,0"
"_A"
"@0,2"
"_L"
"@-2,0"
"") 
(command "_TEXT" "_M" "@-33,1" 0 (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 5
(defun veloai5()
(princ "\nCot thep dai chu nhat") 
(setq chieudai1(getreal   "\nChieu cao dai : "))
(setq chieudai2(getreal   "\nChieu rong dai: "))
(setq chieudai3(getreal   "\nChieu dai moc : "))
(setq chieudai ( + chieudai1 chieudai1 chieudai2 chieudai2 chieudai3 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 5) (/ pi 2) 5 ) 
"@35,0" 
"@0,-3"
"@-30,0"
"@0,6"
"") 
(command "_TEXT" "_M" "@-5,0" 0 (rtos chieudai3 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,-3" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 6
(defun veloai6()
(princ "\nCot thep vai bo")
(setq chieudai1 (getreal   "\nChieu dai 1  :"))
(setq chieudai2 (getreal   "\nChieu dai 2  :"))
(setq chieudai3 (getreal   "\nChieu dai 3  :"))
(setq chieudai4 (getreal   "\nChieu dai 4  :"))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai4 ))
(command  "_PLINE"
( polar (polar base_point 0 10) (/ pi 2) 5 )
"@5,0"
"@3,-3"
"@14,0"
"@3,3"
"@5,0"
"")
(command "TEXT" "_R" "@-25,1.5" 0 (rtos chieudai1 2 0) )
(command "TEXT" "_R" "@0,-5.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "_M" "@10,3.5" 0 (rtos chieudai3 2 0) )
(command "TEXT" "@10,-3.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "@0,5.5" 0 (rtos chieudai4 2 0) )
) 
;;;
;;;Chuong trinh con ve thep loai 7
(defun veloai7()
(princ "\nCot thep treo moc cau")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan cong    : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai1 ))
(command "_PLINE"
(polar (polar base_point 0 16) (/ pi 2) 2 )
"@6,0"
"@0,6"
"_A"
"@3,0"
"_L"
"@0,-6"
"@6,0"
"")
(command "TEXT" "_M" "@-20,1" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@7,3" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@12,3" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M" "@6,-6" 0 (rtos chieudai1 2 0))
)
;;;Chuong trinh con ve thep loai 8
(defun veloai8 ()
(princ "\nCot thep cau thang loai 1")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai ( + chieudai1 chieudai2))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
""
)
(command "TEXT" "_R" "@-21,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "@12,-2" 0 (rtos chieudai2 2 0))
)
;;;Chuong trinh con ve loai 9
(defun veloai9 ()
(princ "\nCot thep cau thang loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
"@0,-6"
""
)
(command "TEXT" "_R" "@-21,4" 0 (rtos chieudai1 2 0))
(command "TEXT" "_C" "@15,-2" 0 (rtos chieudai2 2 0))
(command "TEXT" "@7,0" 0 (rtos chieudai3 2 0))
)
;;;
;;;Chuong trinh con ve loai 10
(defun veloai10 ()
(princ "\nCot thep cau thang loai 3")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "@13,-2" 0 (rtos chieudai3 2 0))
)
;;;Chuong trinh con ve loai 11
(defun veloai11 ()
(princ "\nCot thep cau thang loai 4")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
"@0,-7"
""
)
(command "TEXT" "_R" "@-31.5,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@16,-2" 0 (rtos chieudai3 2 0))
(command "TEXT" "@8,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 12
(defun veloai12 ()
(princ "\nCot thep cau thang loai 5")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@18,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-29.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@18,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@7.5,-2.5" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 13
(defun veloai13 ()
(princ "\nCot thep cau thang loai 6")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@10,3"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@8,-1.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "_R" "@2,5" 0 (rtos chieudai4 2 0))
(command "TEXT" "C" "@7,-2" 0 (rtos chieudai5 2 0))
)
:;;
;;;Chuong trinh con ve loai 14
(defun veloai14 ()
(princ "\nCot thep cau thang loai 7")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@20,5"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@12,-2" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 15
(defun veloai15 ()
(princ "\nCot thep cau thang loai 8")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@14,2"
"@1,2"
"@15,-2"
"@0,-2"
""
)
(command "TEXT" "_R" "@-31.5,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@7,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@6,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@14,0.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@6,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 16
(defun veloai16 ()
(princ "\nCot thep cau thang loai 9")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@6,0"
"@14,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@11,2.5" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@9,2" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M""@6,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 17
(defun veloai17 ()
(princ "\nCot thep cau thang loai 10")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0.5,5"
"@15,-4"
"@15,4"
"@0.5,-5"
""
)
(command "TEXT" "_R" "@-32,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@12,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@10,0" 0 (rtos chieudai3 2 0))
(command "TEXT" "@11,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 18
(defun veloai18 ()
(princ "\nCot thep dam loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0,0" 
"@0,5"
"@30,0"
"@0,-2.5"
"@-10,-2.5"
""
)

(command "TEXT" "_R" "@-22,2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@15,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@21,-4.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@-20,-2" 0 (rtos chieudai4 2 0))
)
;;; Chuong trinh con tinh toan thong ke
(defun thongke()
(command "_POINT" ( polar base_point 0 50))
(setq duongkinh(getreal   "\nDuong kinh : "))
(setq sothanh  (getreal   "\nSo thanh   : "))
(setq socaukien(getreal   "\nSo cau kien: <1>"))
(if socaukien null (setq socaukien 1.0))
(if (>= duongkinh 10) and (> chieudai 11700)
    (setq a (/ chieudai 11700)
	(setq cdainoi (getreal   "\nChieu dai noi chong: <30D>"))
		 (setq cdainoi 30)
		(setq chieudai (* a (* cdainoi duongkinh)))
(setq tongchd(* chieudai (* sothanh (* socaukien 0.001))))
(setq tongkhlg(* tongchd (* duongkinh (* duongkinh 0.006165375))))
(command "_TEXT" "_M" "@5,5" 0 (rtos duongkinh 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos chieudai 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos sothanh 2 0) )
(command "_TEXT" "_M" "@10,0" 0 (rtos (* sothanh socaukien) 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos tongchd 2 2) )
(command "_TEXT" "_M" "@20,0" 0 (rtos tongkhlg 2 2) )
)
;;;Chuong trinh chinh
(defun c:tk( / CMD LIM TS PLW OSM OLDERR)
(SETQ OLDERR *error*
        *error* loitk
)
(SETQ CMD (GETVAR "CMDECHO"))
(SETQ LIM (GETVAR "LIMCHECK"))
(SETQ TS (GETVAR "TEXTSIZE"))
(SETQ PLW (GETVAR "PLINEWID"))
(SETQ OSM (GETVAR "OSMODE"))
(command "SETVAR" "CMDECHO" 0 )
(command "SETVAR" "LIMCHECK" 0 )
(command "SETVAR" "TEXTSIZE" 2.5 )
(command "SETVAR" "PLINEWID" 0.5 )
(command "OSNAP" "INT")
(gpuser)
(SETVAR "OSMODE" 0)
(cond 
((= loai 0) (veloai0))
((= loai 1) (veloai1))
((= loai 2) (veloai2))
((= loai 3) (veloai3))
((= loai 4) (veloai4))
((= loai 5) (veloai5))
((= loai 6) (veloai6))
((= loai 7) (veloai7))
((= loai 8) (veloai8))
((= loai 9) (veloai9))
((= loai 10) (veloai10))
((= loai 11) (veloai11))
((= loai 12) (veloai12))
((= loai 13) (veloai13))
((= loai 14) (veloai14))
((= loai 15) (veloai15))
((= loai 16) (veloai16))
((= loai 17) (veloai17))
((= loai 18) (veloai18))
)
(thongke)
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" 15295)
(SETQ *error* OLDERR)
(princ)
)
(princ " loaded !")

<<

Filename: 283464_tk.lsp
Tác giả: hantinh
Bài viết gốc: 283635
Tên lệnh: tk
Nhờ sửa lsp thống kê thép có thêm đoạn nối chồng

Nhờ các cao thủ sửa hộ cái lsp thông kê thép này để có thêm đoạn nối chông thép với những thanh thép dài hơn 11,7m. và chiều dài đoạn nối chồng đó co thể điều chỉnh được tùy theo từng trường hợp thông kê. đoạn code màu đỏ la mình mới thêm vào nhưng nó hok chay được mong các bạn sửa giúp mình với. Tks.

>>

Nhờ các cao thủ sửa hộ cái lsp thông kê thép này để có thêm đoạn nối chông thép với những thanh thép dài hơn 11,7m. và chiều dài đoạn nối chồng đó co thể điều chỉnh được tùy theo từng trường hợp thông kê. đoạn code màu đỏ la mình mới thêm vào nhưng nó hok chay được mong các bạn sửa giúp mình với. Tks.

;==========================================================
;=CHUONG TRINH THONG KE COT THEP CAU KIEN
;;;Chuong trinh bat loi
(defun loitk (s)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
  (cond
    ((= s "quit / exit abort") (princ))
    ((/= s "Function cancelled") (princ (strcat "\nError: " s)))
  )
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" OSM)
(SETQ *error* OLDERR)
(princ)
)
;;;CHUONG TRINH CON NHAP DU LIEU
(princ "\nThong ke cot thep H3.0 ");
(defun gpuser()
(princ "\nTHONG KE COT THEP H 3.0 by KY SU NGUYEN XUAN MINH DHXD HANOI") 
(princ "\n      Copyright HiTech Group 2004 ENG NGUYEN XUAN MINH") 
(setq base_point(getpoint "\nBase point : "))
(setq loai      (getint   "\nLoai (0-18) : "))
)
;;;
;;;Chuong trinh con ve thep loai 0
(defun veloai0()
(princ "\nCot thep bat ky") 
(setq chieudai (getreal    "\nChieu dai  : "))
)
;;;
;;;Chuong trinh con ve thep loai 1
(defun veloai1()
(princ "\nCot thep thang") 
(setq chieudai (getreal    "\nChieu dai  : "))
(command "_PLINE" ( polar (polar base_point 0 10) (/ pi 2) 2 ) "@30,0" "") 
(command "_TEXT" "_M" "@-15,3" 0 (rtos chieudai 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 2 
(defun veloai2()
(princ "\nCot thep uon hai dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon 1 : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai3(getreal   "\nChieu dai doan uon 2 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"@0,-6"
"") 
(command "_TEXT" "_M" "@-35,3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai3 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 3 
(defun veloai3()
(princ "\nCot thep uon mot dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon   : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai ( + chieudai1 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"") 
(command "_TEXT" "_M" "@-35,-3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 4 
(defun veloai4()
(princ "\nCot thep san") 
(setq chieudai1(getreal   "\nChieu dai thep : "))
(setq chieudai2(getreal   "\nChieu dai moc  : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 12) (/ pi 2) 4 ) 
"@-2,0" 
"_A"
"@0,-2"
"_L"
"@30,0"
"_A"
"@0,2"
"_L"
"@-2,0"
"") 
(command "_TEXT" "_M" "@-33,1" 0 (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 5
(defun veloai5()
(princ "\nCot thep dai chu nhat") 
(setq chieudai1(getreal   "\nChieu cao dai : "))
(setq chieudai2(getreal   "\nChieu rong dai: "))
(setq chieudai3(getreal   "\nChieu dai moc : "))
(setq chieudai ( + chieudai1 chieudai1 chieudai2 chieudai2 chieudai3 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 5) (/ pi 2) 5 ) 
"@35,0" 
"@0,-3"
"@-30,0"
"@0,6"
"") 
(command "_TEXT" "_M" "@-5,0" 0 (rtos chieudai3 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,-3" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 6
(defun veloai6()
(princ "\nCot thep vai bo")
(setq chieudai1 (getreal   "\nChieu dai 1  :"))
(setq chieudai2 (getreal   "\nChieu dai 2  :"))
(setq chieudai3 (getreal   "\nChieu dai 3  :"))
(setq chieudai4 (getreal   "\nChieu dai 4  :"))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai4 ))
(command  "_PLINE"
( polar (polar base_point 0 10) (/ pi 2) 5 )
"@5,0"
"@3,-3"
"@14,0"
"@3,3"
"@5,0"
"")
(command "TEXT" "_R" "@-25,1.5" 0 (rtos chieudai1 2 0) )
(command "TEXT" "_R" "@0,-5.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "_M" "@10,3.5" 0 (rtos chieudai3 2 0) )
(command "TEXT" "@10,-3.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "@0,5.5" 0 (rtos chieudai4 2 0) )
) 
;;;
;;;Chuong trinh con ve thep loai 7
(defun veloai7()
(princ "\nCot thep treo moc cau")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan cong    : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai1 ))
(command "_PLINE"
(polar (polar base_point 0 16) (/ pi 2) 2 )
"@6,0"
"@0,6"
"_A"
"@3,0"
"_L"
"@0,-6"
"@6,0"
"")
(command "TEXT" "_M" "@-20,1" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@7,3" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@12,3" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M" "@6,-6" 0 (rtos chieudai1 2 0))
)
;;;Chuong trinh con ve thep loai 8
(defun veloai8 ()
(princ "\nCot thep cau thang loai 1")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai ( + chieudai1 chieudai2))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
""
)
(command "TEXT" "_R" "@-21,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "@12,-2" 0 (rtos chieudai2 2 0))
)
;;;Chuong trinh con ve loai 9
(defun veloai9 ()
(princ "\nCot thep cau thang loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
"@0,-6"
""
)
(command "TEXT" "_R" "@-21,4" 0 (rtos chieudai1 2 0))
(command "TEXT" "_C" "@15,-2" 0 (rtos chieudai2 2 0))
(command "TEXT" "@7,0" 0 (rtos chieudai3 2 0))
)
;;;
;;;Chuong trinh con ve loai 10
(defun veloai10 ()
(princ "\nCot thep cau thang loai 3")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "@13,-2" 0 (rtos chieudai3 2 0))
)
;;;Chuong trinh con ve loai 11
(defun veloai11 ()
(princ "\nCot thep cau thang loai 4")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
"@0,-7"
""
)
(command "TEXT" "_R" "@-31.5,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@16,-2" 0 (rtos chieudai3 2 0))
(command "TEXT" "@8,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 12
(defun veloai12 ()
(princ "\nCot thep cau thang loai 5")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@18,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-29.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@18,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@7.5,-2.5" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 13
(defun veloai13 ()
(princ "\nCot thep cau thang loai 6")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@10,3"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@8,-1.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "_R" "@2,5" 0 (rtos chieudai4 2 0))
(command "TEXT" "C" "@7,-2" 0 (rtos chieudai5 2 0))
)
:;;
;;;Chuong trinh con ve loai 14
(defun veloai14 ()
(princ "\nCot thep cau thang loai 7")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@20,5"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@12,-2" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 15
(defun veloai15 ()
(princ "\nCot thep cau thang loai 8")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@14,2"
"@1,2"
"@15,-2"
"@0,-2"
""
)
(command "TEXT" "_R" "@-31.5,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@7,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@6,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@14,0.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@6,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 16
(defun veloai16 ()
(princ "\nCot thep cau thang loai 9")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@6,0"
"@14,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@11,2.5" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@9,2" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M""@6,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 17
(defun veloai17 ()
(princ "\nCot thep cau thang loai 10")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0.5,5"
"@15,-4"
"@15,4"
"@0.5,-5"
""
)
(command "TEXT" "_R" "@-32,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@12,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@10,0" 0 (rtos chieudai3 2 0))
(command "TEXT" "@11,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 18
(defun veloai18 ()
(princ "\nCot thep dam loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0,0" 
"@0,5"
"@30,0"
"@0,-2.5"
"@-10,-2.5"
""
)

(command "TEXT" "_R" "@-22,2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@15,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@21,-4.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@-20,-2" 0 (rtos chieudai4 2 0))
)
;;; Chuong trinh con tinh toan thong ke
(defun thongke()
(command "_POINT" ( polar base_point 0 50))
(setq duongkinh(getreal   "\nDuong kinh : "))
(setq sothanh  (getreal   "\nSo thanh   : "))
(setq socaukien(getreal   "\nSo cau kien: <1>"))
(if socaukien null (setq socaukien 1.0))
  (if (>= duongkinh 10) and (> chieudai 11700)
    (setq a (/ chieudai 11700)
    (setq cdainoi (getreal   "\nChieu dai noi chong: <30D>"))
    (setq cdainoi 30)
    (setq chieudai (* a (* cdainoi duongkinh)))
(setq tongchd(* chieudai (* sothanh (* socaukien 0.001))))
(setq tongkhlg(* tongchd (* duongkinh (* duongkinh 0.006165375))))
(command "_TEXT" "_M" "@5,5" 0 (rtos duongkinh 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos chieudai 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos sothanh 2 0) )
(command "_TEXT" "_M" "@10,0" 0 (rtos (* sothanh socaukien) 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos tongchd 2 2) )
(command "_TEXT" "_M" "@20,0" 0 (rtos tongkhlg 2 2) )
)
;;;Chuong trinh chinh
(defun c:tk( / CMD LIM TS PLW OSM OLDERR)
(SETQ OLDERR *error*
        *error* loitk
)
(SETQ CMD (GETVAR "CMDECHO"))
(SETQ LIM (GETVAR "LIMCHECK"))
(SETQ TS (GETVAR "TEXTSIZE"))
(SETQ PLW (GETVAR "PLINEWID"))
(SETQ OSM (GETVAR "OSMODE"))
(command "SETVAR" "CMDECHO" 0 )
(command "SETVAR" "LIMCHECK" 0 )
(command "SETVAR" "TEXTSIZE" 2.5 )
(command "SETVAR" "PLINEWID" 0.5 )
(command "OSNAP" "INT")
(gpuser)
(SETVAR "OSMODE" 0)
(cond 
((= loai 0) (veloai0))
((= loai 1) (veloai1))
((= loai 2) (veloai2))
((= loai 3) (veloai3))
((= loai 4) (veloai4))
((= loai 5) (veloai5))
((= loai 6) (veloai6))
((= loai 7) (veloai7))
((= loai 8) (veloai8))
((= loai 9) (veloai9))
((= loai 10) (veloai10))
((= loai 11) (veloai11))
((= loai 12) (veloai12))
((= loai 13) (veloai13))
((= loai 14) (veloai14))
((= loai 15) (veloai15))
((= loai 16) (veloai16))
((= loai 17) (veloai17))
((= loai 18) (veloai18))
)
(thongke)
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" 15295)
(SETQ *error* OLDERR)
(princ)
)
(princ " loaded !")

 


<<

Filename: 283635_tk.lsp
Tác giả: ketxu
Bài viết gốc: 283748
Tên lệnh: sw
Lisp chọn nhiều đối tượng giống nhau

K biết bạn thất bại cái j, ở đâu, mình cũng thử xoá và vẫn thấy dùng bình thường. Nhớ là xoá chữ All đi rồi thì thao tác chọn sẽ làm 2 lần

 

;; free lisp from cadviet.com
;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/56306-da-xong-lisp-chon-nhieu-doi-tuong-giong-nhau/
(defun c:sw(/ aaa ls dt dt1 sdt sdt1 ent ent1 id id1)
  (setq AAA(SSGET)
sdt (sslength AAA)
id 0
dt (ssadd)
)
...
>>

K biết bạn thất bại cái j, ở đâu, mình cũng thử xoá và vẫn thấy dùng bình thường. Nhớ là xoá chữ All đi rồi thì thao tác chọn sẽ làm 2 lần

 

;; free lisp from cadviet.com
;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/56306-da-xong-lisp-chon-nhieu-doi-tuong-giong-nhau/
(defun c:sw(/ aaa ls dt dt1 sdt sdt1 ent ent1 id id1)
  (setq AAA(SSGET)
sdt (sslength AAA)
id 0
dt (ssadd)
)
  (repeat sdt;;repeat1
	(setq ent (ssname AAA id)
id (1+ id)
);;setq
	(setq ls (entget ent))
	(if (= (cdr (assoc 0 ls)) "INSERT")
  	(get-block ent)
  	(setq dt1 (ssget (list(assoc 0 ls) (assoc 8 ls))))
  	);;if
	(setq sdt1 (sslength dt1)
   id1 -1)
	(while (setq ent1(ssname dt1 (setq id1 (1+ id1))))
  	(setq dt (ssadd ent1 dt))
  	);;While
	(sssetfirst dt dt)
	(princ)
	);;repeat1
  )
;;;;;;;;;;;;;;;;;;;;;;;;
(defun get-block(entm / sdtb idb ent2 entb dtm namem name BBB entb)
  (setq dtm (vlax-ename->vla-object entm))
  (setq namem (if(vlax-property-available-p dtm 'effectivename)
   (vla-get-effectivename dtm)
   (vla-get-name dtm)
   ));;;
  (setq BBB(SSGET  (list(cons 0 "INSERT") (assoc 8 (entget entm))))
sdtb (sslength BBB)
idb 0
dt1 (ssadd)
)
  (repeat sdtb;;repeat1
	(setq entb (ssname BBB idb)
idb (1+ idb)
)
	(setq ent2(vlax-ename->vla-object entb))
	(setq name (if(vlax-property-available-p ent2 'effectivename)
   (vla-get-effectivename ent2)
   (vla-get-name ent2)
   ))
	(if (= name namem)
  	(setq dt1 (ssadd entb dt1))
  	)
	)
  )


<<

Filename: 283748_sw.lsp
Tác giả: Doan Van Ha
Bài viết gốc: 283657
Tên lệnh: ha2
[Yêu cầu] Lisp spline các điểm có tọa độ nhập từ .txt

Đây bạn!

;Doan Van Ha - CADViet.com - Ngay 14/3/2014
;Muc dich: Ve Spline qua cac diem duoc ghi trong file txt (moi hang la 1 diem, cac so trong hang cach nhau boi 1 ky tu trong).
(defun C:HA2( / fn pr rl txt lst)
 (command "ucs" "w")
 (setq fn (getfiled "Chon file de lay so lieu" "" "txt" 8))
 (setq pr (open fn "r"))
 (while (setq rl (read-line pr))
  (setq txt (HA:str->lst rl "...
>>

Đây bạn!

;Doan Van Ha - CADViet.com - Ngay 14/3/2014
;Muc dich: Ve Spline qua cac diem duoc ghi trong file txt (moi hang la 1 diem, cac so trong hang cach nhau boi 1 ky tu trong).
(defun C:HA2( / fn pr rl txt lst)
 (command "ucs" "w")
 (setq fn (getfiled "Chon file de lay so lieu" "" "txt" 8))
 (setq pr (open fn "r"))
 (while (setq rl (read-line pr))
  (setq txt (HA:str->lst rl " "))
  (setq lst (cons (list (car txt) (cadr txt)) lst)))
 (close pr)
 (setq xx lst)
 (Spline (reverse lst))
 (princ))
;----- String to List, EX: (HA:str->lst "1,2,3,4,5" ",") => (1 2 3 4 5)
(defun HA:str->lst ( str del / pos )
 (if (setq pos (vl-string-search del str))
  (cons (atof (substr str 1 pos)) (HA:str->lst (substr str (+ pos 1 (strlen del))) del)) 
  (list (atof str))))
;----- Ve Spline
(defun Spline (lst)
 (entmake (append (list '(0 . "SPLINE") '(100 . "AcDbEntity") '(100 . "AcDbSpline") (cons 71 3) (cons 74 (length lst))) (mapcar (function (lambda (p) (cons 11 p))) lst))))
 


<<

Filename: 283657_ha2.lsp
Tác giả: hantinh
Bài viết gốc: 283973
Tên lệnh: tk
Nhờ sửa lsp thống kê thép có thêm đoạn nối chồng

đây là bộ lsp thông kê mình vẫn hay dùng nếu bạn thích thi đây bạn có thể load về sài. Lệnh thống kê là TK nhé. mỗi tội cái thống kê của mình hok có tổng hợp khối lượng cho từng loại thép và đai cột tròn thôi. nếu thích thì bạn có thể thêm vào nhé.

;=CHUONG TRINH THONG KE COT THEP CAU KIEN
;;;Chuong trinh bat loi
(defun loitk (s)                    ; If an error (such as CTRL-C)...
>>

đây là bộ lsp thông kê mình vẫn hay dùng nếu bạn thích thi đây bạn có thể load về sài. Lệnh thống kê là TK nhé. mỗi tội cái thống kê của mình hok có tổng hợp khối lượng cho từng loại thép và đai cột tròn thôi. nếu thích thì bạn có thể thêm vào nhé.

;=CHUONG TRINH THONG KE COT THEP CAU KIEN
;;;Chuong trinh bat loi
(defun loitk (s)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
  (cond
    ((= s "quit / exit abort") (princ))
    ((/= s "Function cancelled") (princ (strcat "\nError: " s)))
  )
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" OSM)
(SETQ *error* OLDERR)
(princ)
)
;;;CHUONG TRINH CON NHAP DU LIEU
(princ "\nThong ke cot thep H3.0 ");
(defun gpuser()
(princ "\nTHONG KE COT THEP H 3.0 by KY SU NGUYEN XUAN MINH DHXD HANOI") 
(princ "\n      Copyright HiTech Group 2004 ENG NGUYEN XUAN MINH") 
(setq base_point(getpoint "\nBase point : "))
(setq loai      (getint   "\nLoai (0-18) : "))
)
;;;
;;;Chuong trinh con ve thep loai 0
(defun veloai0()
(princ "\nCot thep bat ky") 
(setq chieudai (getreal    "\nChieu dai  : "))
)
;;;
;;;Chuong trinh con ve thep loai 1
(defun veloai1()
(princ "\nCot thep thang") 
(setq chieudai (getreal    "\nChieu dai  : "))
(command "_PLINE" ( polar (polar base_point 0 10) (/ pi 2) 2 ) "@30,0" "") 
(command "_TEXT" "_M" "@-15,3" 0 (rtos chieudai 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 2 
(defun veloai2()
(princ "\nCot thep uon hai dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon 1 : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai3(getreal   "\nChieu dai doan uon 2 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"@0,-6"
"") 
(command "_TEXT" "_M" "@-35,3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0  (rtos chieudai3 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 3 
(defun veloai3()
(princ "\nCot thep uon mot dau") 
(setq chieudai1(getreal   "\nChieu dai doan uon   : "))
(setq chieudai2(getreal   "\nChieu dai doan thang : "))
(setq chieudai ( + chieudai1 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 10) (/ pi 2) 2 ) 
"@0,6" 
"@30,0"
"") 
(command "_TEXT" "_M" "@-35,-3" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 4 
(defun veloai4()
(princ "\nCot thep san") 
(setq chieudai1(getreal   "\nChieu dai thep : "))
(setq chieudai2(getreal   "\nChieu dai moc  : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai2 ))
(command "_PLINE" 
( polar (polar base_point 0 12) (/ pi 2) 4 ) 
"@-2,0" 
"_A"
"@0,-2"
"_L"
"@30,0"
"_A"
"@0,2"
"_L"
"@-2,0"
"") 
(command "_TEXT" "_M" "@-33,1" 0 (rtos chieudai2 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 5
(defun veloai5()
(princ "\nCot thep dai chu nhat") 
(setq chieudai1(getreal   "\nChieu cao dai : "))
(setq chieudai2(getreal   "\nChieu rong dai: "))
(setq chieudai3(getreal   "\nChieu dai moc : "))
(setq chieudai ( + chieudai1 chieudai1 chieudai2 chieudai2 chieudai3 chieudai3 ))
(command "_PLINE" 
( polar (polar base_point 0 5) (/ pi 2) 5 ) 
"@35,0" 
"@0,-3"
"@-30,0"
"@0,6"
"") 
(command "_TEXT" "_M" "@-5,0" 0 (rtos chieudai3 2 0) )
(command "_TEXT" "_M" "@20,0" 0 (rtos chieudai1 2 0) )
(command "_TEXT" "_M" "@20,-3" 0 (rtos chieudai2 2 0) )
)
;;;
;;;Chuong trinh con ve thep loai 6
(defun veloai6()
(princ "\nCot thep vai bo")
(setq chieudai1 (getreal   "\nChieu dai 1  :"))
(setq chieudai2 (getreal   "\nChieu dai 2  :"))
(setq chieudai3 (getreal   "\nChieu dai 3  :"))
(setq chieudai4 (getreal   "\nChieu dai 4  :"))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai4 ))
(command  "_PLINE"
( polar (polar base_point 0 10) (/ pi 2) 5 )
"@5,0"
"@3,-3"
"@14,0"
"@3,3"
"@5,0"
"")
(command "TEXT" "_R" "@-25,1.5" 0 (rtos chieudai1 2 0) )
(command "TEXT" "_R" "@0,-5.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "_M" "@10,3.5" 0 (rtos chieudai3 2 0) )
(command "TEXT" "@10,-3.5" 0 (rtos chieudai2 2 0) )
(command "TEXT" "@0,5.5" 0 (rtos chieudai4 2 0) )
) 
;;;
;;;Chuong trinh con ve thep loai 7
(defun veloai7()
(princ "\nCot thep treo moc cau")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan cong    : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai2 chieudai1 ))
(command "_PLINE"
(polar (polar base_point 0 16) (/ pi 2) 2 )
"@6,0"
"@0,6"
"_A"
"@3,0"
"_L"
"@0,-6"
"@6,0"
"")
(command "TEXT" "_M" "@-20,1" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@7,3" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@12,3" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M" "@6,-6" 0 (rtos chieudai1 2 0))
)
;;;Chuong trinh con ve thep loai 8
(defun veloai8 ()
(princ "\nCot thep cau thang loai 1")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai ( + chieudai1 chieudai2))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
""
)
(command "TEXT" "_R" "@-21,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "@12,-2" 0 (rtos chieudai2 2 0))
)
;;;Chuong trinh con ve loai 9
(defun veloai9 ()
(princ "\nCot thep cau thang loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@20,6"
"@10,0"
"@0,-6"
""
)
(command "TEXT" "_R" "@-21,4" 0 (rtos chieudai1 2 0))
(command "TEXT" "_C" "@15,-2" 0 (rtos chieudai2 2 0))
(command "TEXT" "@7,0" 0 (rtos chieudai3 2 0))
)
;;;
;;;Chuong trinh con ve loai 10
(defun veloai10 ()
(princ "\nCot thep cau thang loai 3")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "@13,-2" 0 (rtos chieudai3 2 0))
)
;;;Chuong trinh con ve loai 11
(defun veloai11 ()
(princ "\nCot thep cau thang loai 4")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@20,5"
"@10,0"
"@0,-7"
""
)
(command "TEXT" "_R" "@-31.5,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@9,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@16,-2" 0 (rtos chieudai3 2 0))
(command "TEXT" "@8,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 12
(defun veloai12 ()
(princ "\nCot thep cau thang loai 5")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@18,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-29.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@18,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@7.5,-2.5" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 13
(defun veloai13 ()
(princ "\nCot thep cau thang loai 6")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@10,3"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@8,-1.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "_R" "@2,5" 0 (rtos chieudai4 2 0))
(command "TEXT" "C" "@7,-2" 0 (rtos chieudai5 2 0))
)
:;;
;;;Chuong trinh con ve loai 14
(defun veloai14 ()
(princ "\nCot thep cau thang loai 7")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@10,0"
"@0,2"
"@20,5"
""
)
(command "TEXT" "_R" "@-31.5,-7" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@10,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@12,-2" 0 (rtos chieudai3 2 0))
)
:;;
;;;Chuong trinh con ve loai 15
(defun veloai15 ()
(princ "\nCot thep cau thang loai 8")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai5 (getreal  "\nChieu dai doan thang 5 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4 chieudai5))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@0,2"
"@14,2"
"@1,2"
"@15,-2"
"@0,-2"
""
)
(command "TEXT" "_R" "@-31.5,-2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@7,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "_M" "@6,2" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@14,0.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@6,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 16
(defun veloai16 ()
(princ "\nCot thep cau thang loai 9")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 1 )
"@6,0"
"@14,5"
"@0,2"
"@10,0"
""
)
(command "TEXT" "_R" "@-31.5,-6" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@11,2.5" 0 (rtos chieudai2 2 0))
(command "TEXT" "_R" "@9,2" 0 (rtos chieudai3 2 0))
(command "TEXT" "_M""@6,-1" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 17
(defun veloai17 ()
(princ "\nCot thep cau thang loai 10")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0.5,5"
"@15,-4"
"@15,4"
"@0.5,-5"
""
)
(command "TEXT" "_R" "@-32,0" 0 (rtos chieudai1 2 0))
(command "TEXT" "_R" "@12,4" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@10,0" 0 (rtos chieudai3 2 0))
(command "TEXT" "@11,-4" 0 (rtos chieudai4 2 0))
)
:;;
;;;Chuong trinh con ve loai 18
(defun veloai18 ()
(princ "\nCot thep dam loai 2")
(setq chieudai1 (getreal  "\nChieu dai doan thang 1 : "))
(setq chieudai2 (getreal  "\nChieu dai doan thang 2 : "))
(setq chieudai3 (getreal  "\nChieu dai doan thang 3 : "))
(setq chieudai4 (getreal  "\nChieu dai doan thang 4 : "))
(setq chieudai ( + chieudai1 chieudai2 chieudai3 chieudai4))
(command "_PLINE"
(polar (polar base_point 0 10) (/ pi 2) 2 )
"@0,0" 
"@0,5"
"@30,0"
"@0,-2.5"
"@-10,-2.5"
""
)

(command "TEXT" "_R" "@-22,2" 0 (rtos chieudai1 2 0))
(command "TEXT" "_M" "@15,5" 0 (rtos chieudai2 2 0))
(command "TEXT" "C" "@21,-4.5" 0 (rtos chieudai3 2 0))
(command "TEXT" "@-20,-2" 0 (rtos chieudai4 2 0))
)
;;; Chuong trinh con tinh toan thong ke
(defun thongke()
(command "_POINT" ( polar base_point 0 50))
(setq duongkinh(getreal   "\nDuong kinh : "))
(setq sothanh  (getreal   "\nSo thanh   : "))
(setq socaukien(getreal   "\nSo cau kien: <1>"))
(if socaukien null (setq socaukien 1.0))
(if (and (>= duongkinh 10) (> chieudai 11700))
        (progn
        (setq a (fix(/ chieudai 11700)))
        (setq cdainoi (getreal "\nChieu dai noi chong: <30D>"))
        (if (not cdainoi)    (setq cdainoi 30))
        (setq chieudai (+ chieudai (* a (* cdainoi duongkinh))))
                     ))
(setq tongchd(* chieudai (* sothanh (* socaukien 0.001))))
(setq tongkhlg(* tongchd (* duongkinh (* duongkinh 0.006165375))))
(command "_TEXT" "_M" "@5,5" 0 (rtos duongkinh 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos chieudai 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos sothanh 2 0) )
(command "_TEXT" "_M" "@10,0" 0 (rtos (* sothanh socaukien) 2 0) )
(command "_TEXT" "_M" "@15,0" 0 (rtos tongchd 2 2) )
(command "_TEXT" "_M" "@20,0" 0 (rtos tongkhlg 2 2) )
)
;;;Chuong trinh chinh
(defun c:tk( / CMD LIM TS PLW OSM OLDERR)
(SETQ OLDERR *error*
        *error* loitk
)
(SETQ CMD (GETVAR "CMDECHO"))
(SETQ LIM (GETVAR "LIMCHECK"))
(SETQ TS (GETVAR "TEXTSIZE"))
(SETQ PLW (GETVAR "PLINEWID"))
(SETQ OSM (GETVAR "OSMODE"))
(command "SETVAR" "CMDECHO" 0 )
(command "SETVAR" "LIMCHECK" 0 )
(command "SETVAR" "TEXTSIZE" 2.5 )
(command "SETVAR" "PLINEWID" 0.5 )
(command "OSNAP" "INT")
(gpuser)
(SETVAR "OSMODE" 0)
(cond 
((= loai 0) (veloai0))
((= loai 1) (veloai1))
((= loai 2) (veloai2))
((= loai 3) (veloai3))
((= loai 4) (veloai4))
((= loai 5) (veloai5))
((= loai 6) (veloai6))
((= loai 7) (veloai7))
((= loai 8) (veloai8))
((= loai 9) (veloai9))
((= loai 10) (veloai10))
((= loai 11) (veloai11))
((= loai 12) (veloai12))
((= loai 13) (veloai13))
((= loai 14) (veloai14))
((= loai 15) (veloai15))
((= loai 16) (veloai16))
((= loai 17) (veloai17))
((= loai 18) (veloai18))
)
(thongke)
(SETVAR "CMDECHO" CMD)
(SETVAR "LIMCHECK" LIM)
(SETVAR "TEXTSIZE" TS)
(SETVAR "PLINEWID" PLW)
(SETVAR "OSMODE" 15295)
(SETQ *error* OLDERR)
(princ)
)
(princ " loaded !")

cái này minhd đã để nó ở hệ mm nên bạn cần chuyển cái file temp acad.dwt về hệ này để dùng http://www.cadviet.com/upfiles/3/54284_tk14.dwg


<<

Filename: 283973_tk.lsp
Tác giả: ketxu
Bài viết gốc: 284065
Tên lệnh: keodai
Hỏi cách kéo dài đoạn thẳng từ cả 2 phía?

Đã có

http://www.cadviet.com/forum/topic/13203-viet-lisp-theo-yeu-cau-phan-2/page-154#entry128473

;; free lisp from cadviet.com
;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/13203-viet-lisp-theo-yeu-cau-phan-2/page-154#entry128473
;free lisp from cadviet.com @ ketxu 
(defun c:keodai (/ ss kc)...
>>

Đã có

http://www.cadviet.com/forum/topic/13203-viet-lisp-theo-yeu-cau-phan-2/page-154#entry128473

;; free lisp from cadviet.com
;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/13203-viet-lisp-theo-yeu-cau-phan-2/page-154#entry128473
;free lisp from cadviet.com @ ketxu 
(defun c:keodai (/ ss kc)  (vl-load-com)   
	(setq 	ss (ssget "_:L" '((0 . "LINE,LWPOLYLINE,ARC")))            
			kc (getdist "\nChieu dai phan dua ra: "))      
			(foreach ent 
				(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))         
					(command "_.lengthen" "_delta" kc                 
					(list ent (vlax-curve-getendpoint ent)) 
					(list ent (vlax-curve-getstartpoint ent)) ""        
					) ;kthuc command      
			) ; kthuc vong lap 
(princ))

<<

Filename: 284065_keodai.lsp
Tác giả: hiepttr
Bài viết gốc: 281174
Tên lệnh: tgll
Lisp tính tổng pline ed vào đuôi text

Sửa lại tí để khỏi phân vân chữ HOA hay chữ thường & có cảnh báo khi text chọn không hợp lệ !

;; free lisp from cadviet.com
;;;--------------------------------------------------------------------
(defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)))
;;;--------------------------------------------------------------------
(defun C:TGLL( / ss L e str)
(setq
ss (ssget (list (cons 0...
>>

Sửa lại tí để khỏi phân vân chữ HOA hay chữ thường & có cảnh báo khi text chọn không hợp lệ !

;; free lisp from cadviet.com
;;;--------------------------------------------------------------------
(defun Length1(e) (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)))
;;;--------------------------------------------------------------------
(defun C:TGLL( / ss L e str)
(setq
ss (ssget (list (cons 0 "LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,ELLIPSE,SPLINE")))
L 0.0
)
(vl-load-com)
(while (setq e (ssname ss 0))
(setq L (+ L (length1 e)))
(ssdel e ss)
)


(setq te (entget(car(entsel"\n Chon Text de gan ket qua :"))))
(cond ((or (vl-string-search "l" (setq str (cdr (assoc 1 te)))) (vl-string-search "L" str))
	(setq te (subst (cons 1 (strcat (CAT str "L") (rtos L 2 0))) (assoc 1 te) te))
	(entmod te))
	(t (alert "Text ban chon khong co chu L !"))
)
)
;;;--------------------------------------------------------------------
;Ham lay ki tu thu n cua chuoi:
(defun TIM(str n)
(substr str n 1)
)
;-------------------
;Ham cat chuoi co ky tu "x" tu dau den ky tu "x" sau cung (khong phan biet CHU HOA chu thuong):
(defun CAT(str x / i)
(cond
    ((= (xstrcase (substr str (strlen str))) (xstrcase x))
        str)
    (t
        (setq i (1+ (strlen str)))
        (while (/= (xstrcase (TIM str (setq i (1- i)))) (xstrcase x))
            (substr str 1 (1- i))
        )
    )
)
)

<<

Filename: 281174_tgll.lsp
Tác giả: Tue_NV
Bài viết gốc: 43068
Tên lệnh: chuyen
Lisp đổi kiểu nét thành Hidden2 và Line type scale = 0.2?

Sao bạn đòi hỏi nhiều quá vây? :cheers:


Filename: 43068_chuyen.lsp
Tác giả: gia_bach
Bài viết gốc: 80757
Tên lệnh: svp
Viết lisp theo yêu cầu [phần 2]

Bạn tham khảo Lisp sau :

Filename: 80757_svp.lsp
Tác giả: ndtnv
Bài viết gốc: 284437
Tên lệnh: 2
Nhờ viết Lips copy Text (tiếng nhật) sang Excel

Vẫn xuất ra tiếng Nhật tốt mà. Đây là kết quả của các text trong layout

http://www.cadviet.com/upfiles/3/19626_result.txt

Explode MTEXT => Text

Đây là code lấy từ cadviet

 

(defun Dxf(n g) (cdr (assoc n g)))
(defun Compare2D    (p q f / )
  (if    (equal (cadr p) (cadr q) f)
    (< (car p)...
>>

Vẫn xuất ra tiếng Nhật tốt mà. Đây là kết quả của các text trong layout

http://www.cadviet.com/upfiles/3/19626_result.txt

Explode MTEXT => Text

Đây là code lấy từ cadviet

 

(defun Dxf(n g) (cdr (assoc n g)))
(defun Compare2D    (p q f / )
  (if    (equal (cadr p) (cadr q) f)
    (< (car p) (car q))
    (> (cadr p) (cadr q)) )
)


(defun C:2 ( / ss lst e z y f s)
  (setq    ss (acet-ss-to-list (ssget '((0 . "TEXT"))))
    lst     (mapcar '(lambda (e) (cons(Dxf 10 (entget e)) (Dxf 1 (entget e)))) ss)
    z    (* (Dxf 40 (entget (car ss))) 0.5)
    lst        (vl-sort lst (function (lambda (e1 e2) (Compare2D (car e1) (car e2) z))))
    f     (open "result.txt" "w")  )
 
  (foreach e lst
        (princ (if    (equal y (cadr (car e)) z) "\t" "\n") f)
    (princ (cdr e) f)    (setq y (cadr (car e)))  )
  (close f)
)
 

<<

Filename: 284437_2.lsp
Tác giả: Doan Van Ha
Bài viết gốc: 235963
Tên lệnh: vht
Code lisp như thế nào để hạn chế lỗi cho người dùng?

Tạm gác ví dụ vẽ HCN ở trên (trong khi chờ mọi người bổ sung), hãy tìm cách bẫy lỗi lisp vẽ đường tròn dưới đây. Điều kiện: hễ mỗi lần gọi lệnh bắt buộc phải có 1 đường tròn được vẽ.

P/S(7h15'_25/5/2013): bổ sung điều...

>>

Tạm gác ví dụ vẽ HCN ở trên (trong khi chờ mọi người bổ sung), hãy tìm cách bẫy lỗi lisp vẽ đường tròn dưới đây. Điều kiện: hễ mỗi lần gọi lệnh bắt buộc phải có 1 đường tròn được vẽ.

P/S(7h15'_25/5/2013): bổ sung điều kiện: trừ trường hợp nhấn Esc. Sorry.

 

(defun C:VHT( / p r)
 (setq p (getpoint "\nSpecify center point for circle: "))
 (setq r (getreal "\nSpecify radius of circle: "))
 (command ".circle" "non" p r)
 (princ))

<<

Filename: 235963_vht.lsp
Tác giả: gia_bach
Bài viết gốc: 284587
Tên lệnh: dttg
Nhờ giúp đỡ về lisp tính diện tích bằng các pick điểm bao.

Em mới học lisp ạ, Em muốn mọi người giúp đỡ viết lisp tính diện tích bằng cách pick điểm đường bao giống như lệnh "area" ấy ạ.

Nghĩa là mình pick khoảng 10 điểm sau đó tính diện tích hình đa giác 10 cạnh ấy.

Em mong được mọi người giúp đỡ.

Tham khảo tính diện tích tam giác...

>>

Em mới học lisp ạ, Em muốn mọi người giúp đỡ viết lisp tính diện tích bằng cách pick điểm đường bao giống như lệnh "area" ấy ạ.

Nghĩa là mình pick khoảng 10 điểm sau đó tính diện tích hình đa giác 10 cạnh ấy.

Em mong được mọi người giúp đỡ.

Tham khảo tính diện tích tam giác qua 3 điểm.

(defun c:dttg()
(defun triangleArea(a b c)
  (setq p (/ (+ a b c) 2.0))
  (sqrt (* p (- p a)(- p b)(- p c))))

  (if (and
	(setq pt1 (getpoint "pict dinh dau cua tam giac :"))
	(setq pt2 (getpoint pt1 "pict dinh ke cua tam giac :"))
	(setq pt3 (getpoint pt2 "pict dinh cuoi cua tam giac :")))
    (progn
      (setq a (distance pt1 pt2)
	    b (distance pt1 pt3)
	    c (distance pt3 pt2)
	    cir (+ a b c)
	    area (triangleArea a b c))
      (princ (strcat "\nChu vi tam giac la :" (rtos cir)
		     "\nDien tich tam giac la :" (rtos area)))  ) )
  (princ))

<<

Filename: 284587_dttg.lsp
Tác giả: tientracdia
Bài viết gốc: 284844
Tên lệnh: trichtoado
Trích và ghi tọa độ, cạnh ra bảng

Mình có st một lisp với chức năng:

Chọn vào hình đa giác , chọn vị trí ghi chèn ra khung. thể hiện hình thể, stt điểm, cạnh và bảng tọa độ ghi Stt X Y và cạnh

(defun c:trichtoado( / ss lst fn fid lstEn)	;; toa do trac dia
(vl-load-com)
(command "-purge" "a" "" "N")
(command "attdisp" "ON")
  (styf)
  (Setq Tlebd (LM:GetXWithDefault getreal "\n Nhap ty le ban do: " '*Tlebd* (atof "1000")))
  (setq TLE (/ Tlebd...
>>

Mình có st một lisp với chức năng:

Chọn vào hình đa giác , chọn vị trí ghi chèn ra khung. thể hiện hình thể, stt điểm, cạnh và bảng tọa độ ghi Stt X Y và cạnh

(defun c:trichtoado( / ss lst fn fid lstEn)	;; toa do trac dia
(vl-load-com)
(command "-purge" "a" "" "N")
(command "attdisp" "ON")
  (styf)
  (Setq Tlebd (LM:GetXWithDefault getreal "\n Nhap ty le ban do: " '*Tlebd* (atof "1000")))
  (setq TLE (/ Tlebd 1000))
  (progn
	(setvar "hpgaptol" 0.5)
	(setq Olmode (getvar "OSMODE"))
	(setvar "OSMODE" 0)
	
	(setq Clor (getvar "CECOLOR"))
	(setq pt (getpoint "\n Pick diem trong vung can trich thua :"))
	(vl-cmdf  "-boundary" pt "")
	
        (setq Elast1 (entlast))
    	(dch (entget Elast1))
    	(setq Elast (entlast))
  	(setq en Elast
      	      ob (vlax-ename->vla-object  en)
               n (vlax-curve-getEndParam ob)
               i 0
        )
  	(setq Pd (vlax-curve-getPointAtParam ob 0)
	      Pc (vlax-curve-getPointAtParam ob n)
	     KCC (rtos (distance Pd Pc) 2 2)
	)
  	(setq P1dau (vlax-curve-getPointAtParam ob 0))
	(setq Xdau (rtos (car P1dau) 2 2))
  	(setq Ydau (rtos (cadr P1dau) 2 2))
  
  	(setq P_ddat (getpoint "\n Chon diem dat: "))
  	;(setq P_a1 (polar P_ddat 0 (* TLE 207.0)))			;;; vi tri dat sst diem 207.0   124.3
  	;(setq P1 (polar P_a1 (/ pi 2) (* TLE 124.3)))
	(setq P_a1 (polar P_ddat 0 (* TLE 207.0)))			;;; vi tri dat sst diem x=207.0   y=124.3  ok
  	(setq P1 (polar P_a1 (/ pi 2) (* TLE 124.3)))
    
  	(command "insert" "khung" P_ddat TLE TLE  0 (rtos (Area Elast)  2 2) (rtos Tlebd  2 0)) ; chen mau khung, dtich, tle
  	(setq P2 (polar P1 0 (* TLE 20.0)))		; vi tri toa do X
  	(setq P3 (polar P1 0 (* Tle 43.0)))		; vi tri toa do Y
  	(setq P4a (polar P1 0 (* TLE 62.0)))	; vi tir ghi Kcach
  	(setq P4 (polar P4a (DTR 270) (* TLE 2.5)))	; xoay 270 do
	;;-------------
	;(setq P5a (polar P1 0 (* TLE 70.0)))	; vi tir ten canh
  	;(setq P5 (polar P5a (DTR 270) (* TLE 2.5)))	; xoay 270 do
	
	;;-------------
  
  	(setq P1DD (polar P1 (DTR 270) (* n (* TLE 5.0))))
  	(setq P2DD (polar P2 (DTR 270) (* n (* TLE 5.0))))
  	(setq P3DD (polar P3 (DTR 270) (* n (* TLE 5.0))))
	
  
  	(MakeText P1DD (rtos 1 2 0) (* TLE 2.5) 0 "C")	; viet STT
  	(MakeText P2DD Xdau (* TLE 2.5) 0 "C")			; viet X
  	(MakeText P3DD Ydau (* TLE 2.5) 0 "C")			; viet Y
  	
	(while (< i n)													; vong lap xac dinh diem, x, y , kc
		(setq p (vlax-curve-getPointAtParam ob i))					; VI TRI 1
	  	(setq p_2 (vlax-curve-getPointAtParam ob (+ i 1)))			; VI TRI 1+N
		(setq X (rtos (car P) 2 2))
	  	(setq Y (rtos (cadr P) 2 2))
	  	(setq KC (rtos (distance P P_2) 2 2))
		
		
	  
	  	(setq P1_i (Polar P1 (DTR 270) (* i (* TLE 5.0))))
	  	(setq P2_i (Polar P2 (DTR 270) (* i (* TLE 5.0))))
	  	(setq P3_i (Polar P3 (DTR 270) (* i (* TLE 5.0))))
	  	(setq P4_i (Polar P4 (DTR 270) (* i (* TLE 5.0))))
		
	  	
	  	(MakeText P1_i (rtos (+ i 1) 2 0) (* TLE 2.5) 0 "C")
	  	(MakeText P2_i X (* TLE 2.5) 0 "C")
	  	(MakeText P3_i Y (* TLE 2.5) 0 "C")
	  	(MakeText P4_i KC (* TLE 2.5) 0 "C")
		;--------
		;(MakeText P5_i TC (* TLE 2.5) 0 "C")
		;-----------
		(setq i (1+ i))
	)
)
;-----
;(setq P_a2 (polar P_ddat 0 (* TLE 138.3)))
(setq P_a2 (polar P_ddat 0 (* TLE 100)))				;; vi tri tam dat cat thua x=100 , y=94.5
(setq Pnt1 (polar P_a2 (/ pi 2) (* TLE 94.5)))
(command "copy" Elast "" (mid Elast) Pnt1 "")			;; copy giua hinh dua vao
(GKT Pnt1 TLE )
;----

(setvar "OSMODE" Olmode)
(princ)
)
;;;----------------
(defun GKT (Pt TLE / lst fn fid lstEn);Ghi kich thuoc
(vl-load-com)
	(setvar "hpgaptol" 0.5)
	(setq Olmode (getvar "OSMODE"))
	(setvar "OSMODE" 0)
	(setq Clor (getvar "CECOLOR"))
	(vl-cmdf  "-boundary" Pt "")
        (setq Elast (entlast))
  	(dch (entget Elast))
  	(setq en Elast
      	      ob (vlax-ename->vla-object  en)
               n (vlax-curve-getEndParam ob)
               i 0
        )
  	
	(while (< i n)
		(setq P (vlax-curve-getPointAtParam ob i))
	  	(command "insert" "diem" p TLE TLE 0)
	  	(setq P_2 (vlax-curve-getPointAtParam ob (+ i 1)))
	  	(setq goc (angle P P_2))
	  	(setq KC_i  (distance P P_2) )
	  	(setq DG_i (polar P goc (/ KC_i 2)))
	  	(setq Pii (polar P (/ pi 2) (* TLE 2)))
	  	(MakeText Pii (rtos (+ i 1) 2 0) (* TLE 2.5) 0 "C")
	  	(setq PVi (Atan2 P P_2))
	  	(if (< (Rad_to_Do PVi) 180)
		  (progn
		    (setq PG_ia (polar DG_i (+ (/ pi 2) goc) 1.0))
	  	    (MakeText PG_ia (rtos KC_i 2 2) (* TLE 2.5) goc "C")
		  )
		  (progn
		    (setq PG_ib (polar DG_i (+ (/ pi 2) (angle P_2 P)) 1.0))
		    (MakeText PG_ib (rtos KC_i 2 2) (* TLE 2.5)  (angle P_2 P) "C")
		  )
		)
		(setq i (1+ i))
	)
(MakeText (mid Elast) (rtos (Area Elast)  2 2)  (* TLE 2.5)  0 "C")
(entdel Elast)
(setvar "OSMODE" Olmode)
;;;(princ )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun Area (ent)
(setvar "hpgaptol" 0.1)
(vla-get-area (vlax-ename->vla-object ent))
)
;;---
(defun mid (ent / p1 p2)
	(vla-getboundingbox (vlax-ename->vla-object ent) 'p1 'p2)
	(setq p1 (vlax-safearray->list p1)
				p2 (vlax-safearray->list p2)
				pt (mapcar '+ p1 p2)
				pt (mapcar '* pt '(0.5 0.5 0.5))
	)
	pt
)
;;---
(defun wtxt_l(txt p / sty d h1 h2 wf h) ;;;Write txt on graphic screen at p
(setq    sty (getvar "textstyle")    
d (tblsearch "style" sty)    
h1 (cdr (assoc 40 d))    
h2 (cdr (assoc 42 d))    
wf (cdr (assoc 41 d)))
(if (> h1 0) (setq h h1) (setq h h2))
(entmake (list (cons 0 "TEXT") (cons 7 sty) (cons 40 h) (cons 41 wf)(cons 72 4)(cons 11 p)(cons 62 4) (cons 1 txt) (cons 10 p)))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun TD:Text-Base (ent)
  (setq Ma10  (cdr (assoc 10 (entget ent))))
  (setq Ma11  (cdr (assoc 11 (entget ent))))
  (setq X11 (car Ma11))
  (setq Ma71  (cdr (assoc 71 (entget ent))))
  (setq Ma72  (cdr (assoc 72 (entget ent))))
  (if (or (and (= Ma71 0) (= Ma72 0) (= X11 0))
	  (and (= Ma71 0) (= Ma72 3) )
	  (and (= Ma71 0) (= Ma72 5) )
      )
    Ma10
    Ma11
   )
)
;--
(defun DTR (Do / radian)
   (setq radian  (/ (* Do pi ) 180))
)
;---
(defun LM:GetXWithDefault ( _function _prompt _symbol _default / _toString )
	(setq _toString
		(lambda ( x )
			(cond
				( (eq getangle _function) (angtos x) )
				( (eq 'REAL (type x)) (rtos x) )
				( (eq 'INT (type x)) (itoa x) )
				( x )
			)
		)
	)

	(set _symbol
	(
	(lambda ( input ) (if (or (not input) (eq "" input)) (eval _symbol) input))
	(_function (strcat _prompt "<" (_toString (set _symbol (cond ( (eval _symbol) ) ( _default )))) "> : "))
	)
	)
)
;--- tao text
(defun MakeText (point string Height Ang justify     / Lst); Ang: Radial
	(setq Lst (list '(0 . "TEXT")
			(cons 8 (if Layer Layer (getvar "Clayer")))
			(cons 62 (if Color Color 256))
			(cons 10 point)
			(cons 40 Height)
			(cons 1 string)
			(cons 50 Ang)
		)
	justify (strcase justify)
      )
      (cond ((= justify "C") (setq Lst (append Lst (list (cons 72 1) (cons 11 point)))))
			((= justify "R") (setq Lst (append Lst (list (cons 72 2) (cons 11 point)))))
			((= justify "M") (setq Lst (append Lst (list (cons 72 4) (cons 11 point)))))
			((= justify "TL") (setq Lst (append Lst (list (cons 72 0) (cons 11 point) (cons 73 3)))))
			((= justify "TC") (setq Lst (append Lst (list (cons 72 1) (cons 11 point) (cons 73 3)))))
			((= justify "TR") (setq Lst (append Lst (list (cons 72 2) (cons 11 point) (cons 73 3)))))	
			((= justify "ML") (setq Lst (append Lst (list (cons 72 0) (cons 11 point) (cons 73 2)))))
			((= justify "MC") (setq Lst (append Lst (list (cons 72 1) (cons 11 point) (cons 73 2)))))
			((= justify "MR") (setq Lst (append Lst (list (cons 72 2) (cons 11 point) (cons 73 2)))))
			((= justify "BL") (setq Lst (append Lst (list (cons 72 0) (cons 11 point) (cons 73 1)))))
			((= justify "BC") (setq Lst (append Lst (list (cons 72 1) (cons 11 point) (cons 73 1)))))
			((= justify "BR") (setq Lst (append Lst (list (cons 72 2) (cons 11 point) (cons 73 1)))))
      )
     (entmakex Lst)
 )


;-----revlwpl
(defun dch (ent / eo el len)
(vl-load-com)
(setq eo ent)
(setq el (list(assoc 210 ent)))
(while (member (assoc 10 ent) ent)
  (if (= 0.0 (assoc 42 ent))
(setq el (cons (assoc 42 ent) el))
(setq el (cons (cons 42 (- (cdr (assoc 42 ent)))) el))
  )
  (setq el (cons (assoc 41 ent) el))
  (setq el (cons (assoc 40 ent) el))
  (setq el (cons (assoc 10 ent) el))
  (setq ent (member (assoc 10 ent) ent))
  (setq ent (cdr ent))
)
(setq len(- (LENGTH eo) (LENGTH (member (assoc 10 eo) eo)) 1))
(while (>= len 0)
  (setq el (cons (nth len eo) el))
  (setq len (- len 1))
)
(setq ent el)
(entmod ent)
(princ)
)
;----
(defun Rad_to_Do(radian / Do)
   (setq Do (/ (* radian 180) pi))
)
(defun Do_to_Radian (Do / radian)
   (setq radian  (/ (* Do pi ) 180))
)
;------
(defun R2DPG (gocR / DPG Toando Do Phut1 Phut Giay DPG)
  (setq DPG (list))
  (setq Toando (Rad_to_Do gocR))
  (setq Do (fix Toando))
  (setq Phut1  (* (- Toando Do) 60))
  (setq Phut (fix Phut1))
  (setq Giay   (atof (rtos (* (- phut1 phut) 60) 2 3)))
  (setq DPG (list Do  Phut giay))
  DPG
)
;---
(defun DPG_to_DO (Goc)
(setq DD (nth 0 Goc))
(setq PP (/ (nth 1 Goc) 60))
(setq GG (/ (nth 2 Goc) 3600))
(setq DDD (+ DD PP GG))
DDD
)
;---
(defun Dogoc2diem (P1 P2 /)
  (setq gocP12 (angle P1 P2))
  (setq gocP12_DPG (R2DPG gocP12))
  (setq Goc_12 (DPG_to_DO gocP12_DPG))
  Goc_12
)
;---
(defun Do_to_DPG (Toando /)
  (setq Do (fix Toando))
  (setq Phut1 (* (- Toando Do) 60))
  (setq Phut (fix Phut1))
  (setq Giay   (atof (rtos (* (- phut1 phut) 60) 2 3)))
  (setq DPG (list Do  Phut giay))
  DPG
)
;---
(defun Atan2 (P1 P2 / gocAtan b)
  (setq dx ( - (car P2) (car P1)))
  (setq dy ( - (cadr P2) (cadr P1)))
  (setq gocAtan (list))
  (cond
    ((and (= dx 0) (> dy 0) )
      (setq gocAtan 0)
    )
    ((and (= dx 0) (< dy 0) )
      (setq gocAtan pi)
    )
    ((and  (< dx 0) (= dy 0) )
      (setq gocAtan (/ (* 3 pi) 2))
    )
    ((and  (> dx 0) (= dy 0) )
      (setq gocAtan pi)
    )
    ((and  (= dx 0) (= dy 0) )
      (setq gocAtan 0)
    )
    ((/= dx 0)
     (progn
	(setq b (atan (/ dx dy)))
	(cond
	    ((and (> dx 0) (>= dy 0))
		  (setq gocAtan b)
	    )
	    ((and (< dx 0) (> dy 0))
		  (setq gocAtan (+ (* pi 2) b))
	    )
	    ((and (< dx 0) (< dy 0))
		  (setq gocAtan (+ pi b))
	    )
	    ((and (> dx 0) (< dy 0))
	          (setq gocAtan (+ pi b))
	    )
	)
      )
    )  
  )
  gocAtan
)
;---
(defun styf (/ Oldtstyle Sttxt Userfont *error*)
  (defun *error* (s)
    (setvar "textstyle" oldtstyle)
  )
  (setq oldtstyle (getvar "textstyle"))
  (setq userfont "Times New Roman") ;; kieu font
  (setvar "textstyle" (cdr (assoc 2 (tblnext "style" T))))
  (command "._Style" "" userfont 2 1 0 "N" "N")
  (while
    (setq sttxt (cdr (assoc 2 (tblnext "style"))))
     (setvar "textstyle" sttxt)
     (command "._Style" "" userfont 2 1 0 "N" "N")
  )
  (setvar "textstyle" oldtstyle)
)

;;---
(defun daochieu (ss / count lwp ent obj oname sss revlwpl revln)
  (vl-load-com)
  (defun revlwpl(/ eo el len)
	(setq eo ent)
	(setq el (list(assoc 210 ent)))
	(while (member (assoc 10 ent) ent)
	  (if (= 0.0 (assoc 42 ent))
   (setq el (cons (assoc 42 ent) el))
   (setq el (cons (cons 42 (- (cdr (assoc 42 ent)))) el))
	  )
	  (setq el (cons (assoc 41 ent) el))
	  (setq el (cons (assoc 40 ent) el))
	  (setq el (cons (assoc 10 ent) el))
	  (setq ent (member (assoc 10 ent) ent))
	  (setq ent (cdr ent))
	)
	(setq len(- (LENGTH eo) (LENGTH (member (assoc 10 eo) eo)) 1))
	(while (>= len 0)
	  (setq el (cons (nth len eo) el))
	  (setq len (- len 1))
	)
	(setq ent el)
	(entmod ent)
  )
  ;---
  (defun revln (/ pt1 pt2)
	(setq pt1 (cons 10 (cdr (assoc 11 ent))))
	(setq pt2 (cons 11 (cdr (assoc 10 ent))))
	(setq ent (subst pt1 (assoc 10 ent) ent))
	(setq ent (subst pt2 (assoc 11 ent) ent))
	(entmod ent)
  )
	 
;;;  (princ "\nSelect Lines & Polylines to reverse direction of:   ")
;;;  (setq ss (ssget '((0 . "POLYLINE,LWPOLYLINE,LINE"))))
  (setvar "CMDECHO" 0)
  (command "._UNDO" "_BEgin")
  (if ss
	(progn
	  (setq count 0 lwp 0)
	  (while (> (sslength ss) count)
		(setq ent (ENTGET (ssname ss count))
				  obj (vlax-ename->vla-object (ssname ss count))
				  oname (vlax-get-property obj 'ObjectName)
		)
		(cond
		  ((= oname "AcDb3dPolyline")(setq lwp(+ 1 lwp)))
		  ((= (cdadr ent) "LWPOLYLINE")(revlwpl))
		  ((= (cdadr ent) "POLYLINE")
			(progn
			  (setq sss (ssadd (ssname ss count)))
			  (vl-cmdf "convertpoly" "Light" sss "")
			  (setq ent (ENTGET (ssname sss 0)))
			  (revlwpl)
			)
		  )
		  ((= (cdadr ent) "LINE")(revln))
		)
		(setq count (+ count 1))
	  )
	)
  )
  (command "._UNDO" "_End")
  (if(> lwp 0)
	(if(> lwp 1)
	  (princ(strcat "\nCould not reverse " (itoa lwp) " 3dPolylines."))
	  (princ"\nCould not reverse the 3dPolyline.")
	)
  )
  (princ)
)
;;;=================
(defun vietcanh()
              (setq s (distance pt1 pt2))
              (setq s (rtos s 2 2))
              (setq ax (angle pt1 pt2))
              (setq ax (/ (* ax 180) pi))
              (setq xx1 (car pt1) yy1 (car (cdr pt1)))
              (setq xx (car pt2) yy (car (cdr pt2)))
              (setq xx1 (/ (+ xx xx1) 2) yy1 (/ (+ yy yy1) 2))
              (setq ptx1 (list xx1 yy1))
                      (if (and (< ax 260) (> ax 100))
                         (command "text" "j" "BC" ptx1 (* sc 2.8) (+ 180 ax) s)
                         (command "text" "j" "BC" ptx1 (* sc 2.8) ax s)
                      )
  (princ)
)
;------------------------------------------

Mong muốn được các anh giúp bổ sung thể hiện thêm cột tên cạnh, trên bảng tọa độ gồm có STT-toa do x -y - cạnh - tên cạnh. Theo mẫu

http://www.cadviet.com/upfiles/3/114381_009.dwg

 

Chép bộ này vào Support của Cad

http://www.cadviet.com/upfiles/3/114381_khung.dwg

http://www.cadviet.com/upfiles/3/114381_diem.dwg

.

 


<<

Filename: 284844_trichtoado.lsp
Tác giả: gia_bach
Bài viết gốc: 284947
Tên lệnh: plj
Nối đỉnh các đường line thành polyline

Chào cả nhà,

Mình có rất nhiều đoạn line. Giúp mình tạo lisp để nối đỉnh tất cả những đoạn line (như đường màu đỏ trong hình minh họa). 

Mình cám ơn!1v0f.png

Hy vọng đúng ý chủ thớt.

(defun c:plj(/ lst...
>>

Chào cả nhà,

Mình có rất nhiều đoạn line. Giúp mình tạo lisp để nối đỉnh tất cả những đoạn line (như đường màu đỏ trong hình minh họa). 

Mình cám ơn!1v0f.png

Hy vọng đúng ý chủ thớt.

(defun c:plj(/ lst st end ss)
  ;; By : Gia_Bach 2014
  (vl-load-com)
  (if (and(setq ss (ssget (list (cons 0 "LINE") )) )
	  (> (sslength ss) 1))
    (progn
      (foreach obj (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))	
	(if (< (cadr (setq st (vlax-curve-getStartPoint obj)))(cadr (setq end (vlax-curve-getEndPoint obj))))
	  (setq lst (cons (list (car end)(cadr end))lst))
	  (setq lst (cons (list (car st)(cadr st))lst))) )
      (setq lst (apply 'append (vl-sort lst '(lambda(x y) (< (car x) (car y))))))
      (vla-addLightweightpolyline
	(vla-get-modelspace (vla-get-ActiveDocument (vlax-get-Acad-Object)))
	(vlax-make-variant(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length lst)))) lst))) ))
  (princ))

<<

Filename: 284947_plj.lsp
Tác giả: quansla
Bài viết gốc: 285023
Tên lệnh: cadviet
Nhờ các anh chị viết giùm em lisp

Đây bạn dùng thử xem sao
http://www.cadviet.com/upfiles/3/101306_cadviet_1.lsp
Lệnh lisp : cadviet
 
Quick Code

 
(defun c:Cadviet (/ B BX1 BX2 BY1 BY2 D H KEY LST P0 T1 T2 VALUE X X1 Y1
   make_ls_poly quan khoitaofile )
  (defun doidiem (p0 dX dY)
    (mapcar '+ p0 (list  dX dY 0)))
    
  (defun make_ls_poly ( p B...

>>

Đây bạn dùng thử xem sao
http://www.cadviet.com/upfiles/3/101306_cadviet_1.lsp
Lệnh lisp : cadviet
 
Quick Code

 
(defun c:Cadviet (/ B BX1 BX2 BY1 BY2 D H KEY LST P0 T1 T2 VALUE X X1 Y1
   make_ls_poly quan khoitaofile )
  (defun doidiem (p0 dX dY)
    (mapcar '+ p0 (list  dX dY 0)))
    
  (defun make_ls_poly ( p B H / p1 p2 p3 p4 ls)    
    (setq p1 (mapcar '+ p (list (/ B -2.0) (/ H 2.0) 0))
 p2 (mapcar '+ p (list (/ B 2.0) (/ H 2.0) 0))
 p3 (mapcar '+ p (list (/ B 2.0) (/ H -2.0) 0))
 p4 (mapcar '+ p (list (/ B -2.0) (/ H -2.0) 0))
 )
    (setq ls (list p1 p2 p3 p4 p1))
    (setq ls (mapcar '(lambda (x) (list (car x) (cadr x))) ls))
    (acet-pline-make(list ls))
    )
  
  (defun quan (/ ls kq)
    (setq ls (mapcar '(lambda (x) (get_tile x)) '("H" "B" "t1" "t2" "X1" "Y1" "D" "BX1" "BX2" "BY1" "BY2")))
    (setq kq T)
    (foreach i ls (if (not(atof i)) (setq kq nil)))
    (if kq (setq #lst ls) (setq #lst '("300" "200" "8" "6" "10" "10" "22" "100" "100" "100" "100")))
    ls
    )
      
  (defun khoitaofile(/ DCLEDITTEXT f i DCL_ID LST EDITEXT)    
    (setq DCLEDITTEXT
  (list "EDIT: dialog {label = \"SELECT VALUE\";initial_focus = \"text\";"
":edit_box {label = \"Chieu cao TD H:\"; allow_accept = true; edit_width = 15; key = \"H\";}"
":edit_box {label = \"Chieu rong TD B:\"; allow_accept = true; edit_width = 15; key = \"B\";}"
":edit_box {label = \"Chieu day Canh t1:\"; allow_accept = true; edit_width = 15;key = \"t1\";}"
":edit_box {label = \"Chieu day bung t2:\"; allow_accept = true; edit_width = 15;key = \"t2\";}"
":edit_box {label = \"Khoang cach X1:\"; allow_accept = true; edit_width = 15;  key = \"X1\";}"
":edit_box {label = \"Khoang cach Y1:\"; allow_accept = true; edit_width = 15;  key = \"Y1\";}"
":edit_box {label = \"Duong kinh lo D:\"; allow_accept = true; edit_width = 15;  key = \"D\";}"
":edit_box {label = \"Khoang cach lo BX1:\"; allow_accept = true; edit_width = 15; key = \"BX1\";}"
":edit_box {label = \"Khoang cach lo BX2(thua):\"; allow_accept = true; edit_width = 15;  key = \"BX2\";}"
":edit_box {label = \"Khoang cach lo BY1:\"; allow_accept = true; edit_width = 15; key = \"BY1\";}"
":edit_box {label = \"Khoang cach lo BY2(thua):\"; allow_accept = true; edit_width = 15;key = \"BY2\";}" 
      "spacer_1;"
      "ok_cancel;}"
      ))
    (setq EDITEXT.DCL (vl-filename-mktemp "EditText.dcl")
 f (open EDITEXT.DCL "w"))
    (foreach i DCLEDITTEXT (write-line i f))
    (close f)    
    (if(> 0 (setq DCL_ID (load_dialog EDITEXT.DCL)))
      (progn (alert "not found file EditText.DCL") (exit)))
    (if(not (new_dialog "EDIT" DCL_ID))
      (progn (alert "not found EDIT dialog") (exit)))
    (or #lst (setq #lst '("300" "200" "8" "6" "10" "10" "22" "100" "100" "100" "100")))
    (mapcar '(lambda (key  value)
(set_tile key value))
    '("H" "B" "t1" "t2" "X1" "Y1" "D" "BX1" "BX2" "BY1" "BY2")
    #lst)    
    (action_tile "accept" "(setq lst (quan))(done_dialog)")
    (action_tile "cancel" "(princ)")
    (start_dialog)
    (unload_dialog DCL_ID)
    (vl-file-delete EDITEXT.DCL)
    lst
    )
  (progn
    (setvar "cmdecho" 0)
    (setq lst (KHOITAOFILE))
    (setq H (atof (nth 0 lst))
B (atof (nth 1 lst))
t1 (atof (nth 2 lst))
t2 (atof (nth 3 lst))
X1 (atof (nth 4 lst))
Y1 (atof (nth 5 lst))
D (atof (nth 6 lst))
Bx1 (atof (nth 7 lst))
Bx2 (atof (nth 8 lst))
By1 (atof (nth 9 lst))
By2 (atof (nth 10 lst))
)
    (setq p0 (getpoint "\nChon diem chen"))    
    (make_ls_poly p0 (+ B y1 y1) (+ H x1 x1))
    (make_ls_poly p0 t2 (- H t1 t1))
    (make_ls_poly (mapcar '+ p0 (list 0 (* (- H t1) -0.5) 0)) B t1)
    (make_ls_poly (mapcar '+ p0 (list 0 (* (- H t1) +0.5) 0)) B t1)
    
    (entmakex(list'(0 . "CIRCLE")
 (cons 10 (doidiem p0 (* Bx1 -0.5) (* By1 -0.5)))
 (cons 40 (/ D 2.0))))
    (entmakex(list'(0 . "CIRCLE")
 (cons 10 (doidiem p0 (* Bx1 -0.5) (* By1 +0.5)))
 (cons 40 (/ D 2.0))))
    (entmakex(list'(0 . "CIRCLE")
 (cons 10 (doidiem p0 (* Bx1 +0.5) (* By1 +0.5)))
 (cons 40 (/ D 2.0))))
    (entmakex(list'(0 . "CIRCLE")
 (cons 10 (doidiem p0 (* Bx1 +0.5) (* By1 -0.5)))
 (cons 40 (/ D 2.0))))
    )
  (setvar "cmdecho" 1)
  (princ)
  )


<<

Filename: 285023_cadviet.lsp

Trang 152/330

152