Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted

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.

Posted
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

Posted

Thanks for the help and feedback.

 

Dave

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...