Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp file not working

3 REPLIES 3
Reply
Message 1 of 4
MD81GM
374 Views, 3 Replies

Lisp file not working

Hi,

 

For the lisp wizzards out there. Attached lisp file used to fillet all corners on a polyline selected to 40% of its length, so over large bends the fillet would be greater than short bends. Then it stopped working. After editing it now fillets to radius 400, and therefore wont fillet is bend is less than 400.  Any ideas?

 

Cheers.

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: MD81GM


@MD81GM wrote:

....Attached lisp file used to fillet all corners on a polyline selected to 40% of its length, so over large bends the fillet would be greater than short bends. Then it stopped working. After editing it now fillets to radius 400, and therefore wont fillet is bend is less than 400.  Any ideas?

 

Cheers.


I'm not sure about the always-400 thing [it doesn't do that for me], but if you're looking for 40%, I can't imagine where all those zeros are coming from in this:

 

;Set the fillet radius to 40% of the shortest leg and fillet the mother...

(setvar "FILLETRAD" (* dist 0.0000040))

 

Try changing that to this, which works as expected for me:

 

(setvar "FILLETRAD" (* dist 0.4))

 

EDIT:  One thing you might want to do, if you ever do this with closed Polylines, is include a check on the closing segment [the distance from the last vertex to the first one].  As it is, if that segment is the shortest one, the routine doesn't find that out, so that doesn't go into the 'dist' variable, and the fillet radius becomes 40% of the second-shortest segment.  Also, do you ever do this with Polylines that include arc segments?  That would introduce further complications, both in deciding what fillet radius to set and in the filleting operation itself.

Kent Cooper, AIA
Message 3 of 4
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

 

....I'm not sure about the always-400 thing....


But I have an idea about it:  400 is the product of your initial large 'dist' value and the multiplier with all the excess zeros in it.  It would seem that somehow either the calculating of the lengths of the segments, or the comparison of them to the current 'dist' value, isn't working, because nothing smaller is replacing that initial value.  But I don't see any obvious reason for those things not to work.

Kent Cooper, AIA
Message 4 of 4
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....  One thing you might want to do, if you ever do this with closed Polylines, is include a check on the closing segment....  Also, do you ever do this with Polylines that include arc segments?  That would introduce further complications ....


This accounts for the closed-Polyline possibility, and does various things in more concise ways, with far fewer variables:

 

(defun C:FP40 (/ pl verts minseg); = Fillet Polyline to 40% of shortest segment length
  (vl-load-com)
  (setq
    pl (car (entsel "\nSelect polyline: "))
    verts
      (mapcar 'cdr ; list of vertices
        (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pl))
      ); mapcar & verts
    minseg
      (apply 'min
        (mapcar
          '(lambda (y)
            (if (cdr (member y verts)); there's a later vertex
              (distance y (cadr (member y verts)))
              1e8 ; [oversize fallback -- otherwise nil at end]
            ); if
          ); lambda
          verts
        ); mapcar
      ); apply & minseg
  ); setq
  (if (vlax-curve-isClosed pl); compare closing segment
    (setq minseg (min minseg (distance (car verts) (last verts))))
  ); if
  (command "_.fillet" "_radius" (* minseg 0.4) "_.fillet" "_p" pl)
); defun

 

You can also have it reject selected things other than Polylines, and Polylines with any arc segments if desired, and Polylines on locked Layers, and have it ask again if you miss, and include various other controls.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost