Auto Curve Polyline Corners

Auto Curve Polyline Corners

ebsoares
Collaborator Collaborator
1,751 Views
10 Replies
Message 1 of 11

Auto Curve Polyline Corners

ebsoares
Collaborator
Collaborator

Hi, all.

 

Is there a way to automatically turn polyline corners into curves - as we draw it? This would be somewhat similar to Revit's Draw Line command, where it allows chains to automatically do that too.

 

Thanks in advance,

 

Edgar

0 Likes
Accepted solutions (1)
1,752 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

Try PlineFilletAlong.lsp with its PLFA command, >here<.

Kent Cooper, AIA
0 Likes
Message 3 of 11

ebsoares
Collaborator
Collaborator

Fantastic - thanks a bunch, Kent 😊

0 Likes
Message 4 of 11

tamas.antal
Contributor
Contributor

Dear @Kent1Cooper 

 

When I click to your link for some reason it sais "redirect from archived ".

Is this link of yours available in other version or other thread? 

 

Btw thank you for your lsp-s, they are awesome!

 

Sincerely,

 

Tamás

0 Likes
Message 5 of 11

ebsoares
Collaborator
Collaborator

Hi, @tamas.antal.

not sure what happened to that link, but here's the code from Kent:

;;
;;	Kent Cooper, 13 June 2013
;;	
;;	PLineFilletAlong.lsp [command name: PLFA]
;;	To draw a PolyLine of zero-width line segments and Fillet the corners along the way.
;;	User specifies non-0 Fillet radius [offers current radius as default if non-0].
;;	Turns Ortho on for right-angle corners, but can be edited to not do so, and/or
;;		User can turn it off or on during routine.
;;	Notifies User if any combination of segments cannot be Filleted at current
;;		radius, Fillets at 0 radius to join new segment to Pline, then resets radius;
;;		check designed for right angles, so may not always work if non-orthogonal.
;;	Draws on the current Layer.
;;
;; ------------------------------------------------------------------------------------
;;	Lightly edited by Edgar Soares, May 2022
;; ------------------------------------------------------------------------------------
;;



