;; Include the OLI package (use-package :oli) ;; Define the dialog for part information (sd-defdialog 'os_teil_info_dialog2 :dialog-title "Teil-Info2" :dialog-control :sequential-loop :variables '( ;; Define TEILE variable to store parts (TEILE :value-type :part :multiple-items t :title "Teil(e)" :initial-value nil :modifies nil :prompt-text "Teil(e) angeben" :after-input (progn ;; Sort TEILE array by part-name (setf TEILE (sort TEILE #'compare-parts-by-name)) ;; Call the function to display part information (teileinfo_anzeigen)) ) ;; TEILE ) ;; variables :local-functions '( ;; Function to compare parts by name alphabetically (compare-parts-by-name (part1 part2) (string< (sd-inq-obj-contents-name part1) (sd-inq-obj-contents-name part2))) ;; Function to display part information (teileinfo_anzeigen () (let ((unique-parts (make-hash-table :test 'equal))) ;; Clear the display (display :clear) ;; Iterate over each part in TEILE (dolist (a-part TEILE) (let ((part-name (sd-inq-obj-contents-name a-part)) (part-mass (sd-call-cmds (get_vol_prop :for_part a-part :part_asmb (sd-inq-obj-pathname a-part) ; :volume :mass) :failure nil))) ;; Check if the part is already displayed (if (gethash part-name unique-parts) ;; If the part is already displayed, do nothing () ;; If the part is not displayed, display its information (progn (setf (gethash part-name unique-parts) t) (display (format nil "~A ~A" part-name (sd-num-to-string (/ part-mass 1000) 1))) ) ) ) ) ;; Display unique part names ; (display "Unique parts:") ; (maphash (lambda (part _) (display part)) unique-parts) ) ) ) ;; :local-functions ) ;;sd-defdialog ;; Define the available command for SolidDesigner (sd-define-available-command "SolidDesigner" "Part and Assy" "os_teil_info_command2" :commandTitle "Teile Info2" :action "os_teil_info_dialog2" ) ;; Add a ribbon group for custom commands (sd-fluentui-add-ribbon-group "sd_analysis_custom_group" :parent "SDANALYSIS" :title "Custom" ) ;; Add a ribbon button for the custom command (sd-fluentui-add-ribbon-button :parent '("SDANALYSIS" "sd_analysis_custom_group") :availCmd '("SolidDesigner" "Part and Assy" "os_teil_info_command2") )