Jump to content

Fillet polyline in LISP


Kenter

Recommended Posts

I made a polyline in LISP and want to add to the program so it will automatically fillet that polyline without asking the user to click on the one they want. I know you can use ssget, and have it aquire the last object made or something like that. And i know the fillet will hit every corner on the polyline as soon as you click the polyline. I am unsure how to do it though. I looked at the help and it didn't clear it up for me. I have a few polylines on the page so a select all wont work. Any idea's welcome.

Link to comment
Share on other sites

You should really post your code, to remove all confusion.

 

So, you are wanting to draw an LWPolyline and have each vertex filleted with a specified radius or are you wanting to fillet a drawn LWPolyline with something else?

Link to comment
Share on other sites

block 3.jpgI have a very long code. However all I need is a way to fillet a polyline I have already created using LISP. All the corners will have a 0.03 fillet. Here is the code to take a look. You must have two layers created 'plate' 'x-laser' or else nothing will happen. It makes one piece off to the right side which is a wall mount and only the polyline outside and two inner boxes will be filleted.

BoxPlate90.LSP

Link to comment
Share on other sites

Here, I did this as an example, so you can follow suite from it. :)

 

(defun c:PF (/ pt eLast ent)
 ;; Alan J. Thompson, 07.21.10
 (setvar 'filletrad
         (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">: ")))
               ((getvar 'filletrad))
         )
 )
 (if (setq pt (getpoint "\nSpecify start point: "))
   (progn
     (setq eLast (entlast))
     (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)
     )
   )
 )
 (princ)
)

 

pf.gif

Link to comment
Share on other sites

