Lee Mac Posted September 7, 2008 Share Posted September 7, 2008 This is an extension of my previous post, however I thought it may be best in a new thread. I have tried to create a LISP to fillet pairs of lines, using the code shown below: (defun flangeelevfillet () (command "_fillet" "R" "2" a6 a8 ) (command "_fillet" "R" "2" a7 a9 ) (command "_fillet" "R" "2" a8 a10 ) (command "_fillet" "R" "2" a9 a11 ) (command "_fillet" "R" "2" a10 a12 ) (command "_fillet" "R" "2" a11 a12 ) (command "regenall") ) However, when using this code within another LISP program (where the variables a1, a2 etc are line entities set using the entlast script) the lines are not filleted and the command box just displays an entity name.... I cannot see what I am doing wrong.... hopefully a new set of eyes may spot something I've missed. :wink: Quote Link to comment Share on other sites More sharing options...
Strix Posted September 7, 2008 Share Posted September 7, 2008 can you post the other lisp too, or is it any other lisp? Quote Link to comment Share on other sites More sharing options...
CAB Posted September 7, 2008 Share Posted September 7, 2008 It has been my experience that you need to supply a point with the ename just like you get from (entsel), not just the ename. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 7, 2008 Author Share Posted September 7, 2008 CAB, would I be able to create such a thing if I know a point on the line and use the 'cons' syntax, ie. (defun constest () (setq b1 (cons a1 pt1) ) ; end setq ) ; end program where b1 is the ename and point (like in entsel) and a1 is the entity with pt1 as a point on the line... Quote Link to comment Share on other sites More sharing options...
CAB Posted September 7, 2008 Share Posted September 7, 2008 Yes. (command "_fillet" "R" "2" (cons a6 p6) (cons a8 p8) ) Note that osmode can cause problems with commands using points. It should be set OFF during the command. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 7, 2008 Author Share Posted September 7, 2008 Thanks, help is much appreciated as always. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 7, 2008 Author Share Posted September 7, 2008 I have used the entsel format method and have tried with a point at the end of the line to be filleted and also mid-way along the line (in case it was the endpoint causing the problems)... both with osmode set to 0. I have used !b1 to check the value of my variable with this result: Command: !b1 (<Entity name: 7ed12f40> 1092.59 287.969 0.0) and so I know that the variable has been set properly. after the LISP completed its routine, I tried to fillet the lines myself and was successful, so why on earth can the LISP not do it!!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 7, 2008 Author Share Posted September 7, 2008 can you post the other lisp too, or is it any other lisp? My LISP file exceeds the 20KB limit set.. sorry Quote Link to comment Share on other sites More sharing options...
Strix Posted September 7, 2008 Share Posted September 7, 2008 that's why we often have lisps broken across 3 posts :wink: Quote Link to comment Share on other sites More sharing options...
CAB Posted September 7, 2008 Share Posted September 7, 2008 You can zip the lisp. Sorry for the code I made a mistake, it should be LISt not CONS (command "_fillet" "R" "2" (list a6 p6) (list a8 p8) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 Thanks CAB, will give that a go Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 I have used the code shown below: (defun flangeelevfillet () (command "_fillet" "R" "2" (setq b1 (list a6 flgotppt ) ; end list ) ; end setq (setq b2 (list a8 flgoltppt ) ; end list ) ; end setq ) ; end fillet (command "_fillet" "R" "2" (setq b3 (list a7 flgobtpt ) ; end list ) ; end setq (setq b4 (list a9 flgolbtpt ) ; end list ) ; end setq ) ; end fillet ) ; end program with no luck in filleting... and when checking the value of b1, I get this: Command: !b1 (<Entity name: 7e88fdf0> (331.409 328.982 0.0)) Quote Link to comment Share on other sites More sharing options...
CAB Posted September 8, 2008 Share Posted September 8, 2008 Note that your fillet command exits after the setting of radius, therefore the command as written doesn't work. This is wrong: (command "_fillet" "R" "2" (setq b1 (list a6 flgotppt)) (setq b2 (list a8 flgoltppt)) ) ; end fillet This is correct: (command "_.fillet" "R" "2" "_.fillet" ; <---<< command must be stated again (setq b1 (list a6 flgotppt)) (setq b2 (list a8 flgoltppt)) ) ; end fillet Try this test routine using another way to set the radius: (defun c:test (/ usrosm e1 e2) (setq usrosm (getvar "osmode")) (and (setq e1 (entsel "\nSelect the first line to fillet.")) (setq e2 (entsel "\nSelect the second line to fillet.")) (setvar "osmode" 0) (setq usrrad (getvar "osmode")) (setvar "filletrad" 2) (command "_.fillet" e1 e2) ) (and usrrad (setvar "osmode" usrrad)) (and usrosm (setvar "osmode" usrosm)) (princ) ) Then try this routine: (defun c:test (/ usrosm e1 e2 p1 rad) (setq rad 2.0) (setq usrosm (getvar "osmode")) (and (setq p1 (getpoint "\nPick a test point for fillet.")) (setq e1 (entmakex (list (cons 0 "LINE") (cons 8 "0") ; layer (cons 10 p1) ; start point (cons 11 (polar p1 pi 100)) ; end point ))) (setq e2 (entmakex (list (cons 0 "LINE") (cons 8 "0") ; layer (cons 10 p1) ; start point (cons 11 (polar p1 (* pi 1.5) 100)) ; end point ))) (setvar "osmode" 0) (setq usrrad (getvar "osmode")) (setvar "filletrad" rad) (command "_.fillet" (list e1 (polar p1 pi rad)) (list e2 (polar p1 (* pi 1.5) rad))) ) (and usrrad (setvar "osmode" usrrad)) (and usrosm (setvar "osmode" usrosm)) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 Thanks for those CAB, much appreciated - I may set the fillet radius using the (setvar "filletrad" 2) instead of trudging through the command using "R" and "2". I have updated the LISP with your ideas and have tried to run it. Most of the lines are filleted, however when the LISP gets to some lines it says that the fillet radius is too large, when it clearly isn't I have attached the LISP, (zipped as it is too large). I will understand if you dont want to go ploughing through it as it is pretty long, but some help on the 'fillet' program would be much appreciated. PIPE & FLANGE DRAUGHTSMAN.zip Quote Link to comment Share on other sites More sharing options...
CAB Posted September 8, 2008 Share Posted September 8, 2008 The error "fillet radius is too large" is usually caused when the picked point is too close to the end of the line. Most likely you are using the START or END of the line point. That is why in my sample routine I use (polar pt (angle away from the end point) (distance of the radius)) to move the pick point away from the end of the line. Does that help? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 CAB, you are absolutely right, I am using the start/endpoint of the line! I have not yet tried it, but I am sure that will solve the problem. Thanks ever so much. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 Is there any way to assign an variable to a fillet so that it may be rotated later? I tried using the entlast function, but to no avail. Quote Link to comment Share on other sites More sharing options...
CAB Posted September 8, 2008 Share Posted September 8, 2008 This works for me. (defun c:test (/ usrosm e1 e2 p1 rad) (setq rad 2.0) (setq usrosm (getvar "osmode")) (and (setq p1 (getpoint "\nPick a test point for fillet.")) (setq e1 (entmakex (list (cons 0 "LINE") (cons 8 "0") ; layer (cons 10 p1) ; start point (cons 11 (polar p1 pi 100)) ; end point ))) (setq e2 (entmakex (list (cons 0 "LINE") (cons 8 "0") ; layer (cons 10 p1) ; start point (cons 11 (polar p1 (* pi 1.5) 100)) ; end point ))) (setvar "osmode" 0) (setq usrrad (getvar "osmode")) (setvar "filletrad" rad) (vl-cmdf "_.fillet" (list e1 (polar p1 pi rad)) (list e2 (polar p1 (* pi 1.5) rad))) (setq rent1 (entlast)) ; [b]this works[/b] (entdel rent1) ; [b]remove the entity as a test[/b] ) (and usrrad (setvar "osmode" usrrad)) (and usrosm (setvar "osmode" usrosm)) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2008 Author Share Posted September 8, 2008 Thanks CAB, Just out of interest, I have a few queries.... 1) (this may seem a little ignorant.. but I'm new to LISP) Why do you list your variables in the brackets after the (defun c:XXX ("here")... with a " / " ? 2) Why do you use the "vl-cmdf" instead of "command"? Thanks once again for your help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 9, 2008 Author Share Posted September 9, 2008 CAB you are a genius... The LISP works like a treat! Thanks for all your help. Quote Link to comment Share on other sites More sharing options...
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.