#|

Color Parts

Note: This is an example file showing concepts of the Integration Kit. The code itself is not supported and will never be supported.
|#

(in-package :EXAMPLES)
(use-package :OLI)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(sd-defdialog 'COLOR_PARTS
  :dialog-title "Color Parts"
  :variables
  '(
    (PARTS :value-type :part :multiple-items t :modifies :instance)
    (ASSY :value-type :assembly :modifies nil
	  :title "Assembly")
    )
  :local-functions
  '(
    (doit ()
     (when
      ASSY
      (setf PARTS (jb-inq-obj-tree-list ASSY)) 
      (setf PARTS
	    (remove-if
	     #'(lambda (obj)
		       (not (equal (sel_item-type obj) *sd-part-seltype*))) 
	     PARTS)))
     (let
      ((n (length PARTS))
       (i 0))
      (dolist
       (part PARTS)
       (sd-call-cmds
	(set_part_color (list PART) :hsl (gpnt3d (/ i n) 1 1) :done))
       (incf i))))
    )
  :mutual-exclusion '(PARTS ASSY)
  :ok-action '(doit))


(defun jb-inq-obj-tree-list (obj)
  (cons obj
   (apply #'nconc (mapcar #'jb-inq-obj-tree-list (sd-inq-obj-children obj)))))

;;