; Autor : Adrian F ; Erstellt: 28.07.2008 ; Winkel ; Dateiname: pero_Winkel.lsp ; Version: 1.1 ; 1.0 erste Final ; Read-ltab-from-file by Patrick Weber 12.11.2008 ; 1.1 ; generic sd-set-logical-table-contents-from-file der_Wolfgang@Cad.de 16nov2008 ; some UI adaptions der_Wolfgang@Cad.de 16nov2008 (in-package :custom) (use-package :OLI) ; ------------ Wertetabellen -------------------------------- (defvar WINKEL_GS_FILE) (defvar WINKEL_UGS_FILE) ; ------------ Pfade anpassen! ------------------------------ ;; manually ;(setq WINKEL_GS_FILE "C:/test/DIN-EN-10056-1-Gleichschenklig.tab") ;(setq WINKEL_UGS_FILE "C:/test/DIN-EN-10056-1-Ungleichschenklig.tab") ;; automatically -> same dir as this lisp file (setq WINKEL_GS_FILE (format nil "~A/DIN-EN-10056-1-Gleichschenklig.tab" (directory-namestring *load-truename*))) (setq WINKEL_UGS_FILE (format nil "~A/DIN-EN-10056-1-Ungleichschenklig.tab" (directory-namestring *load-truename*))) ; ---------------------------------------------------------------- ;; create logical and display table once during load ; ---------------------------------------------------------------- (sd-create-logical-table "DIN-EN-10056-1-Ungleichschenklig" :columns '(:Benennung :a1 :b1 :s1 :r1 :r11) :columnNames '("Bezeichnung" "a" "b" "s" "R1" "R2") :types '(:string :length :length :length :length :length) :units '(nil :mm :mm :mm :mm :mm) :contents '() ) (sd-create-display-table "DIN-EN-10056-1-Ungleichschenklig" :tableTitle "DIN-EN-10056-1-Ungleichschenklig" :logicalTable "DIN-EN-10056-1-Ungleichschenklig" :columns '(:Benennung :a1 :b1 :s1 :r1 :r11) :applyColumns '(:a1 :b1 :s1 :r1 :r11) :displayHeight '(100 850) :filterStatusLine nil :selectionMode :single-row :applyAction :default-tokens ) (sd-create-logical-table "DIN-EN-10056-1-Gleichschenklig" :columns '(:Benennung :a2 :a22 :s2 :r2 :r22) :columnNames '("Bezeichnung" "a" "a" "s" "R1" "R2") :types '(:string :length :length :length :length :length) :units '(nil :mm :mm :mm :mm :mm) :contents '() ) (sd-create-display-table "DIN-EN-10056-1-Gleichschenklig" :tableTitle "DIN-EN-10056-1-Gleichschenklig" :logicalTable "DIN-EN-10056-1-Gleichschenklig" :columns '(:Benennung :a2 :a22 :s2 :r2 :r22) :applyColumns '(:a2 :a2 :s2 :r2 :r22) :displayHeight '(100 850) :filterStatusLine nil :selectionMode :single-row :applyAction :default-tokens ) ; ---------------------------------------------------------------- (unless (fboundp' oli::sd-read-from-string) ;; for rather old OSD's (defun sd-read-from-string (str) (read-from-string str)) ) ;; ---------------------------------------------------------------- ;; caller has to make sure that width of ltab and contents (types) ;; match to the file read ;; ---------------------------------------------------------------- (defun sd-set-logical-table-contents-from-file (ltab csv-file-name &key (ignore-head-lines 0) (separator ",")) ;; some error handling (unless (sd-logical-table-p ltab) (return-from sd-set-logical-table-contents-from-file :no-table)) (unless (sd-inq-file-status csv-file-name :existence) (return-from sd-set-logical-table-contents-from-file :file-does-no-exist)) (unless (sd-inq-file-status csv-file-name :read-access) (return-from sd-set-logical-table-contents-from-file :file-not-readable)) ;; now we really start to work (let (line-of-file new-table-contents) (with-open-file (csv-file csv-file-name :direction :input :if-does-not-exist nil) (dotimes (i ignore-head-lines) (read-line csv-file nil)) ; Header überspringen (loop while (setq line-of-file (read-line csv-file nil)) do (setq line-of-file (sd-string-split line-of-file separator)) (push (mapcar #'(lambda (cell) (sd-read-from-string (sd-string-trim cell))) line-of-file) new-table-contents) ) ;; end loop ) ;;end with-open-file (sd-change-logical-table-contents ltab :contents (nreverse new-table-contents)) ;; let's have a nice return value for 'successful read' (length new-table-contents) ) ;; end let ) ; ---------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (sd-defdialog 'Winkel_DIN_EN_100562 :dialog-title "Winkel DIN EN 10056" :toolbox-button t :variables '( (A_PART :value-type :part-incl-new :modifies :contents :title "Teil" :prompt-text "Name für den Winkel eingeben") (A_ASSEM :value-type :assembly :modifies :contents :title "Baugruppe" :initial-value "/" :prompt-text "Baugruppe auswaehlen.") ("Position") (NULLPUNKT :toggle-type :boolean :title "im Nullpunkt" :push-action (nullpunkt)) (Startpunkt :value-type :point-3d) (Richtung :value-type :measure-direction :prompt-text "Richtung in Z") (Abstand :value-type :length :prompt-text "Abstand vom Startpunkt" :initial-value 0) (WINKEL :value-type :angle :title "Winkel" :initial-value 0 :proposals () :auto-add-proposal t :proposals-order :sorted :prompt-text "Winkel angeben.") ("Geometrie") (querschnitt :expand-shrink ((A1 B1 S1 R1 R11 Laenge) (A2 S2 R2 R22 Laenge)) :expand-shrink-toggle-type :toggle-pair :expand-token :Ungleichschenklig :expand-title "Ungleichschenklig" :shrink-token :Gleichschenklig :shrink-title "Gleichschenklig" ) (A1 :value-type :length :title "Schenkel A" :show-input-tool (sd-show-display-table "DIN-EN-10056-1-Ungleichschenklig" :position (list (sd-get-variable-ui-properties 'Winkel_DIN_EN_100562 :A1 :tb) :leftcenter +50 0)) :hide-input-tool (sd-hide-display-table "DIN-EN-10056-1-Ungleichschenklig" :ignorePin t) :prompt-text "LĖnge angeben") (B1 :value-type :length :title "Schenkel B" :prompt-text "LĖnge angeben") (S1 :value-type :length :title "Dicke S" :prompt-text "LĖnge angeben") (R1 :value-type :length :title "Radius 1" :prompt-text "LĖnge angeben") (R11 :value-type :length :title "Radius 2" :prompt-text "LĖnge angeben") (A2 :value-type :length :title "Schenkel A" :show-input-tool (sd-show-display-table "DIN-EN-10056-1-Gleichschenklig" :position (list (sd-get-variable-ui-properties 'Winkel_DIN_EN_100562 :A2 :tb) :leftcenter +50 0)) :hide-input-tool (sd-hide-display-table "DIN-EN-10056-1-Gleichschenklig" :ignorePin t) :prompt-text "LĖnge angeben") (S2 :value-type :length :title "Dicke S" :prompt-text "LĖnge angeben") (R2 :value-type :length :title "Radius 1" :prompt-text "LĖnge angeben") (R22 :value-type :length :title "Radius 2" :prompt-text "LĖnge angeben") (Laenge :value-type :length :proposals () :auto-add-proposal t :proposals-order :sorted :prompt-text "LĖnge angeben") ("-") (RICHT :range ( (:+W :label "+W") (:-W :label "-W") (:both_sides :label "beidseitig")) :title "Richtung" :prompt-text "Richtung angeben") ("Werkstoff angeben") (ABK :value-type :string :title "Werkstoff" :show-input-tool (sd-show-display-table "Werkstoff-Dichte-Liste" :position (list (sd-get-variable-ui-properties 'Winkel_DIN_EN_100562 :ABK :tb) :leftcenter +50 0)) :hide-input-tool (sd-hide-display-table "Werkstoff-Dichte-Liste" :ignorePin t) :proposals () :auto-add-proposal t :proposals-order :sorted :prompt-text "Werkstoff auswaehlen" );;ABK (DICHTE :value-type :positive-number :title "Dichte" :proposals () :auto-add-proposal t :proposals-order :sorted :prompt-text "Dichte eingeben") #| ;; wozu denn das? (Farbe2 :value-type :string :toggle-type :invisible :after-input (progn (sd-set-variable-status "FARBE" :value (sd-rgb-to-color (read-from-string Farbe2))) (setq FARBE (sd-rgb-to-color (read-from-string Farbe2))))) |# (FARBE :value-type :rgb-color :title "Farbe") ("-") (NEXT :push-action (Winkel-erstellen) :after-input (setf Startpunkt nil A1 nil A2 nil B1 nil S1 nil S2 nil R1 nil R11 nil R2 nil R22 nil Laenge nil) :next-variable 'Startpunkt) ) :after-initialization '(progn ;; alternatives to load the table from file not so many times.. ;; (when (> (file-date file) last-time-read) .... (when (= (sd-get-logical-table-number-of-rows "DIN-EN-10056-1-Ungleichschenklig") 0) (sd-set-logical-table-contents-from-file "DIN-EN-10056-1-Ungleichschenklig" WINKEL_UGS_FILE :ignore-head-lines 1)) (when (= (sd-get-logical-table-number-of-rows "DIN-EN-10056-1-Gleichschenklig") 0) (sd-set-logical-table-contents-from-file "DIN-EN-10056-1-Gleichschenklig" WINKEL_GS_FILE :ignore-head-lines 1)) ) ; end after-initialization :local-functions '( (Winkel-erstellen () (sd-call-cmds (let (p0 p1 p2 p3 p4 p5) (create_workplane :new :name "AEF" :pt_dir :origin Startpunkt :normal (first Richtung) :done) (position_wp "/AEF" :translate :dir_len :w Abstand) (when (and A1 B1) (setf p0 (make-gpnt2d :x 0 :y 0) ;; links unten p1 (make-gpnt2d :x B1 :y 0) ;; rechts unten p2 (make-gpnt2d :x B1 :y S1) ;; rechts mitte p3 (make-gpnt2d :x S1 :y S1) ;; innen mitte p4 (make-gpnt2d :x S1 :y A1) ;; rechts oben p5 (make-gpnt2d :x 0 :y A1)) ;; links oben (GEOMETRY_MODE :REAL) ;ändert die Geometrieart auf "Geometrie" falls das nicht eingestellt ist (polygon (gpnt2d 0 0) (gpnt2d B1 0) (gpnt2d B1 S1) (gpnt2d S1 S1) (gpnt2d S1 A1) (gpnt2d 0 A1) :close) (when (> R1 0) (fillet :create :fillet_radius R1 p3) ) (when (> R11 0) (fillet :create :fillet_radius R11 p2 p4) ) ) (when (and A2 S2) (setf p0 (make-gpnt2d :x 0 :y 0) ;; links unten p1 (make-gpnt2d :x A2 :y 0) ;; rechts unten p2 (make-gpnt2d :x A2 :y S2) ;; rechts mitte p3 (make-gpnt2d :x S2 :y S2) ;; innen mitte p4 (make-gpnt2d :x S2 :y A2) ;; rechts oben p5 (make-gpnt2d :x 0 :y A2)) ;; links oben (GEOMETRY_MODE :REAL) ;ändert die Geometrieart auf "Geometrie" falls das nicht eingestellt ist (polygon (gpnt2d 0 0) (gpnt2d A2 0) (gpnt2d A2 S2) (gpnt2d S2 S2) (gpnt2d S2 A2) (gpnt2d 0 A2) :close) (when (> R2 0) (fillet :create :fillet_radius R2 p3) ) (when (> R22 0) (fillet :create :fillet_radius R22 p2 p4) ) ) (if (/= WINKEL 0) (rotate_2d :select :edge_2d :all_2d :center_point P0 :angle WINKEL :repeat_factor 1 :keep :off) );;if (extrude :sel_part A_PART :direction RICHT :keep_profile :no :distance Laenge) (set_part_base_color :parts A_PART :color FARBE) (set_part_base_density :parts A_PART :dens DICHTE) (CHANGE_PA_OWNER :PARTS_ASSEMBLIES A_PART :NEW_OWNER A_ASSEM) (delete_3d "/AEF" ) );progn );sd-call-cmds );Winkel-erstellen (nullpunkt () (setq Startpunkt 0,0,0) (setq RICHTUNG (list 0,0,1)) );nullpunkt );;local-functions :ok-action '(Winkel-erstellen) :help-action '(progn (display :show) (display "Dieses Tool wurde von Adrian F entwickelt!") (display " ")) ) ; end sd-defdialog 'Winkel-DIN-EN-100562