Đến nội dung


Hình ảnh
- - - - -

[Hỏi] cách lấy về phần nguyên của phép chia


  • Please log in to reply
2 replies to this topic

#1 hantinh

hantinh

    biết lệnh attdef

  • Members
  • PipPipPipPipPipPip
  • 413 Bài viết
Điểm đánh giá: 44 (tàm tạm)

Đã gửi 10 March 2014 - 10:10 PM

bro nào giỏi về aotulisp cho mình hỏi chút. hiện tại mình muốn lấy phần nguyên của 1 phép chia thi khi bao thế nao với

VD: 25/4=6.25 mà minh chỉ muốn lấy cái giá trị nguyên (6) trước dấu phẩy ấy thì khai bao the nào để lấy được nó vậy


  • 0

#2 phamthanhbinh

phamthanhbinh

    biết lệnh adcenter

  • Moderator
  • PipPipPipPipPipPipPip
  • 6009 Bài viết
Điểm đánh giá: 3113 (tuyệt vời)

Đã gửi 11 March 2014 - 01:19 AM

bro nào giỏi về aotulisp cho mình hỏi chút. hiện tại mình muốn lấy phần nguyên của 1 phép chia thi khi bao thế nao với

VD: 25/4=6.25 mà minh chỉ muốn lấy cái giá trị nguyên (6) trước dấu phẩy ấy thì khai bao the nào để lấy được nó vậy

Hề hề hề,

(setq a (/ 25 4))


  • 0
Chúc các quý Anh trên diễn đàn luôn khỏe, đẻ thêm được nhiều thứ để mót.

#3 hantinh

hantinh

    biết lệnh attdef

  • Members
  • PipPipPipPipPipPip
  • 413 Bài viết
Điểm đánh giá: 44 (tàm tạm)

Đã gửi 13 March 2014 - 11:40 AM

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 !")

  • 0