Mr Bojangles Posted March 5 Posted March 5 Hi Guys I'm.currently working on a routine, and I've hit a wall.. I'm only a novice lisper and also I can only code with Autolisp, although I've incorporated Visual lisp from various sources into my routines. This time though I'm stuck. I can't find what I need with the search function (or Google )and I'm hoping that's because I'm not using the right parameters rather than it not being possible. What I'm trying or wanting to do in this part of my routine is, find the smallest radius that is on a closed polyline and put that value into a variable, so that it can be used in another part of my routine. My routine layout is as follows I would be using a selection set to get the correct polyline (using a layername filter). Then I want to find the smallest radius on that polyline and put it in a variable (more than likely called "smrad". Then I would be comparing that variable with another. If it's okay then the routine would continue to do more, else it would pop up a message and end. Hope someone can help me Quote
mhupp Posted March 6 Posted March 6 all tho it doesn't say it here i think the bulge is stored in group 42 You can use that to calculate the radius. https://www.lee-mac.com/bulgeconversion.html#addition output polyline dxf info https://www.cadtutor.net/forum/topic/74613-dxf-fields/?do=findComment&comment=590936 1 Quote
Mr Bojangles Posted March 6 Author Posted March 6 Thanks for the info mhupp I'll take a look at that today Quote
Tsuky Posted March 6 Posted March 6 A start with this? (defun def_bulg_pl (ls lb / l_rad) (setq ls (append ls (list (car ls)))) (while (cadr ls) (if (zerop (car lb)) (setq l_rad (cons (car lb) l_rad)) (setq l_rad (cons (/ (distance (car ls) (cadr ls)) (sin (* 2.0 (atan (abs (car lb))))) 2.0) l_rad)) ) (setq ls (cdr ls) lb (cdr lb)) ) l_rad ) (defun c:test ( / sspl typent lst l_bulg e_next dxf_next rad) (while (null (setq sspl (ssget "_+.:E:S" '((0 . "*POLYLINE") (-4 . "<AND") (-4 . "&") (70 . 1) (-4 . "<NOT") (-4 . "&") (70 . 124) (-4 . "NOT>") (-4 . "AND>"))))) (princ "\nInvalid object") ) (setq typent (cdr (assoc 0 (setq dxf_ent (entget (setq ent (ssname sspl 0))))))) (cond ((eq typent "LWPOLYLINE") (setq lst (mapcar '(lambda (x) (trans x ent 1)) (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) dxf_ent))) l_bulg (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 42)) dxf_ent)) lst (def_bulg_pl lst l_bulg) ) ) ((eq typent "POLYLINE") (setq e_next (entnext ent)) (while (= "VERTEX" (cdr (assoc 0 (setq dxf_next (entget e_next))))) (if (zerop (boole 1 223 (cdr (assoc 70 dxf_next)))) (setq lst (cons (trans (cdr (assoc 10 dxf_next)) ent 1) lst) l_bulg (cons (cdr (assoc 42 dxf_next)) l_bulg) ) ) (setq e_next (entnext e_next)) ) (setq lst (reverse lst) l_bulg (reverse l_bulg) lst (def_bulg_pl lst l_bulg) ) ) ) (if (setq rad (car (vl-remove 0.0 (vl-sort lst '<)))) (princ (strcat "\nMinor radius found " (rtos rad 2))) (princ "\nNo radius found in this polyline") ) (prin1) ) 1 1 Quote
Mr Bojangles Posted March 6 Author Posted March 6 Wow, yes That works perfectly. With your permission I would like to use that as part of my larger routine. I'm still reading up on the bulge information, I get some of it, some not so much, hopefully reading through your routine will help me understand better.. I also know I really should be getting into Vlisp more. Quote
Sharper Posted March 6 Posted March 6 I like this thread.. Good question, I too have had to do this and great answers as usual by the talent on this website, my solution was a lot more long winded than tsukys elegant work. 1 Quote
Tsuky Posted March 6 Posted March 6 @Mr Bojangles Quote With your permission I would like to use that as part of my larger routine. No problem, if I put the code in plain text, it's because I'm sharing it otherwise I would compile the code if I wanted to keep control of it. 1 Quote
Mr Bojangles Posted March 7 Author Posted March 7 Thank you Tsuky And thank you to everyone else for your help and comments. Quote
Tsuky Posted March 12 Posted March 12 @mhupp On 3/8/2024 at 1:30 AM, mhupp said: I just saw your name and am cracking up. I don't know if this is aimed at me. If so, what I can say: I am a retired Frenchman I introduce myself: Under Bonuscad in the French forums Under CADaSchtroumpf on the AutoDesk forums Under Bruno.Valsecchi on the AUGI forum And Tsuky here (that's my cat's name: moon in Japanese) Quote
pkenewell Posted March 12 Posted March 12 7 minutes ago, Tsuky said: @mhupp I don't know if this is aimed at me. If so, what I can say: I am a retired Frenchman I introduce myself: Under Bonuscad in the French forums Under CADaSchtroumpf on the AutoDesk forums Under Bruno.Valsecchi on the AUGI forum And Tsuky here (that's my cat's name: moon in Japanese) @Tsuky I think mhupp was referring to the OP's screen name of "Mr Bojangles" 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.