Plat

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

;;; start the program

(defun c:rect_shim (/)


;;; drawing setup
(setq osm (getvar "osmode")) ; gets osnap settings and assigns to osm
(setvar "osmode" 0) ; turns osnap settings off
;;; user input
(setq sp (getpoint "\nPick the starting point "))
(setq height (getreal "\nWhat is the height of the rectangle shim? "))
(setq width (getreal "\nWhat is the width of the rectangle shim? "))
(setq drillsize (getreal "\nWhat is the size of the drilled holes? "))
(setq offset-y (getreal "\nWhat is the offset of the drilled hole on the y axis?
"))
(setq offset-x (getreal "\nWhat is the offset of the drilled hole on the x axis?
"))
;;; setup layers
(command "layer" "n" "rectangle_shim" "c" "14" "rectangle_shim" "")
(command "layer" "n" "dimension" "c" "red" "dimension" "")
(command "layer" "n" "text" "c" "green" "text" "")
(command "layer" "n" "center" "c" "yellow" "center" "lt" "center" "center" "")
(command "layer" "n" "hidden" "c" "magenta" "hidden" "lt" "hidden" "hidden" "")
(command "layer" "n" "section" "c" "cyan" "section" "lt" "phantom" "section" "")
;;; do math
(setq x1 (car sp)
x2 (+ x1 offset-x)
x4 (+ x1 width)
x3 (- x4 offset-x)
)
(setq y1 (cadr sp)
y2 (+ y1 offset-y)
y4 (+ y1 height)
y3 (- y4 offset-y)
)
;;; point assignments
(setq p1 (list x1 y1 )
p2 (list x4 y1 )
p3 (list x4 y4 )
p4 (list x1 y4 )
p5 (list x2 y2 )
p6 (list x3 y2 )
p7 (list x3 y3 )
p8 (list x2 y3 )
)
;;; lets draw
(command "layer" "s" "rectangle_shim" "" ) ; sets layer to the rectangle_shim la
yer
(command "line" p1 p2 p3 p4 "c")
(command "circle" p5 "d" drillsize)
(command "circle" p6 "d" drillsize)
(command "circle" p7 "d" drillsize)
(command "circle" p8 "d" drillsize)
;;; dimension the drawing
(command "layer" "s" "dimension" "" ) ; sets layer to the dimension layer
(setq circlept (list (+ (car p5) (/ drillsize 2.0)) (cadr p5) ))
(command "dimcenter" circlept)
(setq circlept (list (+ (car p6) (/ drillsize 2.0)) (cadr p6) ))
(command "dimcenter" circlept)
(setq circlept (list (+ (car p7) (/ drillsize 2.0)) (cadr p7) ))

(command "dimcenter" circlept)


(setq circlept (list (+ (car p8) (/ drillsize 2.0)) (cadr p8) ))
(command "dimcenter" circlept)
(setq offorigin (getvar "dimexo"))
(setvar "dimexo" 0.1875)
(command "dimlinear" p5 p6 (list (car sp) (- (cadr sp) 1.0)))
(command "dimlinear" p5 p1 (list (car sp) (- (cadr sp) 1.0)))
(command "dimlinear" p2 p3 (list (+ (car p2) 1.0) (cadr p2)))
(command "dimlinear" p4 p3 (list (car p4) (+ (cadr p4) 1.0)))
(command "dimlinear" p5 p8 (list (- (car sp) 1.0)(cadr sp)))
(command "dimvertical" p5 p1 (list (- (car sp) 1.0)(cadr sp)))
(command "dimdiameter" (list (+ (car p8) (/ drillsize 2.0))(cadr p8)) (list (- (
car p4) 1.0)(+
(cadr p4) 1.0 )))
;;; end of program
(command "layer" "s" "0" "")
(command "zoom" "e")
(setvar "osmode" osm)
(setvar "dimexo" offorigin)
;(gc)
(princ)
)

You might also like