←  Technical Questions

nanoCAD forum

»

Fillet several polylines

Adriano's Photo Adriano 25 Jan 2024

Hello!

I have tried to make (with no success) a lisp to fillet several polylines at the same time.

Why?

I have a CNC machine for leather cut, and the cornes of the shapes must be filleted with 1mm radius. The dxf files have many polylines, and I need to click one by one... total sum is almost 10000 polylines!!!

The ideia is make a "macro" or a lisp file, to change all the corners with one command.

I have tried with this code (its a code for autocad):

(vl-load-com)

(defun c:filetartudo (/ ss polyline filletedObj)
(setq ss (ssget "_X" '((0 . "LWPOLYLINE"))))
(if ss
(progn
(setq cnt 0)
(repeat (sslength ss)
(setq polyline (ssname ss cnt))

; Get the polyline as a VLA-object
(setq polyObj (vlax-ename->vla-object polyline))

; Tenta aplicar o fillet diretamente usando o método VLA-FILLET
(setq filletedObj
(vl-catch-all-apply
'vla-fillet
(list
polyObj
1.0 ; Raio do fillet configurado em 1
)
)
)

; Verifica se ocorreu algum erro durante a chamada
(if (vl-catch-all-error-p filletedObj)
(princ (strcat "\nError filleting polyline: " polyline))
; Se não houve erro, continue com o próximo polyline
(setq cnt (1+ cnt))
)
)
(princ "\nFillet aplicado para todas polilinhas.")
)
(princ "\nNão há polilinhas.")
)
(princ)
)

I have an error in the line: (setq polyObj (vlax-ename->vla-object polyline))

Someone can help with this?

Thanks
Quote

Dsw's Photo Dsw 26 Jan 2024

Hi Adriano,
may you share a sample file?

Would be interesting to know which nanoCAD Release are you using?
Quote

Adriano's Photo Adriano 26 Jan 2024

Hi,

Thank you for your answer.

I use the free nanocad version (5.0.2520.1471 - COMMERCIAL).

Here are two files as an example. The file "filetartudo.txt" need to be renamed for "filetartudo.lsp". The lisp file is already loaded in the dxf.

To use the command, you have to type "filetartudo" in nandocad

Thanks!

Attached Files

Quote

Dsw's Photo Dsw 27 Jan 2024

NanoCAD 5.0 the fillet dialog box (as much I know) can't be hidden breaking a simple automation script to do the job, that mean more time to develop a automation script.

I'm sorry but I've no time to do it for you, but maybe you will find the answer to your question on follow link
lisp - I need an AutoLISP for fillet command - Stack Overflow
Quote

Adriano's Photo Adriano 29 Jan 2024

Newbie. Thank you very much! I will try there.
Quote