oldsoftboss Posted September 30, 2010 Posted September 30, 2010 Hi all, I have been playing around with an autolisp function that will automatically fillet a polyline. At the moment the following will allow you to draw and fillet a polyline with a 300mm radius on the Flex-CR layer. I would like the ability to copy the way the fillet command works, getting the current radius, allowing a different radius to be entered (if Ent is pressed, use current value) then store that value for next time but for the life of me cant work out how to get, use and re-store the current fillet radius. (defun c:FlexLine ( / *error* LastEntity OldLayer pt ent ) (defun *error* ( msg ) (and OldLayer (setvar "CLAYER" OldLayer)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq LastEntity (entlast) OldLayer (getvar "CLAYER")) (or (tblsearch "LAYER" "FLEX-CR") (command "_.-layer" "_M" "FLEX-CR" "")) (if (and (setq pt (getpoint "\nSpecify start point: ")) (progn (setvar "CLAYER" "FLEX-CR") (command "_.pline" pt "_W" 0.0 0.0) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (not (equal LastEntity (setq ent (entlast)))) ) ) (progn (setvar "FILLETRAD" 300) (command "_.fillet" "_P" ent) ) ) (setvar "CLAYER" OldLayer) (princ) ) Any help greatly appreciated. Quote
jammie Posted September 30, 2010 Posted September 30, 2010 Hi Maybe as a starting point (progn (if (setq input (getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">:") ) ) (setvar 'filletrad input) ) (command "_.fillet" "_P" ent) ) There are probably a few other ways you could also achieve this as well Quote
alanjt Posted September 30, 2010 Posted September 30, 2010 http://www.cadtutor.net/forum/showthread.php?50594-Fillet-polyline-in-LISP&p=343487&viewfull=1#post343487 Quote
oldsoftboss Posted September 30, 2010 Author Posted September 30, 2010 Thanks for the feed back. Will have a play at the weekend. As a side note, Jammie, how would you combine this code into the other lisp code I posted? Cheers, Dave Quote
oldsoftboss Posted October 1, 2010 Author Posted October 1, 2010 Have had some success. Code: (defun c:FlexLine (/ *error* LastEntity OldLayer pt eLast ent) ;; (defun *error* ( msg ) (and OldLayer (setvar "CLAYER" OldLayer)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq LastEntity (entlast) OldLayer (getvar "CLAYER")) (or (tblsearch "LAYER" "flex-cr") (command "_.-layer" "_M" "flex-cr" "")) ;; (setvar 'filletrad (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">: "))) ((getvar 'filletrad)) ) ) (if (setq pt (getpoint "\nSpecify start point: ")) (progn ; (setq eLast (entlast)) (setvar "CLAYER" "flex-cr") (command "_.pline" "_non" pt) (while (= 1 (logand (getvar 'cmdactive) 1)) (princ "\nSpecify next point: ") (command PAUSE) ) (or (equal eLast (setq ent (entlast))) (command "_.fillet" "_P" ent) ) ) ) (setvar "CLAYER" OldLayer) (princ) ) works a treat. Thanks to all. Quote
jammie Posted October 1, 2010 Posted October 1, 2010 As a side note, Jammie, how would you combine this code into the other lisp code I posted? Your could add it pre the polyline command (defun c:FlexLine ( / *error* LastEntity OldLayer pt ent ) (defun *error* ( msg ) (and OldLayer (setvar "CLAYER" OldLayer)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq LastEntity (entlast) OldLayer (getvar "CLAYER")) (or (tblsearch "LAYER" "FLEX-CR") (command "_.-layer" "_M" "FLEX-CR" "")) (if (setq input (getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">:") ) ) (setvar 'filletrad input) ) (if (and (setq pt (getpoint "\nSpecify start point: ")) (progn (setvar "CLAYER" "FLEX-CR") (command "_.pline" pt "_W" 0.0 0.0) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (not (equal LastEntity (setq ent (entlast)))) ) ) (command "_.fillet" "_P" ent) ) (setvar "CLAYER" OldLayer) (princ) ) or post (defun c:FlexLine ( / *error* LastEntity OldLayer pt ent ) (defun *error* ( msg ) (and OldLayer (setvar "CLAYER" OldLayer)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq LastEntity (entlast) OldLayer (getvar "CLAYER")) (or (tblsearch "LAYER" "FLEX-CR") (command "_.-layer" "_M" "FLEX-CR" "")) (if (and (setq pt (getpoint "\nSpecify start point: ")) (progn (setvar "CLAYER" "FLEX-CR") (command "_.pline" pt "_W" 0.0 0.0) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (not (equal LastEntity (setq ent (entlast)))) ) ) (progn (if (setq input (getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">:") ) ) (setvar 'filletrad input) ) (command "_.fillet" "_P" ent) ) ) (setvar "CLAYER" OldLayer) (princ) ) Although your new code seems to work well. Glad you got it sorted Regards Jammie Quote
oldsoftboss Posted October 3, 2010 Author Posted October 3, 2010 Thanks for the help and feedback. Dave 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.