;;--------------------------------------------------------------------------* ;; Modulbeschreibung: ;; Erstellt,löscht und ... Fasen/Rundung nach Geometrieregeln ;;--------------------------------------------------------------------------* ;; Dateiname: Kanten_aendern.lsp ;; Version : 1.01 ;; Datum : 24.03.2023 ;; Author : MiBr ;; Reference: https://ww3.cad.de/foren/ubb/Forum29/HTML/004914.shtml ;;--------------------------------------------------------------------------* ;; Als Grundlage diente das Tool Kanten.lsp von der Seite OSD.CAD.de ;;--------------------------------------------------------------------------* ;; changes: ;; 27.03.2023 some button titles adapted dynamically by der_Wolfgang@forum@Cad.de ;; 28.03.2023 next-variable = symbol fixed by der_Wolfgang@forum@Cad.de ;; 28.03.2023 proposals persisted by der_Wolfgang@forum@Cad.de (in-package :mibr) (use-package :oli) (sd-defdialog 'kanten_aendern :dialog-title "Fasen/Rundungen nach Georegeln" :toolbox-button t :persistent-proposals t ;; keep user entered values of proposals across osdm sessions :after-initialization '(progn (do-visible) (sd-disable-must-variable-check)) ;Variablencheck der :ok-action deaktivieren!!! :start-variable 'ref_laenge :variables '( ("Art") (tool_rund :title "Rundung" :value-type :boolean :toggle-type :grouped-toggle :persistent-data-storage t :after-input (do-visible) :next-variable (if erst_flaeche 'ref_laenge 'ref_rund) :indicator-type :none :title-alignment :center ) (tool_fase :title "Fase" :value-type :boolean :toggle-type :grouped-toggle :persistent-data-storage t :after-input (do-visible) :next-variable (if erst_flaeche 'ref_laenge 'ref_fase) :indicator-type :none :title-alignment :center ) ("Funktion") (erst_flaeche :title "Erstellen" :value-type :boolean :toggle-type :grouped-toggle :initial-value t :after-input (do-visible) :next-variable 'ref_laenge :indicator-type :none :title-alignment :center ) (aend_flaeche :title "Ändern" :value-type :boolean :toggle-type :grouped-toggle :initial-value nil :after-input (do-visible) :next-variable (if tool_rund 'ref_rund 'ref_fase) :indicator-type :none :title-alignment :center ) ("Einstellungen") (fasen_art :range ((0 :label "Abstand") (1 :label "Abst/Winkel")) :title "Art" :after-input (if (equal fasen_art 0) (progn (sd-set-variable-status 'fasen_winkel :enable nil) (sd-set-variable-status 'f_wechsel :enable nil)) (progn (sd-set-variable-status 'fasen_winkel :enable t) (sd-set-variable-status 'f_wechsel :enable t)) ) ;end if ) (flaechen_gr :value-type :number :title "Größe" :initial-value 1 :prompt-text "Abstand eingeben" :proposals (0.5 1 2 3 4 5 10 15 20) :auto-add-proposals t ) (fasen_winkel :value-type :number :title "Winkel" :initial-value 30 :prompt-text "Winkel eingeben" :proposals (5 10 15 22.5 30 60) :auto-add-proposals t :initial-enable nil ) (f_wechsel :value-type :boolean :toggle-type :wide-toggle :title "Fläche wechseln" :initial-enable nil :initial-value nil ) ("Auswahl") (ref_laenge :selection (*sd-arc-3d-seltype* *sd-circle-3d-seltype* *sd-line-3d-seltype*) :title "Referenz Kante" :prompt-text "Referenz Kante auswählen" :after-input (setf klaenge (sd-call-cmds (measure_dist :edge_length ref_laenge))) :next-variable 'gew_kanten ) (ref_rund :selection *sd-blend-3d-seltype* :title "Referenz Rundung" :prompt-text "Referenz Rundung auswählen" :after-input (setf kflaeche (sd-call-cmds (get_vol_prop :for_face ref_rund :area))) :next-variable 'gew_rund ) (ref_fase :selection *sd-chamfer-3d-seltype* :title "Referenz Fase" :prompt-text "Referenz Fase auswählen" :after-input (setf kflaeche (sd-call-cmds (get_vol_prop :for_face ref_fase :area))) :next-variable 'gew_fasen ) (gew_kanten :selection (*sd-arc-3d-seltype* *sd-circle-3d-seltype* *sd-line-3d-seltype*) :prompt-text "Kanten wählen" :title "Kanten wählen" :multiple-items t :initial-value nil ) (gew_rund :selection *sd-blend-3d-seltype* :prompt-text "Rundungen wählen" :title "Rundungen wählen" :multiple-items t :initial-value nil ) (gew_fasen :selection *sd-chamfer-3d-seltype* :prompt-text "Fasen wählen" :title "Fasen wählen" :multiple-items t :initial-value nil ) (tol_mm :value-type :positive-number :title "Toleranz [±mm]" :initial-value 0.0001 :proposals (0.5 0.2 0.1 0.01 0.001 0.001 0.0001) :auto-add-proposals t :prompt-text "± Toleranz der Kantenabweichung angeben" ) (tol_qmm :value-type :positive-number :title "Toleranz [±mm²]" :initial-value 0.01 :proposals (0.5 0.2 0.1 0.01 0.001 0.001 0.0001) :auto-add-proposals t :prompt-text "± Toleranz der Flächenabweichung angeben" ) ("-") (uebercol :title "Farbe ändern" :push-action (do_aendern 3) :toggle-type :grouped-toggle :next-variable (if tool_rund 'ref_rund 'ref_fase) ) (ueberloe :title "Flächen löschen" :push-action (do_aendern 2) :toggle-type :grouped-toggle :next-variable (if tool_rund 'ref_rund 'ref_fase) ) (ueberaen :title "Flächen ändern" :push-action (do_aendern 1) :toggle-type :wide-toggle :next-variable (if tool_rund 'ref_rund 'ref_fase) ) (ueberers :title "Flächen erstellen" :push-action (do_ers) :toggle-type :wide-toggle :next-variable 'ref_laenge ) ;lokale variablen (klaenge) ;; ggf. als display only var mit dem gemessenen Wert im UI mit anzeigen, beachte User Units! (kflaeche) ;; ggf. als display only var mit dem gemessenen Wert im UI mit anzeigen, beachte User Units! ) ;end var :mutual-exclusion '((tool_rund tool_fase) (aend_flaeche erst_flaeche)) :ok-action '(let (part_input) (when (or (and gew_rund ref_rund) (and gew_fasen ref_fase) (and ref_laenge gew_kanten)) (setf part_input (sd-display-warning (format nil "Eingaben wurden nicht ausgeführt!~%Zurück zum Dialog?") :title "Verundungen/Fasen" :push-1 "Ja" :push-2 "Nein" :severity :low)) (if (eql part_input :yes) (sd-return-from-ok-action))) ) ;end let :local-functions '( (do_ers () (let (istlang die_kanten) (dolist (i gew_kanten) (setf istlang (sd-call-cmds (measure_dist :edge_length i))) (when (and (< (- istlang tol_mm) klaenge ) (> (+ istlang tol_mm) klaenge)) (push i die_kanten)) ) ;end dolist (when die_kanten (if tool_rund (progn (sd-call-cmds (add_blends die_kanten :const_rad flaechen_gr :check)) (display (format nil "~a Rundungen erstellt" (length die_kanten)))) (progn (cond ((equal fasen_art 0) (sd-call-cmds (chamfer die_kanten :distance flaechen_gr :check))) ((equal fasen_art 1) (sd-call-cmds (chamfer die_kanten :dist_angle :new_angle_dist flaechen_gr (* fasen_winkel (/ pi 180)) (when (equal f_wechsel t) :da_reverse) :check))) ) (display (format nil "~a Fasen erstellt" (length die_kanten)))) ) ) ) ;end let (sd-set-variable-status 'gew_kanten :value nil) (sd-set-variable-status 'ref_laenge :value nil) ) ;end do_ers ;; hint: change 1-2-3 index to :change :delete :colouring for better code readability (do_aendern (index) (if tool_rund (progn (let (istgross die_radien) (dolist (i gew_rund) (setf istgross (sd-call-cmds (get_vol_prop :for_face i :area ))) (when (and (< (- istgross tol_qmm) kflaeche) (> (+ istgross tol_qmm) kflaeche)) (push i die_radien)) ) ;end dolist (when die_radien (cond ((= index 1) (sd-call-cmds (modify_blends die_radien :const_radius :new_radius flaechen_gr :check)) (display (format nil "~a Verrundungen geändert" (length die_radien)))) ((= index 2) (sd-call-cmds (delete_blend die_radien :check)) (display (format nil "~a Verrundungen gelöscht" (length die_radien)))) ((= index 3) (sd-call-cmds (set_face_color die_radien 10066329)) (display (format nil "~a Verrundungen eingefärbt" (length die_radien)))) ) ) ) ;end let ) (progn (let (istgross die_fasen) (dolist (i gew_fasen) (setf istgross (sd-call-cmds (get_vol_prop :for_face i :area ))) (when (and (< (- istgross tol_qmm) kflaeche) (> (+ istgross tol_qmm) kflaeche)) (push i die_fasen)) ) ;end dolist (when die_fasen (cond ((and (= index 1) (equal fasen_art 0)) (sd-call-cmds (modify_chamfers die_fasen :distance :new_distance flaechen_gr :check)) (display (format nil "~a Fasen geändert" (length die_fasen)))) ((and (= index 1) (equal fasen_art 1)) (sd-call-cmds (modify_chamfers die_fasen :dist_angle :new_angle_dist flaechen_gr (* fasen_winkel (/ pi 180)) (when (equal f_wechsel t) :reverse) :check)) (display (format nil "~a Fasen geändert" (length die_fasen)))) ((= index 2) (sd-call-cmds (remove_chamfers die_fasen :check)) (display (format nil "~a Fasen gelöscht" (length die_fasen)))) ((= index 3) (sd-call-cmds (set_face_color die_fasen 10066329)) (display (format nil "~a Fasen eingefärbt" (length die_fasen)))) ) ) ) ;end let ) ) ;; effektiver wäre ;; (setq gew_rund nil ref_rund nil gew_fasen nil ref_fase nil klaenge nil kflaeche nil) (sd-set-variable-status 'gew_rund :value nil) (sd-set-variable-status 'ref_rund :value nil) (sd-set-variable-status 'gew_fasen :value nil) (sd-set-variable-status 'ref_fase :value nil) ) ;end do_aendern (do-visible () ;; die Sichtbarkeit sollten wir besser über einen Expand Shrink vom def-dialog steuern lassen (cond ((and tool_rund erst_flaeche) (visible-buttons t nil t nil nil nil t nil t nil nil nil nil nil nil)) ;Rundung erstellen 1 ((and tool_rund aend_flaeche) (visible-buttons nil t nil t t t nil t nil t nil nil nil nil nil)) ;Rundung ändern 2 ((and tool_fase erst_flaeche) (visible-buttons t nil t nil nil nil t nil t nil t t t nil nil)) ;Fase erstellen 3 ((and tool_fase aend_flaeche) (visible-buttons nil nil nil t t t nil nil nil t t t t t t)) ;Fase ändern 4 ) (sd-set-variable-status 'ueberaen :title (format nil "~A ändern" (if tool_rund "Rundung" "Fase"))) (sd-set-variable-status 'ueberers :title (format nil "~A erstellen" (if tool_rund "Rundung" "Fase"))) ) (visible-buttons (a b c d e f g h i j k l m n o) (sd-set-variable-status 'ref_laenge :visible a) (sd-set-variable-status 'ref_rund :visible b) (sd-set-variable-status 'ueberers :visible c) (sd-set-variable-status 'uebercol :visible d) (sd-set-variable-status 'ueberloe :visible e) (sd-set-variable-status 'ueberaen :visible f) (sd-set-variable-status 'gew_kanten :visible g) (sd-set-variable-status 'gew_rund :visible h) (sd-set-variable-status 'tol_mm :visible i) (sd-set-variable-status 'tol_qmm :visible j) (sd-set-variable-status 'fasen_art :visible k) (sd-set-variable-status 'fasen_winkel :visible l) (sd-set-variable-status 'f_wechsel :visible m) (sd-set-variable-status 'ref_fase :visible n) (sd-set-variable-status 'gew_fasen :visible o) ) ;end visible-buttons ) ;end local ) ;end sd-def