Isaac26a Posted May 23, 2022 Posted May 23, 2022 (edited) Hello friends, I recently was thinking on how to entmake an arc with 2 points and a radius, and since I couldn't find a solution without knowing the center point created this solution by using a lwpolyline, I don't know if it ever is useful for you or not, but if it ever happens to be useful to you give me a like or just credit. ;;; Program to create a curved lwpolyline with 2 points and a radius ;;; By Isaac A. 20220523 ;;; V1.1 (defun c:parc (/ bcal cw end r start) (while (= nil (setq start (getpoint "\nPick the start point"))) (setq start (getpoint "\nPick the start point")) ) (while (= nil (setq end (getpoint "\nPick the end point"))) (setq end (getpoint "\nPick the end point")) ) (setq r (getreal "\nGive me the radius: ")) (while (< r (/ (distance start end) 2.)) (setq r (getreal (strcat "\nThe radius can't be less than " (rtos (/ (distance start end) 2.) 2 2) ": "))) ) (setq bcal (ia:bulge start end r)) (initget 1 "Clockwise counterclockWise") (setq cw (getkword "\nSelect the path of the arc Clockwise/counterclockWise: ")) (if (= cw "Clockwise") (setq bcal (* -1 bcal)) ) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(8 . "newlayer") '(62 . 5) '(38 . 0.0) (cons 90 2) '(70 . 0) (cons 10 start) (cons 42 bcal) (cons 10 end) '(42 . 0.) ) ) (princ) ) ;;; ia:bulge Obtains the bulge to be used on a curved lwpolyline ;;; based on 2 points and radius (defun ia:bulge (p1 p2 r / d d-2 d-4 n) (setq d (distance p1 p2)) (if (>= r (/ d 2)) (progn (setq n (/ d (* 2. r)) d-2 (cond ((equal n 1. 1e-9) (/ pi 2.)) ((equal n -1. 1e-9) (/ pi -2.)) ((< -1. n 1.) (atan n (sqrt (- 1 (expt n 2)))) ) ) d-4 (/ d-2 2.) ) (/ (sin d-4) (cos d-4)) ) (princ "\nThe radius is incorrect") ) ) Hoping it ever gets useful to anyone. Happy coding. Edited May 25, 2022 by Isaac26a 5 Quote
Isaac26a Posted May 24, 2022 Author Posted May 24, 2022 Just now, mhupp said: Curious what situation would you use this? Well actually the idea didn't came up just by myself, in this post she was asking to entmake an arc but didn't provide the center, at the end, she knew the center point and this was just something not needed, but I just kept wondering if it was possible. Quote
1958 Posted May 24, 2022 Posted May 24, 2022 If the radius is less than the distance between the points, then there will be an emergency exit. Therefore, it is necessary to check for the minimum value of the radius. Sorry for my English. bulge.lsp 2 Quote
Isaac26a Posted May 24, 2022 Author Posted May 24, 2022 42 minutes ago, 1958 said: If the radius is less than the distance between the points, then there will be an emergency exit. Therefore, it is necessary to check for the minimum value of the radius. You're totally right, I sometimes forget to put checks to make it work better, Thanks I updated the code. Quote
marko_ribar Posted May 24, 2022 Posted May 24, 2022 Thanks... Â Note : You don't need starting (vl-load-com) as all further coded functions are not (vl-load-com) dependent... Second : I like your way of formulating (getkword) in relation to CW/CCW : [Clockwise/counterclockWise]... If I bump to something in future, I may steal your reasoning/visualization... Â I see you got like(s), so perhaps sometimes it's good thing to be modest/humble (here on planet) and not asked to be feeded with too much personality/egoistc glorifications (you could end up with empty hands on other/next world/planet (after this/thankful life of wonders...))... 1 Quote
Isaac26a Posted May 24, 2022 Author Posted May 24, 2022 3 hours ago, marko_ribar said: You don't need starting (vl-load-com) Thanks I sometimes leave it because I don't know if I'm going to end up using a vl(a, ax) function, I like the comments that help me learn and grow. Â Â 3 hours ago, marko_ribar said: I see you got like(s), so perhaps sometimes it's good thing to be modest/humble (here on planet) and not asked to be feeded with too much personality/egoistc glorifications (you could end up with empty hands on other/next world/planet (after this/thankful life of wonders...))... Yes, you're probably just right but for me it's not like that I happen to met lisp in 2007 and left it in 2008 knowing like 3%, took it back in 2020 again and from there nowadays I think I have learned to be like in a 12% so as you see I'm like 88% away to become a master in Lisp too far from being a Lee, Tharwat, BigAl, Fixo, Marko_Ribar. I use it to keep me going because sometimes selfmotivation is not enough, but thanks all comments are appreciated. Quote
Leika Posted May 24, 2022 Posted May 24, 2022 Isaac, thank you very much for this code You are creative that's for sure ! This one is also good for entering my doors because I already know all the points by breaking the walls first... Quote
Isaac26a Posted May 24, 2022 Author Posted May 24, 2022 Just now, Leika said: Isaac, thank you very much for this code You are creative that's for sure ! This one is also good for entering my doors because I already know all the points by breaking the walls first... I'm glad you could make use of it. Quote
Tharwat Posted May 24, 2022 Posted May 24, 2022 You don't need to use apply & append functions nor wrapping / covering list function , besides that you don't need to get X & Y only from variables start & end to exclude Z coordinates from them so they will be ignored on creation. Suppose a user hits enter when collecting inputs, what will happen when reaching while function ? Â 2 Quote
Isaac26a Posted May 25, 2022 Author Posted May 25, 2022 2 hours ago, Tharwat said: You don't need to use apply & append functions nor wrapping / covering list function , besides that you don't need to get X & Y only from variables start & end to exclude Z coordinates from them so they will be ignored on creation. Suppose a user hits enter when collecting inputs, what will happen when reaching while function ? Â Thanks again for helping me get better, I see that you like to make your programs fool proof, I thinks that's good, I guess we all should do it too. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.