#| created: 2009-01-22 last modified: 2009-01-23 version: 2.0 Author: Patrick Weber version 2.1 2009-01-25 der_Wolfgang@forum@cad.de * window fit is done by the create_thumbnail command * use sd-inq-file-status instead of sd-search-file * switch of workplanes recursive * add proposals * add global window handling (store+restore) * add check for current VP * sd-call-cmds fixes * germanisiert * TIP: replace 'jpg' by 'png' at all places creates better screen shots! for: ThE CaD-CoMmUnItY |# (in-package :custom) (use-package :OLI) (sd-defdialog 'save-all-from-top-pkg-plus-picture-dialog :dialog-title '(sd-multi-lang-string "Save All At Top PKG+JPG" :german "Speicher alles als PKG+JPG") :persistent-proposals t ;; keep user entered value of proposals across osdm session :precondition '(if (sd-inq-current-vp) :OK (values :error (sd-multi-lang-string "Not any 3D Viewport does exist!" :german "Kein Ansichtsfenster vorhanden!")) ) :variables '( (FILE :value-type :filename :direction :output :if-exist :confirm-overwrite :initialdirectory (sd-get-current-working-directory) :filetype :package :initialPattern "*.pkg" :filename-incl-path t :title (sd-multi-lang-string "PKG-File" :german "PKG Datei") ) (pic-settings :title (sd-multi-lang-string "picture settings" :german "Bild Einstellungen")) (AE :value-type :boolean :title (sd-multi-lang-string "hide workplanes" :german "AE verstecken") :toggle-type :wide-toggle :initial-value t ) (KEEP_VP :value-type :boolean :title (sd-multi-lang-string "keep vport camera + drawlist" :german "Kamera + DarstellListe behalten") :toggle-type :wide-toggle :initial-value nil ) (XSIZE :value-type :integer :title (sd-multi-lang-string "width" :german "Breite") :initial-value 800 :proposals '(1600 1280 1024 800 600 480) :auto-add-proposal t :proposals-order :sorted ) (YSIZE :value-type :integer :title (sd-multi-lang-string "height" :german "Hoehe") :initial-value 600 :proposals '(1200 1024 960 800 768 600 480) :auto-add-proposal t :proposals-order :sorted ) ) ;; end variables :local-functions '( (save-all-at-top-pkg-plus-picture () (sd-call-cmds (let* (PIC_FULL_FILENAME ORG_VP_CAM PIC_VP (ORG_VP (sd-inq-current-vp)) (ORG_VP_MAX (sd-inq-vp-maximized-p ORG_VP)) ) (when KEEP_VP (setf ORG_VP_CAM (sd-inq-vp-camera ORG_VP))) ; if KEEP_VP ist true -> set variable ORG_VP_CAM as SD-VP-CAMERA-STRUCT (create_vp) ; creates new viewport (setf PIC_VP (sd-inq-current-vp)) ; inquires the name of new viewport (if KEEP_VP (progn (copy_vp_drawlist PIC_VP ORG_VP) ; copies the drawlist of the active viewport to the new one (sd-set-vp-camera PIC_VP ORG_VP_CAM :smooth nil) ; set the kept camera setting ) (progn (uic_draw_all PIC_VP) ; enables all objects in struct browser (set_vp_direction PIC_VP 1.0,1.0,-1.0) ; isometric view ) ) (when AE (remove_from_vp_drawlist PIC_VP :workplane :recursive :all_at_top) ; if AE is true hide all workplanes ) (setf PIC_FULL_FILENAME (sd-string-replace (format nil "~A#$" (first FILE)) ".pkg#$" ".jpg")) (when (sd-inq-file-status PIC_FULL_FILENAME :existence) ; if filename exists -> delete (delete-file PIC_FULL_FILENAME) ) ;(update_screen) (create_thumbnail :vp PIC_VP :size :user :size_x XSIZE :size_y YSIZE :fit (if KEEP_VP :off :on) :filename PIC_FULL_FILENAME :overwrite) ; create picture (delete_vp PIC_VP) ; delete picture viewport (when ORG_VP_MAX (sd-maximize-vp ORG_VP)) ;; for rather old versions... (save_package :all_at_top :filename (first FILE) :overwrite) ; save all from top as package )) ;; end let + sd-call-cmds ) ) ;; end local functions :after-initialization '(when (fboundp 'oli::sd-store-window-placement) (sd-store-window-placement :all)) :cleanup-action '(when (fboundp 'oli::sd-restore-window-placement) (sd-restore-window-placement :all)) :ok-action '(save-all-at-top-pkg-plus-picture) :help-action '(display (sd-multi-lang-string "Save a screen shot of the model in same dir as the PKG file is saved to." :german "Frag' nach bei cad.de!" )) ) ;; end dialog ;; if problems: uncomment the following lines, load file again and call the action again (up to your error) ;; and send the information shown in console window ;(sd-show-console-window) ;(trace CREATE_THUMBNAIL FIT_VP CREATE_VP DELETE_VP SET_VP_DIRECTION REMOVE_FROM_VP_DRAWLIST ; OLI:SD-STRING-REPLACE oli:sd-inq-current-vp ; )