Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ql:quickload 'cl-svg)
- (use-package 'cl-svg)
- (defparameter +height+ 133.4)
- (defparameter +hp+ 5.08) ;Horizontal pitch
- (defparameter +hole-offet-vertical+ 3.0) ;Distance from edge of module and screw hole
- (defparameter +hole-offet-horizontal+ 7.5) ;Distance from edge of module and screw hole
- (defvar *width*)
- (setf *width* 4)
- (defparameter +screw-radius+ "1.75")
- (defparameter +x-offset+ 3.5)
- (defparameter +y-offset+ 3.5)
- (let* ((scene (make-svg-toplevel 'svg-1.1-toplevel :height "150mm" :width "150mm"
- :viewBox "0 0 150 150")))
- (draw scene (:path :d (path (move-to 0 0) ; Generate outline of module
- (line-to (* *width* +hp+) 0)
- (line-to (* *width* +hp+) +height+)
- (line-to 0 +height+)
- (line-to 0 0)
- (close-path)) :stroke "red" :stroke-width "1" :fill "white"))
- (screw-hole scene 'top-left)
- (screw-hole scene 'top-right)
- (screw-hole scene 'bottom-right)
- (screw-hole scene 'bottom-left)
- (with-open-file (s "test.svg" :direction :output :if-exists :supersede)
- (stream-out s scene)))
- (deftype screw-positions () '(member top-left top-right
- bottom-left bottom-right))
- (defun screw-hole (scene position)
- "Place a screw hole"
- (let* ((x-offset 0)
- (y-offset 0))
- (cond ((eq position 'top-left) (setf x-offset +x-offset+)
- (setf y-offset +y-offset+))
- ((eq position 'top-right) (setf x-offset (- (* +hp+ *width*) +x-offset+))
- (setf y-offset +y-offset+))
- ((eq position 'bottom-left) (setf x-offset +x-offset+)
- (setf y-offset (- +height+ +y-offset+)))
- ((eq position 'bottom-right) (setf x-offset (- (* +hp+ *width*) +x-offset+))
- (setf y-offset (- +height+ +y-offset+))))
- (draw scene (:circle :cx x-offset :cy y-offset :r +screw-radius+ :stroke "red" :fill "white"
- :stroke-width "1"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement