;SolidDesigner Thread Extension - Additional Example

SolidDesigner Thread Extension - Additional Example

Note: This file is directly loadable into SolidDesigner.



(in-package :thread)
(use-package :oli)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin of page;;
;; 
;; example how to use the function sd-am-create-standard-view
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(sd-defdialog 'thread_extension
 :dialog-title "Thread Define"
 :after-initialization
 '(trace oli::sd-define-thread
	 oli::sd-inq-thread
	 oli::sd-destroy-thread
	 )
 :variables
 '(
   (t-feedbacks :initial-value nil) ;; all feedbacks shown
   (result      :initial-value nil) ;; saved return value of sd-*-thread functions
   (props       :initial-value nil) ;; cylinder face properties
   (a-cyl-face
    :value-type :face
    :title "Cyl Face"
    :check-function
    #'(lambda (this-face)
	(if (sd-cylinder-p (SD-INQ-GEO-PROPS this-face))
	    :ok
	  (values :error "No cylindrical face selected. Thread Information is only valid for a cylindrical face.")))
    :after-input
    (let (center axis start radius)
      (dolist (a-fb t-feedbacks) (sd-end-point-feedback a-fb)) ;; remove old feedback

      (setf props (sd-inq-geo-props a-cyl-face :dest-space :global))
      (setf center (sd-cylinder-center    props))  ;; really the center , also in axis direction!
      (setf axis   (sd-cylinder-axis-dir  props))
      (setf start  (sd-cylinder-start-dir props))  ;; this is for rotaion,
      (setf radius (sd-cylinder-radius    props))

      (push ;; center of cylinder
       (sd-start-direction-feedback
	:point center :direction axis :disc t  :color 0,0,1)
       t-feedbacks)

      (sd-set-variable-status 't-define  :enable t)
      (sd-set-variable-status 't-inq     :enable t)
      (sd-set-variable-status 't-destroy :enable t)
      ) ;; end after-input
    ) ;; end a-cylface
   ;; -------------------------------------------------------------------
   ("Thread Define")
   (nomi-dia
    :title "Nominal Dia."
    :value-type :positive-length
    )
   (pitch
    :title "Pitch"
    :value-type :positive-length
    )
   (core-dia
    :title "Core Dia."
    :value-type :positive-length
    )
   (thread-type :title "Type"  :range ( :inner :outer))
   (chamfer
    :title "Include adjacent Cone"
    :value-type :boolean
    :toggle-type :wide-toggle
    :initial-value T
    )
   (thread-name
    :title "Name"
    :value-type :string
    :initial-value ""
    )
   (a-dir-reverse
    :title "Reverse Dir"
    :value-type :boolean
    :toggle-type :wide-toggle
    )
   (t-define
    :initial-enable NIL
    :toggle-type :wide-toggle
    :title "Define"
    :push-action
    (progn
      (setf result
	    (oli::sd-define-thread a-cyl-face
				   :nominal-diameter nomi-dia
				   :core-diameter    core-dia
				   :pitch            pitch
				   :thread-type      thread-type
				   ;:thread-unit      thread-unit
				   :thread-color     1,0,0
				   :include-chamfer  chamfer
				   :thread-direction (if a-dir-reverse :REVERSE-CYL-AXIS :CYL-AXIS)
				   :thread-name      thread-name
				   )
	    )
      (unless result (display "no thread created - look to trace output in concole"))
      )
    ) ;; end t-define
   ;; -------------------------------------------------------------------
   ("Thread Inquire")
   (t-inq
    :initial-enable NIL
    :toggle-type :wide-toggle
    :title "Inquire"
    :push-action
    (progn
      (setf result
	    (oli::sd-inq-thread a-cyl-face))
      (if result
	  (progn
	    (display (format nil "thread detected~%~%~{:~A ~A~%~}~%look also to trace output in concole~%" (nthcdr 2 result)))
	    (setf nomi-dia      (getf result :nominal-diameter))
	    (setf core-dia      (getf result :core-diameter))
	    (setf pitch         (getf result :pitch))
	    (setf thread-type   (getf result :thread-type))
	    (setf chamfer       (getf result :include-chamfer))
	    (setf a-dir-reverse (NOT (sd-vec-equal-p (getf result :thread-direction) (sd-cylinder-axis-dir props))))
	    (setf thread-name   (getf result :thread-name))
	    ) ; end progn
	(display "no thread information available"))
      )
    ) ;; end t-inq
   ;; -------------------------------------------------------------------
   ("Thread Destroy")
   (t-destroy
    :initial-enable NIL
    :toggle-type :wide-toggle
    :title "Destroy"
    :push-action
    (progn
      (setf result
	    (oli::sd-destroy-thread a-cyl-face))
      (if result
	  (display "thread deleted")
	(display "no thread information available or no thread deleted - look to trace output in concole"))
      )
    ) ;; end t-destroy
   ) ;; end variables
 :cleanup-action
 '(progn
    (dolist (a-fb t-feedbacks) (sd-end-point-feedback a-fb)) ;; remove old feedback
    (untrace oli::sd-define-thread
	     oli::sd-inq-thread
	     oli::sd-destroy-thread
	 )
    )
 ) ;; end


;  END of Example