#|
|# (in-package :EXAMPLES) (use-package :OLI) (sd-defdialog 'slot :dialog-control :sequential-loop :precondition '(let ((curr-wp (sd-inq-curr-wp))) (when (and curr-wp (not (sd-inq-obj-contents-read-only-p curr-wp))) :ok)) :variables '((FBACK) (POINT_1 :value-type :point-2d :prompt-text "Pick first center point." :after-input (progn (setq fback (sd-start-rubberline-feedback point_1)) (sd-call-cmds (c_point point_1)))) (POINT_2 :value-type :point-2d :prompt-text "Pick second center point." :after-input (progn (sd-end-feedback fback) (sd-call-cmds (c_point point_2)))) (WIDTH :value-type :positive-length :prompt-text "Specify width of slot." :after-input (progn (sd-call-cmds (delete_2d :c_user_point :all_2d)) (sd-end-feedback fback) (sd-call-cmds (create-slot point_1 point_2 width)) (setq point_1 nil) (setq point_2 nil)))) :cleanup-action '(progn (sd-end-feedback fback) (when point_1 (sd-call-cmds (delete_2d :c_user_point point_1))) (when point_2 (sd-call-cmds (delete_2d :c_user_point point_2))))) (defun create-slot (p1 p2 width) (let (p1p2 normal offset-vec) ;;----- Calculation: ----- (setq p1p2 (sd-vec-subtract p2 p1)) ;; Calculate Normal of p1p2 vector: (setq normal (make-gpnt2d :x (- (gpnt2d_y p1p2)) :y (gpnt2d_x p1p2))) ;; Normalize Normal: (setq normal (sd-vec-normalize normal)) ;; Calculate Offset Vector: (setq offset-vec (sd-vec-scale normal (/ width 2.0))) ;; Create infinite construction lines through the center points: (c_line_inf :two_points p1 p2) (c_line_inf :two_points p1 (sd-vec-add p1 offset-vec)) (c_line_inf :two_points p2 (sd-vec-add p2 offset-vec)) ;; Create Slot: (line :two_points (sd-vec-add p1 offset-vec) (sd-vec-add p2 offset-vec)) (line :two_points (sd-vec-subtract p1 offset-vec) (sd-vec-subtract p2 offset-vec)) (arc :center p1 (sd-vec-add p1 offset-vec) (sd-vec-subtract p1 offset-vec)) (arc :center p2 (sd-vec-subtract p2 offset-vec) (sd-vec-add p2 offset-vec)))) ;