;;----------------------------------------------------------------------------- ;; for CoCreate OneSpace Designer ;; Description: ;; creates an infinite construction line as bisecting line ;; * by giving 4 points or ;; * by selecting 2 straight edges/lines ;; ;;----------------------------------------------------------------------------- ;; ;; Filename : winkelhalbierende.lsp ;; Version : 1.05 ;; Datum : 18sep2008 ;; Author : Thömu@forum@cad.de ;; Download : osd.cad.de (sooner or later) ;; SD-Version : developed with 15.00 - tested with 14.50, too ;; ;;----------------------------------------------------------------------------- (in-package :custom) (use-package :OLI) (sd-defdialog 'win_halb :dialog-title '(sd-multi-lang-string "BiSecting Line" :german "Winkelhalbierende") :precondition '(if (sd-inq-curr-wp) :OK (values :error (sd-multi-lang-string "No current workplane exists." :german "Keine Arbeitsebene vorhanden")) ) :variables '( (gerade-gerade :title (sd-multi-lang-string "Linear Linear" :german "Gerade Gerade")) (LA :value-type :edge-2d :title (sd-multi-lang-string "1st Line" :german "1. Linie") :prompt-text (sd-multi-lang-string "Specify 1st Line." :german "1. Linie angeben.") ;;:initial-enable nil :initial-optional nil ;;wenn erster Button nicht angeklickt sein soll t :check-function #'(lambda (gerade) (if (sd-line-p (sd-inq-geo-props gerade)) :ok (values :error (sd-multi-lang-string "Linear Lines Only!" :german "Nur Geraden erlaubt!")))) :after-input (gerade-gerade-action) ) (LB :value-type :edge-2d :title (sd-multi-lang-string "2nd Line" :german "2. Linie") :prompt-text (sd-multi-lang-string "Specify 2nd Line." :german "2. Linie angeben.") ;;:initial-enable nil :initial-optional t :check-function #'(lambda (gerade) (if (sd-line-p (sd-inq-geo-props gerade)) :ok (values :error (sd-multi-lang-string "Linear Lines Only!" :german "Nur Geraden erlaubt!")))) :after-input (gerade-gerade-action) ) ; (punkt-punkt :title (sd-multi-lang-string "4 Points" :german "4 Punkte")) ; (P1 ; :value-type :point-2d ; :title (sd-multi-lang-string "1st Point" :german "1. Punkt") ; :prompt-text (sd-multi-lang-string "Specify 1st Point." :german "1. Punkt angeben.") ; :initial-optional t ; :after-input (punkt-punkt-action) ; ) ; (P2 ; :value-type :point-2d ; :title (sd-multi-lang-string "2nd Point" :german "2. Punkt") ; :prompt-text (sd-multi-lang-string "Specify 2nd Point." :german "2. Punkt angeben.") ; :initial-optional t ; :after-input (punkt-punkt-action) ; ) ; (P3 ; :value-type :point-2d ; :title (sd-multi-lang-string "3rd Point" :german "3. Punkt") ; :prompt-text (sd-multi-lang-string "Specify 3rd Point." :german "3. Punkt angeben.") ; :initial-optional t ; :after-input (punkt-punkt-action) ; ) ; (P4 ; :value-type :point-2d ; :title (sd-multi-lang-string "4th Point" :german "4. Punkt") ; :prompt-text (sd-multi-lang-string "Specify 4th Point." :german "4. Punkt angeben.") ; :initial-optional t ; :after-input (punkt-punkt-action) ; ) ;; some local variables (AR :initial-value nil) (BR :initial-value nil) (AP :initial-value nil) (BP :initial-value nil) ) ;; end variables :local-functions '( (gerade-gerade-action () (sd-set-variable-status 'LA :optional nil) (sd-set-variable-status 'LB :optional nil) (when (and LA LB) (setf AR (sd-line-dir (sd-inq-geo-props LA))) (setf BR (sd-line-dir (sd-inq-geo-props LB))) (setf AP (sd-line-pnt (sd-inq-geo-props LA))) (setf BP (sd-line-pnt (sd-inq-geo-props LB))) (setf AR (gpnt2d (gpnt3d_x AR) (gpnt3d_y AR))) (setf BR (gpnt2d (gpnt3d_x BR) (gpnt3d_y BR))) (setf AP (gpnt2d (gpnt3d_x AP) (gpnt3d_y AP))) (setf BP (gpnt2d (gpnt3d_x BP) (gpnt3d_y BP))) (sd-set-variable-status 'LA :optional nil) ;;wenn es nicht wieder zur ersten Linie gehen soll dann t (sd-set-variable-status 'LB :optional t) (setf LA nil) (setf LB nil) (winkel-halb-action) );;when ) ;; end gerade-gerade-action ; (punkt-punkt-action () ; (sd-set-variable-status 'P1 :optional nil) ; (sd-set-variable-status 'P2 :optional nil) ; (sd-set-variable-status 'P3 :optional nil) ; (sd-set-variable-status 'P4 :optional nil) ; (when (and P1 P2 P3 P4) ; (setf AR (sd-vec-normalize (sd-vec-subtract P2 P1))) ; (setf BR (sd-vec-normalize (sd-vec-subtract P4 P3))) ; (setf AP P1) ; (setf BP P3) ; (sd-set-variable-status 'P1 :optional t) ; (sd-set-variable-status 'P2 :optional t) ; (sd-set-variable-status 'P3 :optional t) ; (sd-set-variable-status 'P4 :optional t) ; (setf P1 nil) ; (setf P2 nil) ; (setf P3 nil) ; (setf P4 nil) ; (winkel-halb-action) ; );;when ; ) ;; end punkt-punkt-action (winkel-halb-action () (let (P5 P6 P7 VT) (if (or (sd-vec-equal-p AR BR) (sd-vec-equal-p AR (sd-vec-scale BR -1))) (progn (setf P5 (sd-vec-scale (sd-vec-add AP BP) 0.5)) (setf P6 (sd-vec-add P5 AR)) (sd-call-cmds (c_line_inf :angle P5 P6)) );;progn );;if (if (and (not (sd-vec-equal-p AR BR)) (not (sd-vec-equal-p AR (sd-vec-scale BR -1)))) (progn (setf VT (/ (+ (* (- (gpnt2d_y AP) (gpnt2d_y BP)) (gpnt2d_x AR)) (* (- (gpnt2d_x BP) (gpnt2d_x AP)) (gpnt2d_y AR))) (- (* (gpnt2d_y BR) (gpnt2d_x AR)) (* (gpnt2d_x BR) (gpnt2d_y AR))))) (setf P5 (sd-vec-add BP (sd-vec-scale BR VT))) (setf P6 (sd-vec-add P5 (sd-vec-add AR BR))) (setf P7 (sd-vec-add P5 (sd-vec-subtract AR BR))) (sd-call-cmds (c_line_inf :angle P5 P6)) (sd-call-cmds (c_line_inf :angle P5 P7)) );;progn );;if (setf P5 nil) (setf P6 nil) (setf P7 nil) (setf AR nil) (setf BR nil) (setf AP nil) (setf BP nil) );;let ) ;; end winkel-halb-action ) ;; end local-functions :cancel-action '() :ok-action '() :help-action '(sd-display-url (sd-multi-lang-string "http://osd.cad.de/lisp_3d.en.htm#51" :german "http://osd.cad.de/lisp_3d.htm#51")) ) ;; end dialog