;;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;;;; Developer Notes ;;;; ;;;; How these functions work goes as follows ;;;; 1. Changing the Pipe ID and OD ;;;; 1a. Select the outer planer face of the pipe, this will gather it's OD and ID ;;;; 1b. The module will go through the pipe structure and gather all the twists and turns of the pipe ;;;; 1c. While doing so it will create a new spline through each cylinder and torus ;;;; 1d. Lastly, the user can change either the ID and OD of the pipe to create a new pipe. ;;;; ;;;; 2. As it is, the selection of the face and center point is optional. When not selected, it will create the ;;;; fastener at the world origin ;;;; 2a. When bolts are created the head will be above the origin/workplane with the bolt shaft going downward ;;;; 2b. When nuts and washers are created, they will be above the world origin/workplane ;;;; 2c. When set screws are creaded, they will be below the origin/workplane ;;;; ;;;; 3. the sd-machine-fasteners-listings.lsp (if loaded) can be filled out with partnumbers you or your company use ;;;; ;;;; 4. For the threaded functions to work, you must also load the sd-machine-threads.lsp file so that the fasteners can ;;;; generated with the threads. ;;;; ;;;; 5. The bulk of these dimensions are found in the Machinist's Handbook v26. If not found in the hand book, a web address ;;;; has been provided next to the feature inside their module. ;;;; ;;;; Version 2.4 ;;;; Date March 30, 2017 ;;;; Developer - Chris Palmer ;;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (in-package :custom) (use-package :oli) ;;;; =================================================================================================================== (sd-defdialog 'sd_model_utility_create_new_pipe ;;;; =================================================================================================================== :dialog-title "Create New Pipe" :variables '( ("This must be an End Face") (SelPart :selection *sd-part-seltype* :toggle-type :invisible) (SelFace :title "Select Face" :selection *sd-plane-seltype* :after-input (Inquire_Part_Face SelFace) :next-variable 'NewOD) ("Create New Profile") (NewOD :title "New O.D." :value-type :positive-length :initial-value 0 :after-input (Create_Pipe_Geo SelFace NewOD WllThck 1) :next-variable 'WllThck) (WllThck :title "Thickness" :value-type :positive-length :initial-value (* 25.4 0.25) :after-input (Create_Pipe_Geo SelFace NewOD WllThck 2) ) ;("Testing") (ChkBox1 :title "Run the Cylinder Filter?" :value-type :boolean :initial-value T :toggle-type :invisible);:wide-toggle) (ChkBox2 :title "Run the Torus Filter?" :value-type :boolean :initial-value T :toggle-type :invisible);:wide-toggle) (ChkBox0 :title "Delete the Inquired Faces?" :value-type :boolean :initial-value nil :toggle-type :invisible);:wide-toggle) ("") (Execute :title "Generate New Pipe" :push-action (create_new_pipe SelPart) :toggle-type :wide-toggle ) ;;Hidden Variables (CylrList0) (CylrList1) (CylrList2) (C_Spline_List) (TorsList0) (TorsList1) (TorsList2) (T_Spline_List) (CntList) (Face) (CF_Count1 :value-type :number :initial-value 0 :toggle-type :invisible) (CF_Count2 :value-type :number :initial-value 0 :toggle-type :invisible) (TF_Count1 :value-type :number :initial-value 0 :toggle-type :invisible) (TF_Count2 :value-type :number :initial-value 0 :toggle-type :invisible) (FaceCnt :value-type :number :initial-value 0 :toggle-type :invisible) (SubCount1 :value-type :number :initial-value 0 :toggle-type :invisible) (SubCount2 :value-type :number :initial-value 1 :toggle-type :invisible) );variables :local-functions '( ;;Inquire face information (inquire_face_info (Face) ;;Inquire Face (setf FaceEdges (sd-call-cmds (get_selection :focus_type *sd-edge-3d-seltype* :select :edge_3d :by_face Face )) Dia_1 (* 2 (sd-circle-radius (sd-inq-geo-props (first FaceEdges) :dest-space :global))) Dia_2 (* 2 (sd-circle-radius (sd-inq-geo-props (second FaceEdges) :dest-space :global))) );setf ;;Sort it out (if(> Dia_1 Dia_2) ;;If Dia_1 is Bigger (setq NewOD Dia_1 WllThck (* 0.5 (- Dia_1 Dia_2)) );setq ;;Else (setq NewOD Dia_2 WllThck (* 0.5 (- Dia_2 Dia_1)) );setq );if );inquire_face_info ;;Things to do after selecting the face (Inquire_Part_Face (Face) ;;Fill in the Main part (setq SelPart (sd-inq-parent-obj Face) ) ;;Reset all the variables (setq CylrList0 nil CylrList1 nil CylrList2 nil C_Spline_List nil TorsList0 nil TorsList1 nil TorsList2 nil T_Spline_List nil CF_Count 0 TF_Count 0 CntList nil FaceCnt 0 LoopCount 0 SubCount1 0 SubCount2 1);setq ;;Get the face dimensions (inquire_face_info Face) ;;Now start compiling the face lists (Compile_Face_List SelPart) );Inquire_Part_Face ;;Count the number of items in the list (get_a_face_count (F_List Type Cycle) ;;count how many items are in the list (setq FaceCnt (length F_List)) ;;Now create the face count (setq Face (cond ((= Type 1) "Cylinder") ((= Type 2) "Torus" ) ) ) (cond ((= Cycle 1)(cond ((= Type 1)(setq CF_Count1 FaceCnt)) ((= Type 2)(setq TF_Count1 FaceCnt)) ) ) ((= Cycle 2)(cond ((= Type 1)(setq CF_Count2 FaceCnt)) ((= Type 2)(setq TF_Count2 FaceCnt)) ) ) );cond ;;log it (cond ((= Cycle 1) (print(format nil "~A~% -There are ~A ~A faces found in the old list" "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" FaceCnt Face)) ) ((= Cycle 2) (print(format nil "~A~% -There are ~A ~A faces found in the new list" "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" FaceCnt Face)) ) );cond );get_a_face_count ;;Create the main list and the divide the list into seperate types (Compile_Face_List (Part) ;;Gather All the faces in the part (setq CylrList1 (sd-call-cmds(get_selection :focus_type *sd-cylinder-seltype* :select :in_part Part :all_3d )) TorsList1 (sd-call-cmds(get_selection :focus_type *sd-torus-seltype* :select :in_part Part :all_3d )) );setq ;;Work on the cilinders (when (equal ChkBox1 T) (get_a_face_count CylrList1 1 1) (filter_through_face_list CylrList1 CylrList2 1) (get_a_face_count CylrList2 1 2) (setq CylrList0 CylrList2) );when ;;Work on the Torus|Bends (when (equal ChkBox2 T) (get_a_face_count TorsList1 2 1) (filter_through_face_list TorsList1 TorsList2 2) (get_a_face_count TorsList2 2 2) (setq TorsList0 TorsList2) );when ;;Create the spline (create_spline_by_face CylrList0 TorsList0) );Compile_Face_List ;;Filter through the list (filter_through_face_list (F_List_1 F_List_2 Type) ;;Logit (print(format nil "~A~% -Checking the ~A list for a specificed outer diameter" "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" Face)) ;;Setup the variables (setq SubCount1 1 TempList F_List_1 TempCount TF_Count );setq ;;Run through the list looking for simular outer diameters (loop ;;Setup the first variables (setf Face_1 (first TempList) ) ;;Provide an escape route (if (equal Face_1 nil) (return) );if ;;Setup the rest of the variables (setf Face_1R (cond ((= Type 1)(sd-cylinder-radius (sd-inq-geo-props Face_1 :dest-space :global))) ((= Type 2)(sd-torus-min-radius (sd-inq-geo-props Face_1 :dest-space :global))) );cond ORad (* 0.5 NewOD) );setf ;;logit (print(format nil " -Checking Torus Face - ~A - ODia1 ~A ODia2 ~A" SubCount1 (sd-write-to-string (/ Face_1R 12.7) 6) (sd-write-to-string (/ ORad 12.7) 6) )) ;;Compare the two diameters (if (= Face_1R ORad) (progn ;;Logit (print " -Moving Face to Another List") ;;Add to a new listing (cond ((= Type 1) (push Face_1 CylrList2) ) ((= Type 2) (push Face_1 TorsList2) ) );cond ;;delete the found face off the 3d geo, test only (if (equal ChkBox0 T) (sd-call-cmds(remove_face_rep :faces Face_1 )) );if ));if ;;delete the first and move on (pop TempList) ;;bump to the next face (setf SubCount1 (+ 1 SubCount1)) );loop );filter_through_face_list ;;Create the spline geometry (sd_create_spline_in_center_of_face (Type Face) ;;Collect all the edges of the face (setf Edges (sd-call-cmds (get_selection :focus_type *sd-edge-3d-seltype* :select :edge_3d :by_face Face )) Edge1Cen (sd-circle-center (sd-inq-geo-props (first Edges) :dest-space :global) ) Edge2Cen (sd-circle-center (sd-inq-geo-props (second Edges) :dest-space :global) ) );setf ;;If this is a Torus Type (when (= Type 2) ;;Setup additional variables (setq InqTorus (sd-inq-geo-props Face :dest-space :global) Tor_center (sd-torus-center InqTorus) Tor_axis_dir (sd-torus-axis-dir InqTorus) ;------------------------------------------------------------------------------------- Point_3 (sd-vec-rotate Edge1Cen .01 :point Tor_center :direction Tor_axis_dir) );setf );when ;;Create the spline by type (when (= Type 1);;-Cylinder (sd-call-cmds(create_straight;_doer :wire_part (format nil "/~A_Tube_Spline" (sd-inq-obj-basename (sd-inq-parent-obj Face)) ) :start_condition :position :two_points :start_point Edge1Cen :end_point Edge2Cen)) );when (when (= Type 2);;-Torus (sd-call-cmds (create_arc :wire_part (format nil "/~A_Tube_Spline" (sd-inq-obj-basename (sd-inq-parent-obj Face)) ) :start_condition :position :three_points :start_point Edge1Cen :end_point Edge2Cen :third_point Point_3 )) );when );sd_create_spline_in_center_of_face (create_spline_by_face (CF_List TF_List) ;logit (print(format nil "~A~% -Creating the Splines based on the Face listing" "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" )) ;;Reset some variables (setf Cyl_Cnt 1 Tor_Cnt 1 );setf ;;Make the Cylinder Splines first (loop ;;get the first item on the list (setf CF_Face (First CF_List) ) ;;provide an escape (when (equal CF_Face nil) (return) ) ;;logit (print(format nil " -Making straight spline - ~A" Cyl_Cnt)) ;;Call the command to make the spline (sd_create_spline_in_center_of_face 1 CF_Face) ;;take one down and pass it around (setf Cyl_Cnt (+ 1 Cyl_Cnt)) (pop CF_List) );loop ;;Make the Torus Splines Next (loop ;;get the first item on the list (setf TF_Face (First TF_List) ) ;;provide an escape (when (equal TF_Face nil) (return) ) ;;logit (print(format nil " -Making arced spline - ~A" Tor_Cnt)) ;;Call the command to make the spline (sd_create_spline_in_center_of_face 2 TF_Face) ;;take one down and pass it around (setf Tor_Cnt (+ 1 Tor_Cnt)) (pop TF_List) );loop );create_spline_by_face ;;Create the pipe 2d profile that will update after each input. (Create_Pipe_Geo (Face OD WllThck Input) ;;Calculate ID (setf ID (- OD (* 2 WllThck)) ) ;;Check the inputs (cond ;;Checking OD ((= Input 1) (when (< OD ID)(progn (sd-display-alert "The OD is smaller than the ID. Please fix this" :icon :error) (sd-put-buffer ":NewOD") ))) ;;Checking ID ((= Input 2) (when (< OD ID)(progn (sd-display-alert "The ID is bigger than the OD. Please fix this" :icon :error) (sd-put-buffer ":NewID") ))) );cond ;;Checking for Equals (when (= OD ID) (progn (sd-display-alert "The ID and OD are the same. Please fix this" :icon :error) (cond ((= Input 1 )(sd-put-buffer ":New0D")) ((= Input 2 )(sd-put-buffer ":NewID")) ) )) ;;Check for preexisting wp of the same name (when (sd-inq-workplane-p(sd-pathname-to-obj "/New_Pipe_WP" )) (sd-call-cmds(delete_3d "/New_Pipe_WP" )) );when ;;Create a new workplane (sd-call-cmds (create_workplane :new :name "New_Pipe_WP" :model_name "New_Pipe_WP" :par_face :face Face :slide_origin (sd-call-cmds(get_vol_prop :for_face :face Face :select_done :centroid)) )) ;;Next, convert the diameters to radii (setf ORad (* 0.5 OD) IRad (* 0.5 ID) ) ;;Now attempt to draw the new profile (when (> OD 0) (sd-call-cmds(circle :cen_rad 0,0 ORad)) );when (when (> ID 0) (sd-call-cmds(circle :cen_rad 0,0 IRad)) );when );Create_Pipe_Geo ;;Now Create the new pipe (create_new_pipe (Part) ;;Create the spline list (setq C_Spline_List (sd-call-cmds (get_selection :focus_type *sd-line-3d-seltype* :select :in_part (sd-inq-curr-part) :all_3d )) T_Spline_List (sd-call-cmds (get_selection :focus_type *sd-arc-3d-seltype* :select :in_part (sd-inq-curr-part) :all_3d )) SplineList (append C_Spline_List T_Spline_List)) ;;Now try to sweep the profile (sd_generic_general_sweep 1 (format nil "~A_New" (sd-inq-obj-pathname Part)) SplineList T 1 nil nil) ;;;Delete the workplane (sd-call-cmds(delete_3d (sd-inq-curr-wp))) ;;Delete the spline (sd-call-cmds(delete_3d(format nil "/~A_Tube_Spline" (sd-inq-obj-basename Part) ))) );create_new_pipe );local-functions );sd-defdialog ;;;; =================================================================================================================== (sd-defdialog 'sd_model_utility_create_pipe_spline ;;;; =================================================================================================================== :dialog-title "Create Pipe Spline" :variables '( ("This must be a Pipe Wall") (SelPart :selection *sd-part-seltype* :toggle-type :invisible) (SelFace :title "Select Face" :selection *sd-face-seltype* :after-input (create_spline_from_face SelFace) :next-variable 'SelFace) (chkbox :title "Use Color Indicators?" :value-type :boolean :initial-value T :toggle-type :wide-toggle) (OrigClr :value-type :rgb-color :toggle-type :invisible ) (FaceList) );variables :local-functions '( ;;Spline Creation (create_spline_from_face (Face) ;;Inquire what kind of face is this (setq InqFace (sd-inq-geo-props Face :dest-space :global) OrigClr (sd-inq-part-color (sd-inq-parent-obj Face) :contents ) Error 1) ;;Add to an ongoing face list (push Face FaceList) ;;If it's a cylidrical Face (when (sd-cylinder-p InqFace) ;(sd-display-alert "Cylinder" :auto-close-time 0.5) (sd_create_spline_in_center_of_face 1 Face) (setq Error 0) (if (equal chkbox T)(sd-call-cmds(set_face_color Face :color :rgb 0.0000,1.0000,0.0000))) );when ;;If it's a Torical Face (when (sd-torus-p InqFace) ;(sd-display-alert "Torus" :auto-close-time 0.5) (sd_create_spline_in_center_of_face 2 Face) (setq Error 0) (if (equal chkbox T)(sd-call-cmds(set_face_color Face :color :rgb 0.0000,1.0000,0.0000))) );when ;;When an error is found (when (= Error 1) (if (equal chkbox T)(sd-call-cmds(set_face_color Face :color :rgb 1.0000,0.0000,0.0000))) (sd-display-alert "Sorry, I can't figure out this face" :icon :error :auto-close-time 2) );when );create_spline_from_face (sd_create_spline_in_center_of_face (Type Face) ;;Collect all the edges of the face (setf Edges (sd-call-cmds (get_selection :focus_type *sd-edge-3d-seltype* :select :edge_3d :by_face Face )) Edge1Cen (sd-circle-center (sd-inq-geo-props (first Edges) :dest-space :global) ) Edge2Cen (sd-circle-center (sd-inq-geo-props (second Edges) :dest-space :global) ) );setf ;;If this is a Torus Type (when (= Type 2) ;;Setup additional variables (setq InqTorus (sd-inq-geo-props Face :dest-space :global) Tor_center (sd-torus-center InqTorus) Tor_axis_dir (sd-torus-axis-dir InqTorus) ;------------------------------------------------------------------------------------- Point_3 (sd-vec-rotate Edge1Cen .01 :point Tor_center :direction Tor_axis_dir) );setf );when ;;Create the spline by type (when (= Type 1);;-Cylinder (sd-call-cmds(create_straight;_doer :wire_part (format nil "/~A_Tube_Spline" (sd-inq-obj-pathname (sd-inq-parent-obj Face)) ) :start_condition :position :two_points :start_point Edge1Cen :end_point Edge2Cen)) );when (when (= Type 2);;-Torus (sd-call-cmds (create_arc :wire_part (format nil "/~A_Tube_Spline" (sd-inq-obj-pathname (sd-inq-parent-obj Face)) ) :start_condition :position :three_points :start_point Edge1Cen :end_point Edge2Cen :third_point Point_3 )) );when );sd_create_spline_in_center_of_face );local-functions );sd-deffeature ;;;; =================================================================================================================== (defun sd_create_spline_in_center_of_cylinder (Face &optional Num) ;;;; =================================================================================================================== ;;Collect the edges of the cylinder (setf Edges (sd-call-cmds(get_selection :focus_type *sd-edge-3d-seltype* :select :edge_3d :by_face Face )) Edge1Cen (sd-circle-center(sd-inq-geo-props (first Edges) :dest-space :global)) Edge2Cen (sd-circle-center(sd-inq-geo-props (second Edges) :dest-space :global)) Count (cond ((equal Num nil) "") (t (format nil ".~A" Num)) ) );setf ;;Now run a 3d line through the cylinder (sd-call-cmds(create_straight :wire_part (format nil "/~A_Spline~A" (sd-inq-obj-pathname(sd-inq-parent-obj Face)) Count) :start_condition :position :two_points :start_point Edge1Cen :end_point Edge2Cen)) );defun ;;;; =================================================================================================================== (defun sd_create_spline_in_center_of_torus (Face &optional Num) ;;;; =================================================================================================================== ;;Collect the edges of the cylinder (setf Edges (sd-call-cmds(get_selection :focus_type *sd-edge-3d-seltype* :select :edge_3d :by_face Face )) Edge1Cen (sd-circle-center(sd-inq-geo-props (first Edges) :dest-space :global)) Edge2Cen (sd-circle-center(sd-inq-geo-props (second Edges) :dest-space :global)) Count (cond ((equal Num nil) "") (t (format nil ".~A" Num)) ) );setf ;;Set some variables (setq InqTorus (sd-inq-geo-props Face :dest-space :global) Tor_center (sd-torus-center InqTorus) Tor_axis_dir (sd-torus-axis-dir InqTorus) ;------------------------------------------------------------------------------------- Point_3 (sd-vec-rotate Edge1Cen .01 :point Tor_center :direction Tor_axis_dir) );setf ;;Now run a 3d line through the cylinder (sd-call-cmds (create_arc :wire_part (format nil "/~A_Spline~A" (sd-inq-obj-pathname(sd-inq-parent-obj Face)) Count) :start_condition :position :three_points :start_point Edge1Cen :end_point Edge2Cen :third_point Point_3 )) );defun