(setvar 'filletrad
         (cond ((getdist (strcat "\nSpecify fillet radius <" (rtos (getvar 'filletrad)) ">: ")))
               ((getvar 'filletrad))
         )
 )

 

Nice coding!

Link to comment
Share on other sites

How do you make a Layer current since that it isn't in a drawing, I maen you should make a Layer first and automatically would

be set to current.

(setvar 'clayer "x-laser")

(setvar 'clayer "plate")

"_.-layer"

 

So where is the area that you want to fillet?

 

Tharwat

Link to comment
Share on other sites

How do you make a Layer current since that it isn't in a drawing, I maen you should make a Layer first and automatically would

be set to current.

(setvar 'clayer "x-laser")

(setvar 'clayer "plate")

"_.-layer"

 

So where is the area that you want to fillet?

 

Tharwat

 

Excellent point. Also, know that if a layer is frozen and you try and set it as current with setvar 'clayer or vla-put-activelayer, it will crash. Always use -layer and thaw the layer before setting as current or vla-put-freeze x :vlax-false before setting a layer as current.

 

I would also check.

(if (tblsearch "LAYER" "BLAH")
 thaw and set layer as current
 create layer
)

Link to comment
Share on other sites

Excellent point.

 

Thanks Alanjt.

And here is many more.

)					
   [color="red"](BPReset)
 )	
(defun BPReset ()
   (setvar 'plinewid plw)
   (setvar 'osmode osm)
   (setvar 'blipmode blipm)
   (setvar 'clayer curlay)
   (command "_.undo" "_end")
   (setvar 'cmdecho cmde)
 )				[/color]	; end defun
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (command "_.undo" "_begin")
 (setq osm (getvar 'osmode))
 (setvar 'osmode 0)
 (setq blipm (getvar 'blipmode))
 (setqcurlay (getvar 'clayer)
   plw	   (getvar 'plinewid)

 

The defun of functions must be called after getting the values of Sys Vars, just to let the defun get a value for each SETVAR's.

And if you wanted to turn specific Sys Vars off first, so you can bring them out of the routine codes and just include the name

of the defun at your favourite place.

 

Regards

 

Tharwat

Link to comment
Share on other sites

(setqcurlay (getvar 'clayer)
You might want to fix this. I also don't see the point in making this into a subroutine. Just save variables before and reset them at appropriate time.
Link to comment
Share on other sites

Thank you all, I have gone through and made changes from you suggestions. Figured out the fillet thing as well.

 

 

(command

"_.fillet" "_r" 0.03

"_.fillet" "_polyline" b1

"_.fillet" "_polyline" b2

"_.fillet" "_polyline" b6

"_.fillet" "_polyline" b9

"_.fillet" "_polyline" (mapcar '+ pLL (list 10.941 2.5 0))

"_.fillet" "_polyline" (mapcar '+ pUL (list 10.941 -2.5 0))

)

Link to comment
Share on other sites

Thank you all, I have gone through and made changes from you suggestions. Figured out the fillet thing as well.

 

 

(command

"_.fillet" "_r" 0.03

"_.fillet" "_polyline" b1

"_.fillet" "_polyline" b2

"_.fillet" "_polyline" b6

"_.fillet" "_polyline" b9

"_.fillet" "_polyline" (mapcar '+ pLL (list 10.941 2.5 0))

"_.fillet" "_polyline" (mapcar '+ pUL (list 10.941 -2.5 0))

)

Good deal. :)
Link to comment
Share on other sites

  • 4 years later...
Dear all!

 

Please help me!

 

(defun fb (r1 r2 b)

....

)

 

 

hi 萬里独行 welcome to forum :)

please understand we are volunteers so don't expect too high

1.not working well if close polyline. (tips: dxf 70)

2.error if offset too sharp

3.only standard fillet & radius applied

so you can study, modify etc..

hope better than nothing :)

 

;fop.lsp :fillet open polyline
(defun c:fop (/ *error*  r e d)
;hanhphuc 2014
 (defun *error* (msg) (if msg 
 (princ "\n*cancel*")))
 (if (and (not (initget 5))
   (setq r (getdist "\nRadius : "))
   (not (initget 7))
   (setq d (getdist "\nWidth : "))
   (setq e (entsel "\nSelect Polyline.. "))
   (setq e (car e))
   (=(cdr(assoc 0 (entget e)))"LWPOLYLINE")
   (vl-cmdf "_fillet" "P" e)
   (setq e (vlax-ename->vla-object e))
   
   ) ;_ end of and
   (foreach x '("StartPoint" "EndPoint")
     (entmakex
(vl-list* '(0 . "LINE")
	  (cons 8 (vla-get-layer e))
	  (mapcar 'cons
		  '(10 11)
		  (mapcar '(lambda (o) ((eval (read (strcat "vlax-curve-get" x))) o))
			  (apply 'append (mapcar ''((x) (vlax-invoke e 'Offset (x (* d 0.5)))) (list + -)))
			  ) ;_ end of mapcar
		  ) ;_ end of mapcar
	  ) ;_ end of vl-list*
) ;_ end of entmakex
     ) ;_ end of foreach
  (princ "\nsorry..")
   ) ;_ end of if
(princ)
)

Edited by hanhphuc
Method applicable filter can be ignored
Link to comment
Share on other sites

hi 萬里独行 welcome to forum :)

please understand we help volunteer so don't expect too high

1.not working well if close polyline. (tips: dxf 70)

2.error if offset too sharp

3.only standard fillet & radius applied

so you can study, modify etc..

hope better than nothing :)

 

Thank you so much! But...

 

Fillet polyline with 2 radius: R1 and R2

+ R1 for END

+ R2 for MID

 

Please!

Sorry! My English skills so poor!

Link to comment
Share on other sites

Thank you so much! But...

 

Fillet polyline with 2 radius: R1 and R2

+ R1 for END

+ R2 for MID

 

Please!

Sorry! My English skills so poor!

 

It means you have just 2 numbers of R1, why can be done manually??

use FOP.lsp for R2 in MID.

 

If fully automated you need to write single fillet function. but wish i could have more free time :huh:

 

here is some useful polyline tools HTH

Edited by hanhphuc
add reference link
Link to comment
Share on other sites

Was available:

1. Open polyline.

2. Layer Boundaries.

 

Input: R1, R2 and B

1. R1 is fillet radius for begin & end vertices.

2. R2 is fillet radius for between the remaining vertices

3. B is width of boundaries.

 

Requirements:

Boundaries is a polyline in layer “Boundaries” (was available)

 

(*) Detailed description in attach file.

Pline.dwg

Link to comment
Share on other sites

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...