Autolisp Programs

September 14, 2017 | Author: Amit Mishra | Category: Circle, Triangle Geometry, Space, Geometric Objects, Euclidean Geometry
Share Embed Donate


Short Description

Download Autolisp Programs...

Description

NAME ROLL NO PROGRAM 1 ( defun c:PROG1() (setq s1 (getreal "Enter length of 1st side: ")) (setq s2 (getreal "Enter length of 2nd side: ")) (setq s3 (getreal "Enter length of 3rd side: ")) (cond ;For sorting given sides in ascending order ( (> s1 s2) (setq temp1 s2) (setq s2 s1) (setq s1 temp1) ) ( (> s2 s3) (setq temp2 s3) (setq s3 s2) (setq s2 temp2) ) ( (> s1 s2) (setq temp3 s2) (setq s2 s1) (setq s1 temp3) ) ) (cond ( (> (+ s1 s2) s3) ;For checking condition for triangle (setq pt1 (getpoint "Enter insertion point of triangle: ")) (setq pt2 (list (+ (car pt1) s1) (cadr pt1))) (setq x (/ (+ (* s1 s1) (- (* s2 s2) (* s3 s3))) (* 2 s1))) ;x=(a^2 + b^2 - c^2)/(2a) (setq z (- (* s2 s2) (* x x))) ;y=sqrt(b^2 - x^2) (setq y (sqrt z)) (setq pt3 (list (+ (car pt1) x) (+ (cadr pt1) y))) (command "line" pt1 pt2 pt3 pt1 "") ) ( ( s1 s2) ;For sorting given sides in ascending order (progn (setq temp1 s2) (setq s2 s1) (setq s1 temp1) ) () ) (if (> s2 s3) (progn (setq temp2 s3) (setq s3 s2) (setq s2 temp2) ) () ) (if (> s1 s2) (progn (setq temp3 s2) (setq s2 s1) (setq s1 temp3) ) () ) (cond ( (> (+ s1 s2) s3) (setq pt1 (getpoint "Enter insertion point of triangle: ")) (setq pt2 (list (+ (car pt1) s1) (cadr pt1))) (setq x (/ (+ (* s1 s1) (- (* s2 s2) (* s3 s3))) (* 2 s1))) (setq z (- (* s2 s2) (* x x))) (setq y (sqrt z)) (setq pt3 (list (+ (car pt1) x) (+ (cadr pt1) y))) (command "line" pt1 pt2 pt3 pt1 "") (cond

( (and (= s1 s2) (= s2 s3)) (princ "Triangle is equilateral") ) ( (or (= s1 s2) (= s2 s3) (= s1 s3)) (princ "Triangle is isosceles") ) (princ "Triangle is scalene") )

;Condition for equilateral

;Condition for isosceles

) ( ( dis r) (princ "Point selected lies outside circle") ) ( (< dis r) (princ "Point selected lies inside circle") ) ( (= dis r) (princ "Point lies on circle") ) ) ) ******************OUTPUT******************** C:PROG5 Command: PROG5 Select center of circle: Enter radius of circle: 5 Select any point on the screen: Point selected lies outside circle

NAME ROLL NO PROGRAM 6 ( defun c:PROG6() (setq a (entget (car (entsel "Select object: ")))) (cond ( (= (cdr (assoc 0 a)) "LINE") (setq pt1 (cdr (assoc 10 a))) (setq pt2 (cdr (assoc 11 a))) (princ "End coordinates are ") (princ pt1) (princ pt2) (setq len (distance pt1 pt2)) (princ "Length of line is ") (princ len) ) ( (= (cdr (assoc 0 a)) "CIRCLE") (setq c (cdr (assoc 10 a))) (princ "Center of circle is ") (princ c) (setq r (cdr (assoc 40 a))) (princ "Radius of circle is ") (princ r) ) ) (princ) ) *************OUTPUT*************************** C:PROG6 Command: PROG6 Select object: Center of circle is (25.3331 13.5295 0.0) Radius of circle is 6.15538

NAME ROLL NO PROGRAM 7 ( defun c:PROG7() (setq c (getpoint "Select center of circle: ")) (setq r (getreal "Enter radius of circle: ")) (command "circle" c r) (setq opt (getint "Select option for hatching 1 or 2 : ")) (if (= opt 1) (progn (command "bhatch" "select") (setq a (entsel "Select object to hatch: ")) (command a "" "") ) (progn (command "bhatch" "internal" "") (setq b (getpoint "Select internal point for hatching: ")) (command b "") ) ) ) ************OUTPUT******************** Command: PROG7 Select center of circle: Enter radius of circle: 5 Select option for hatching 1 or 2 : 1

NAME ROLL NO PROGRAM 8 ( defun c:PROG8() (setq c1 (getpoint "Select center of arc: ")) (setq pt1 (getpoint "Select start point of arc: ")) (setq pt2 (getpoint "Select end point of arc: ")) (command "arc" "c" c1 pt1 pt2) (setq ang (angle c1 pt1)) (princ "Included angle is ") (princ ang) (princ) (setq r (distance c1 pt1)) (setq angd (/ ang 5)) (setq i 1) (setq ang1 angd) (command "line" c1 pt1 "") ( while ( dismid dispt3) (princ "Selected point is to the left of midpoint of line") ) ( (< dismid dispt3) (princ "Selected point is to the right of midpoint of line") ) ( (= dismid dispt3) (princ "You have selected the midpoint") ) ) ) *****************OUTPUT************************ Command: PROG10 Select starting point of line: Select endpoint of line: Select a point on the line: Selected point is to the right of midpoint of line

NAME ROLL NO. PROGRAM 11 ( defun c:PROG11_2() (setq x (getint "Enter series variable: ")) (setq n (getint "Enter length of series: ")) (setq i 1) (setq sum 0) ( while (
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF