;;--------------------------------------------------------------------------------* ;; Modulbeschreibung: ;; Erstellt,löscht und ... Fasen/Rundung nach Geometrieregeln ;;--------------------------------------------------------------------------------* ;; Dateiname: Kanten_aendern.lsp ;; Version : 1.02 ;; 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 ;; 30.03.2023 Hinweise mittels 'display' entfernt und durch Anzeige 'display-only' ;; ersetzt. Hierzu zwei 'defun' hinzugefügt. Geändert durch MiBr (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 :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 :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 k_laenge (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 r_flaeche (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 r_flaeche (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 :after-input (sd-set-variable-status 'n_kanten :value (suche_die_kanten k_laenge gew_kanten tol_mm)) ) (gew_rund :selection *sd-blend-3d-seltype* :prompt-text "Rundungen wählen" :title "Rundungen wählen" :multiple-items t :initial-value nil :after-input (sd-set-variable-status 'n_flaechen :value (suche_die_flaechen r_flaeche gew_rund tol_qmm)) ) (gew_fasen :selection *sd-chamfer-3d-seltype* :prompt-text "Fasen wählen" :title "Fasen wählen" :multiple-items t :initial-value nil :after-input (sd-set-variable-status 'n_flaechen :value (suche_die_flaechen r_flaeche gew_fasen tol_qmm)) ) (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" :after-input (when (and k_laenge gew_kanten tol_mm) (sd-set-variable-status 'n_kanten :value (suche_die_kanten k_laenge gew_kanten tol_mm))) ) (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" :after-input (progn (when (and r_flaeche gew_rund tol_qmm) (sd-set-variable-status 'n_flaechen :value (suche_die_flaechen r_flaeche gew_rund tol_qmm))) (when (and r_flaeche gew_fasen tol_qmm) (sd-set-variable-status 'n_flaechen :value (suche_die_flaechen r_flaeche gew_fasen tol_qmm))) ) ) (k_laenge :title "Kantenlänge" :value-type :display-only ) (r_flaeche :title "Flächengröße" :value-type :display-only ) (n_kanten :title "Kanten" :value-type :display-only :gui-value (length n_kanten) ) (n_flaechen :title "Flächen" :value-type :display-only :gui-value (length n_flaechen) ) ("-") (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 ) ) ;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 () (when (and n_kanten k_laenge) (if tool_rund (sd-call-cmds (add_blends n_kanten :const_rad flaechen_gr :check)) (cond ((equal fasen_art 0) (sd-call-cmds (chamfer n_kanten :distance flaechen_gr :check))) ((equal fasen_art 1) (sd-call-cmds (chamfer n_kanten :dist_angle :new_angle_dist flaechen_gr (* fasen_winkel (/ pi 180)) (when (equal f_wechsel t) :da_reverse) :check))) ) ) ) (sd-set-variable-status 'gew_kanten :value nil) (sd-set-variable-status 'ref_laenge :value nil) (sd-set-variable-status 'n_kanten :value nil) (sd-set-variable-status 'k_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 (when (and n_flaechen r_flaeche) (cond ((= index 1) (sd-call-cmds (modify_blends n_flaechen :const_radius :new_radius flaechen_gr :check))) ((= index 2) (sd-call-cmds (delete_blend n_flaechen :check))) ((= index 3) (sd-call-cmds (set_face_color n_flaechen 10066329))) ) ) (when (and n_flaechen r_flaeche) (cond ((and (= index 1) (equal fasen_art 0)) (sd-call-cmds (modify_chamfers n_flaechen :distance :new_distance flaechen_gr :check))) ((and (= index 1) (equal fasen_art 1)) (sd-call-cmds (modify_chamfers n_flaechen :dist_angle :new_angle_dist flaechen_gr (* fasen_winkel (/ pi 180)) (when (equal f_wechsel t) :reverse) :check))) ((= index 2) (sd-call-cmds (remove_chamfers n_flaechen :check))) ((= index 3) (sd-call-cmds (set_face_color n_flaechen 10066329))) ) ) ) ;; effektiver wäre ;; (setq gew_rund nil ref_rund nil gew_fasen nil ref_fase nil k_laenge nil r_flaeche 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) (sd-set-variable-status 'r_flaeche :value nil) (sd-set-variable-status 'n_flaechen :value nil) ) ;end do_aendern ;Visible logik ;-) (do-visible () (cond ((and tool_rund erst_flaeche) (visible-buttons t nil nil nil nil)) ;Rundung erstellen 1 ((and tool_rund aend_flaeche) (visible-buttons nil t nil t nil)) ;Rundung ändern 2 ((and tool_fase erst_flaeche) (visible-buttons t nil t nil nil)) ;Fase erstellen 3 ((and tool_fase aend_flaeche) (visible-buttons nil t t nil 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"))) (sd-set-variable-status 'ueberloe :title (format nil "~A löschen" (if tool_rund "Rundung" "Fase"))) ) (visible-buttons (a b c d e) ; Rundung Fase ;Beide für´s erstellen 1 2 3 4 (sd-set-variable-status 'ref_laenge :visible a) ;Referenz Kante x x a (sd-set-variable-status 'ueberers :visible a) ;Rundung erstellen x x a (sd-set-variable-status 'gew_kanten :visible a) ;Kanten wählen x x a (sd-set-variable-status 'tol_mm :visible a) ;Toleranz [±mm] x x a (sd-set-variable-status 'k_laenge :visible a) ;Kantenlänge x x a (sd-set-variable-status 'n_kanten :visible a) ;Kanten x x a ;Beide für´s ändern (sd-set-variable-status 'uebercol :visible b) ;Farbe ändern x x b (sd-set-variable-status 'ueberloe :visible b) ;Rundung löschen x x b (sd-set-variable-status 'ueberaen :visible b) ;Rundung ändern x x b (sd-set-variable-status 'tol_qmm :visible b) ;Toleranz [±mm²] x x b (sd-set-variable-status 'r_flaeche :visible b) ;Flächengröße x x b (sd-set-variable-status 'n_flaechen :visible b) ;Flächen x x b ;Nur für Fasen ändern (sd-set-variable-status 'fasen_art :visible c) ;Art x x c (sd-set-variable-status 'fasen_winkel :visible c) ;Winkel x x c (sd-set-variable-status 'f_wechsel :visible c) ;Winkel x x c ;Nur für´s Verundunden ändern (sd-set-variable-status 'ref_rund :visible d) ;Ref. Rundung x d (sd-set-variable-status 'gew_rund :visible d) ;Rundungen wählen x d ;Nur für´s Fasen ändern (sd-set-variable-status 'ref_fase :visible e) ;Referenz Fase x e (sd-set-variable-status 'gew_fasen :visible e) ;Fasen wählen x e ) ;end visible-buttons ) ;end local ) ;end sd-def (defun suche_die_kanten (k_laenge gew_kanten tol_mm) (let (istlang die_kanten) (dolist (i gew_kanten) (setf istlang (sd-call-cmds (measure_dist :edge_length i))) (when (and (< (- istlang tol_mm) k_laenge) (> (+ istlang tol_mm) k_laenge)) (push i die_kanten)) ) ;end dolist die_kanten ) ) (defun suche_die_flaechen (r_flaeche gew_flaechen tol_qmm) (let (istgross die_flaechen) (dolist (i gew_flaechen) (setf istgross (sd-call-cmds (get_vol_prop :for_face i :area ))) (when (and (< (- istgross tol_qmm) r_flaeche) (> (+ istgross tol_qmm) r_flaeche)) (push i die_flaechen)) ) ;end dolist die_flaechen ) )