Message 1 of 26
Fillet in polyline two lines or with other words change the fillet radius
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to write an lisp program which can go through a polyline if the fillet radius is bigger than 3 will change the radius with a given value eg. 0.1 mm.
I tried to use the fillet command but I couldn't get it work. I can read the points from the polyline and if I tried the p2 p3 points with fillet an error message popped up - cannot fillet.
Is it possible somehow to get the names of the straight lines from polyline? Maybe with the names the fillet could work.
I tried to select the straight lines with fence selection creating theoretical perpendicular crossing lines but it also give me the failure message: invalid selection.
(defun c:RADIUS3 (/ *error* width radius aselection sslen counter data typ
angarc bulge element l name obj p1 p2 p3
p4 p1a p2a p3a p4a ss1 ss2 r segmentindex
numberPolyArc dbr3 number_of_arcs p1p2_angle p3p4_angle radius_change
)
-------------------------------------------------------------------------
(vl-load-com)
(setq width 1) ;width o the arc segments in the polyline
(setq radius 2.99999) ;the defined smallest radius, ARC with smaller radius hast to be selected
(setq radius_change 0.1)
(setq selection (ssget))
(setq sslen (sslength selection))
(setq counter 0)
(setq numberPolyArc 0)
(setq dbr3 0) ;counter for ARCs with smaller radius then 3 mm
(setq number_of_arcs 0)
-------------------------------------------------------------------------
(if
(/= sslen 0)
(repeat sslen
(setq name (ssname selection counter))
(setq data (entget name))
(setq typ (cdr (assoc 0 data)))
----------------------------------------------------------------------------------
(if (or (= typ "POLYLINE") (= typ "LWPOLYLINE"))
(progn
(setq element (fix (vlax-curve-getendparam name))) ;number of segments of the polyline
(setq segmentindex -1)
(setq obj (vlax-ename->vla-object name))
(repeat (- element 1)
(setq p1 (vlax-curve-getpointatparam name (setq segmentindex (1+ segmentindex))))
(setq bulge1 (vla-getbulge (vlax-ename->vla-object name) segmentindex))
(setq p2 (vlax-curve-getpointatparam name (+ 1 segmentindex)))
(setq bulge2 (vla-getbulge (vlax-ename->vla-object name) (+ 1 segmentindex)))
(setq p3 (vlax-curve-getpointatparam name (+ 2 segmentindex)))
(setq bulge3 (vla-getbulge (vlax-ename->vla-object name) (+ 2 segmentindex)))
(setq p4 (vlax-curve-getpointatparam name (+ 3 segmentindex)))
(setq bulge4 (vla-getbulge (vlax-ename->vla-object name) (+ 3 segmentindex)))
(command "point" p1)
(command "point" p2)
(command "point" p3)
(command "point" p4)
;print the co-ordinates
;(princ (strcat " bulge = " (rtos bulge))) ;print the bulge
-------------------------------------------------------------------------
;If radius small then change the width
(if (and (= bulge1 0) (= bulge3 0) (/= bulge2 0))
(progn
(setq l (distance p2 p3))
(setq angarc (* 4.0 (atan bulge2)))
(setq r (abs (/ (/ l 2) (sin (/ angarc 2.0)))))
(princ (strcat " r = " (rtos r)))
(if (>= r radius)
(progn
;;; (setq p1 (getpoint))
;;; (setq p2 (getpoint p1))
;;; (command "line" p1 p2 "")
(setq p1p2_angle (angle p1 p2))
(setq p1a (polar (polar p1 p1p2_angle ( / (distance p1 p2) 2)) (+ p1p2_angle (angtof "90")) 1))
(setq p2a (polar (polar p1 p1p2_angle ( / (distance p1 p2) 2)) (+ p1p2_angle (angtof "270")) 1))
(setq ss1 (ssget "F" (list p1a p2a)))
(command "line" p1a p2a "")
(setq p3p4_angle (angle p3 p4))
(setq p3a (polar (polar p3 p3p4_angle ( / (distance p3 p4) 2)) (+ p3p4_angle (angtof "90")) 1))
(setq p4a (polar (polar p3 p3p4_angle ( / (distance p3 p4) 2)) (+ p3p4_angle (angtof "270")) 1))
(setq ss2 (ssget "F" (list p3a p4a)))
(command "line" p3a p4a "")
;;; (command "point" (polar p1 p1p2_angle ( / (distance p1 p2) 2)) )
;;; (command "point" (polar p3 p3p4_angle ( / (distance p3 p4) 2)) )
(setq pt1 (cadr (cadddr (car (ssnamex ss1 0))))
pt2 (cadr (cadddr (car (ssnamex ss2 0))))
)
(command "point" pt1)
(command "point" pt2)
(princ pt1)
(princ pt2)
(setq r (+ r radius_change))
(setvar "FILLETRAD" r)
(vla-setwidth obj (+ 1 segmentindex) width width)
(command "_.fillet" pt1 pt2)
(setq numberPolyArc (1+ numberPolyArc))
) ;end progn
(vla-setwidth obj (+ 1 segmentindex) 0 0)
) ;end if
) ;end progn
) ;end if
-------------------------------------------------------------------------
) ;end repeat
) ;progn
) ;if
----------------------------------------------------------------------------------
(setq counter (+ 1 counter))
) ;end repeat
) ;end if sslen
(princ)
)