
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi members, I am a newbee to lisp here.
I am working on a lisp to draw a 2D S.E. Head by inputting several parameters. Currently I am facing problems when trying to join my outer lines to form an enclosed poly-line. Tried the ".Join" command but it will also join the lines at other portion of my drawing. (P.S. I wanted to join the outer lines of the drawn head only.)
Kindly see my codes as below:
(defun c:SE ()
(setq IP (getpoint "\nSpecify Insertion Point : "))
(setq ID (getdist "\nInner Diameter : "))
(setq SF (getdist "\nStraight Flange : "))
(setq thk (getdist "\nThickness : "))
(setq CR (* 0.9045 ID)) ;get crown radius
(setq KR (* 0.1727 ID)) ;get knuckle radius
(setq Z (- (/ ID 2) KR))
(setq H (- CR KR))
(setq L (* Z (/ CR H)))
(setq A1 (sqrt (- (expt CR 2) (expt L 2))))
(setq A2 (sqrt (- (expt H 2) (expt Z 2))))
(setq y (- A1 A2))
(setq P10 (polar IP (* PI 1) (/ ID 2))) ;OK (ID)
(setq P11 (polar IP (angle P10 IP) (/ ID 2))) ;OK (ID)
(setq P20 (polar IP (+ (/ PI 2) (atan (/ L y))) (sqrt (+ (expt L 2) (expt y 2))))) ;OK
(setq P21 (polar IP (- (/ PI 2) (atan (/ L y))) (sqrt (+ (expt L 2) (expt y 2))))) ;OK
(setq P00 (polar P10 (* PI -0.5) SF))
(setq P01 (polar P11 (* PI -0.5) SF))
(command "Line" P00 P10 "")
(command "Offset" thk P00 P10 "")
(command "Line" P11 P01 "")
(command "Offset" thk P11 P01 "")
(command "Arc" "_Non" P11 "_E" P21 "_R" KR)
(command "Offset" thk P11 P21 "")
(command "Arc" "_Non" P21 "_E" P20 "_R" CR)
(command "Offset" thk P21 P20 "")
(command "Arc" "_Non" P20 "_E" P10 "_R" KR)
(command "Offset" thk P20 P10 "")
(setq P101 (polar P10 (* PI 1) thk))
(setq P111 (polar p11 (angle P10 IP) thk))
(command "Line" P111 P101 "") ;this is tangent line
(command "Offset" SF P111 P101 "") ;this is weld line
(initcommandversion)
(command "_.Join" "_All" "")
(princ)
)
I believe there is more elegant way to write the coding. I will be very grateful if there is anyone willing to point out and guide me for this!
Thank you very much!
Solved! Go to Solution.