I just feel like sharing a little thing I did a while ago. I love it, anyway. Hope you do too. It draws a circular flange with outerØ, innerØ, bolt circle and holes in a snap.
Feel free to give it away at Christmas. It's a great stocking stuffer.
;;; Flange.lsp ;;; Draws a flange with bolt circle (DEFUN c:flange(/ out in bc num trou cen cen1 cir1 cir2 cir3) (SETQ out (GETREAL "Give OUTER diameter : ") in (GETREAL "Give INNER diameter :") bc (GETREAL "Give bolt circle diameter : ") num (GETINT "How many holes : ") trou (GETREAL "Hole diameter : ") cen (GETPOINT "Insertion point : ") ) ;_ end of setq (IF (NOT (AND (TBLSEARCH "layer" "Axis") (TBLSEARCH "layer" "Contour") ) ;_ END and ) ;_ END not (PROGN (COMMAND "layer" "m" "Axis" "c" "Red" "" "l" "center" "" "") ;_ END COMMAND (COMMAND "layer" "m" "Contour" "c" "Magenta" "" "l" "continuous" "" "") ;_ END COMMAND ) ;_ END progn ) (SETVAR "OSMODE" 0) (setvar "CLAYER" "Contour") (COMMAND "_.circle" cen "D" out) (COMMAND "_.circle" cen "D" in) (SETQ cen1 (POLAR cen (/ PI 2) (/ bc 2))) (COMMAND "_.circle" cen1 "D" trou) (setq cir1 (entlast)) (setvar "CLAYER" "AXIS") (command "_.line" (polar cen1 (/ pi 2) (/ trou 2)) (polar cen1 (/ pi -2) (/ trou 2)) "") (setq cir2 (entlast)) (command "_.line" (polar cen1 pi (/ trou 2)) (polar cen1 0.0 (/ trou 2)) "") (setq cir3 (entlast)) (setvar "OSMODE" 0) (command "_.regen") (COMMAND "_.array" cir1 cir2 cir3 "" "P" cen num 360 "y") (setvar "CLAYER" "Contour") (SETVAR "OSMODE" 183) (PRINC) ) ;_ end of defun
Dr Fleau or anyone else interested --here is a routine I wrote a year or so ago that creates a 3d weld neck flange as a solid model. It requires a text file also included here. When copying the text file note that it is space delimited and must have one space ending each line. You must edit the lisp to send the routine to the proper place to find the file on your system.
By the way a very nice routine you have written
First the lisp:
;;A program to draw a 3D wn flange ;; The program has no error checking so results will be unpredictable if negative numbers are used ;; I recommend using this program in a new drawing and copying the flange where it is needed ;;Written by Tim Aiken-- tested on 2000 and 2004 --may be distributed freely as long as this heading remains
;; Create the function to read the data file
(defun rdata ( / ups a dps c ctr)
;; Get the pipe size from the user
(setq ups (getreal "Enter the pipe size Enter 0.5 or 0.75 for 1/2 or 3/4 pipe: "))
;; Open the data file read only ;; Change the path to the data file on your system
(setq a (open "c:/windows/desktop/Tim's folder/acad/150_flg_data.txt" "r"))
;; Initialize a variable to contain the pipe size returned from each loop of the while statement
(setq dps 0)
;; Loop through the data file one line at a time
(while (/= ups dps)
;; Read each line of the data file until the first string (first entry) of the file is equal to the pipe size
(setq *b (read-line a))
;; Get the first string of the line but first...
;; initialize a counter and a container for a concatenated string
(setq ctr 1 str "" c "")
;; As long as the character c is not a space...
(while (/= c " ")
;; In case the pipe size has 2 digits... (progn (setq c (substr *b ctr 1)) (setq str (strcat str c)) (setq ctr (1+ ctr)) );progn
);while
;; Convert the substring to an integer
(setq dps (atof str))
;; end while
)
;; Close the open file
(close a)
;; *b is the line of interest, using substr loop through the line *b to pull out the substrings
;;set up the counter to increment the substr function to walk through the line of text
(setq *sctr 1)
;; initialize a variable to hold the data string as it is revealed by the substr routine
(setq datastr "")
;; initialize a variable to track the number of spaces found
(setq *ns 0)
;; initialize a variable to hold the length of *b
(setq *blength (strlen *b))
;; if *a is a space then the complete piece of data is contained in datastr. If *a is not a space concatenate *a ;;to the data string and increment the counter. Repeat evaluation for every character in *b
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.