;; Calls out main routine. Uses current filletrad variable if non-zero
(defun C:PLF ( / )
	(if (> (getvar 'filletrad) 0) ; if radius is > 0
		(pLineFilletAlong 0) ; do not change fillet radius
		(pLineFilletAlong 1) ; do change fillet radius
	)
)

; Calls out main routine. Asks to change fillet radius (filletrad variable)
(defun C:PLFR ( / )
	(pLineFilletAlong 1) ; do change fillet radius
)

; Main Routine: PolyLine, Filleted Along the way
(defun pLineFilletAlong (checkRadius / *error* myFilletRadius filletIt cmde orth myFilletRadiusTemp myPLine new)
	
	(defun *error* (errmsg)
		(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
			(prompt (strcat "\nError: " errmsg))
		)
		(setvar 'orthomode orth) ;; delete or comment out if not desired
		(command "_.undo" "_end")
		(setvar 'cmdecho cmde)
		(princ)
	)
	
	(defun myFilletRadius () (getvar 'filletrad))
	
	(defun filletIt ()
		(command "_.fillet"
			(vlax-curve-getPointAtParam myPLine (- (vlax-curve-getEndParam myPLine) 0.5))
			;; midpoint of last Polyline segment
			(vlax-curve-getEndPoint new); becomes 'lastpoint for next segment
		)
	)
	
	(setq
		cmde (getvar 'cmdecho)
		orth (getvar 'orthomode) ;; delete or comment out if not desired
	)
	(setvar 'cmdecho 0)
	(command "_.undo" "_begin" "_.ortho" "on") ;; delete last two words if not desired
	
	(initget (if (= (myFilletRadius) 0) 7 6)); no 0, no negative, no Enter if FILLETRAD=0
	
	(if (= checkRadius 1)
		(checkFilletRadius myFilletRadius)
	)
	
	(setq myFilletRadiusTemp (myFilletRadius)); to reset when temporarily set to 0 for too-short segment(s)
	(command
		"_.pline"
		(getpoint
			(strcat "\nSpecify start point (r=" (rtos (myFilletRadius)) "):")
		)
		"_width" 0 0 ; [if allow non-0 width, Fillet selection points may not find Pline]
		(getpoint (getvar 'lastpoint) "\nSpecify next point: ")
		""
	)
	(setq myPLine (entlast))
	(while (setq pt (getpoint (getvar 'lastpoint) "\nSpecify next point: "))
		(command "_.pline" "@" pt "")
		(setq new (entlast))
		(if
			(and
				(>=
					(- ; last segment length of Polyline
					(vlax-curve-getDistAtParam myPLine (vlax-curve-getEndParam myPLine))
					(vlax-curve-getDistAtParam myPLine (1- (vlax-curve-getEndParam myPLine)))
					); -
					(myFilletRadius)
				)
				(>= (vlax-curve-getDistAtParam new (vlax-curve-getEndParam new)) (myFilletRadius))
					;; length of new segment
			)
			(filletIt); then
			(progn
				(prompt "\nSegments too short for fillet radius."); else
				(setvar 'filletrad 0)
				(filletIt)
				(setvar 'filletrad myFilletRadiusTemp)
			)
		)
	)
	
	(setvar 'orthomode orth) ;; delete or comment out if not desired
	(command "_.undo" "_end")
	(setvar 'cmdecho cmde)
	(princ)
)

(defun checkFilletRadius (myFilletRadius / )
	(setvar 'filletrad
		(cond
			((getdist
				(strcat
				"\nSpecify fillet radius"
				(if (= (myFilletRadius) 0) "" (strcat " <" (rtos (myFilletRadius)) ">")); current as option only if non-zero
				": "
				)
			)
			); User-specified-radius condition
			((myFilletRadius)); keep current value on User Enter if non-zero
		)
	)
)

(vl-load-com)

(princ "\nPLF+ (Polyline Filleted).lsp\n")
(princ)

I reformatted it a bit and changed the calling commands, but otherwise it's his coding altogether (thanks again, Kent!)

0 Likes
Message 6 of 11

tamas.antal
Contributor
Contributor

Hi There

 

Thank you guys for the great work and the quick response!

0 Likes
Message 7 of 11

tamas.antal
Contributor
Contributor

Ammmm..... does it supposed to switch itself off after 2-3 lines? Can it have compatilibity issue with Autocad 2022? Or am I doing something wrong..... maybe

0 Likes
Message 8 of 11

ebsoares
Collaborator
Collaborator

It's a very finicky routine, to be sure. I've had issues with it sometimes, even when following all prompts.

The main thing to me that seems to make it glitch out is turning off the ortho while the program is running - depending on the angle you have between the previous and current segment it can stop working. Also, if you snap to a previously existing polyline/line it might stop working as well.

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

@ebsoares wrote:

.... here's the code from Kent:

....
;;	Lightly edited by Edgar Soares, May 2022
....

I reformatted it a bit and changed the calling commands, but otherwise it's his coding altogether (thanks again, Kent!)


That's actually rather heavily edited -- not simple reformatting, but several added sub-routines, localizing of at least one variable that was global, etc.  I haven't tried it, but in case my original might behave any differently, I'm attaching it.

Kent Cooper, AIA
0 Likes
Message 10 of 11

ebsoares
Collaborator
Collaborator

Thanks for providing your original code, Kent 👍

 

I usually edit the lisp routines I download into a format I'm more familiar with and helps me understand the code when I read it later (formatting, adding comments, change/adding calling commands and shortcuts, changing variable names to long, descriptive ones, etc) - but the code itself (the gears and the brain that make it all work) I don't usually change. But now that I think about it, and I wrote it all above, I think you are right about it kinda being "heavily" edited 😁

 

This routine is very good and I use it often - and you have helped me out countless times, so I'm really thankful, Kent!

0 Likes
Message 11 of 11

tamas.antal
Contributor
Contributor

Hi!

 

Thank you for the code, now it works, except if I click all around a closed loop the last/first connection point won't have the radius.

 

Anyhow it is seems to be working. Ortho  needed to be shut off but working. Thanks!

0 Likes