วันศุกร์ที่ 29 มกราคม พ.ศ. 2564

draw polyline form points

 

;; Select object (point only) and draw polyline

(defun c:p2pl (/ sset p1 n p2 ss1 ss2)

(setq old_cmdecho  (getvar "cmdecho"))  ;  cmdecho

(setq old_osnap (getvar "osmode"))  ; osnap

(setvar "cmdecho" 0)    ;  (off) cmdecho

(prompt "\nDraw Polyine From Points")

(Setq sset (ssget '((0 . "POINT"))))

(Setq p1 nil

       ss1 nil

)

(setvar "osmode" 0) ;  (off) object snap

(repeat (setq n (sslength sset))

     (setq p2 (cdr (assoc 10 (entget (ssname sset (setq N (- N 1)))))))

     (if (/= p1 nil)

          (progn

              (command "_.pline" "_none" p1 "_none" p2 "")

              (setq ss2 (entlast))

          )

     )

     (if (/= ss1 nil)

          (progn

              (command "_.pedit" "_multiple" ss1 ss2 "" "_join" "0.0" "")

              (setq ss1 (entlast))

          )

          (setq ss1 ss2)

     )

     (setq p1 p2)

)

(setvar "cmdecho" old_cmdecho)  ; old_cmdecho

(setvar "osmode" old_osnap) ; old_osnap

(princ)

)


วันพุธที่ 20 มกราคม พ.ศ. 2564

Area of a triangle Heron's formula

 

การหาพื้นที่สามเหลี่ยมด้วยวิธี Heron's formula


;; Area of a triangle (Heron's formula)

(defun c:Arheron ()

(setq a (getdist "\nEnter Length of Side a : "))

(setq b (getdist "\nEnter Length of Side b : "))

(setq c (getdist "\nEnter Length of Side c : "))

(setq s (/(+ a b c) 2))

(setq as (sqrt(* s (- s a)(- s b)(- s c))))

(princ (strcat "Area = " (rtos as 2 2)))

(princ)

)