Jump to content

Lisp for trimming corners within an area?


Cad-n-ator

Recommended Posts

Hello all! I am getting fimilar with lisp now and would like to know if anyone could give me insite to creating a lisp that would basically trim or fillet corners within an area chosen.

 

Start with this: picture 1

 

and the output to look picture 2

 

Thanks!

1.gif

2.jpg

Link to comment
Share on other sites

Cad-n-ator,

If you want your lisp to do all the intersections in one go, you could use SSGET with the "I" implied mode, to get all the lines which you had previously selected (with PICKFIRST on). Then it's a matter of writing a loop to check each line against the others and find the intersections (with INTERS). Within that loop, every time you have an intersection you could call the FILLET command with a zero radius to get a double trim. This is one approach among many. Enjoy.

Link to comment
Share on other sites

I was thinking something along the same lines as Randy...

For your example drawing you could accomplish this because for each line there is only two intersections. What about if there is more than two (ie your overall group is not a square)? You'd have to introduce conditions like only intersections within a certain distance from either end. I'd say if you are learning lisp you are biting into a pretty big chunk..

Link to comment
Share on other sites

Thanks for the insite guys ... i am looking to just use this for rectangular areas. I'm still a newbie to the whole lisp/macro thing in autocad so i have my work cut out for me. Thanks!

Link to comment
Share on other sites

If you are looking to proceed with the fillet method (zero radius), then you would need to work out a way to know which lines in the selection set need to be filleted with which.

 

As, if you just iterate through the selectionset filleting all the lines with each other, you could get undesired fillets.

Link to comment
Share on other sites

Please try this:

 

(defun c:boxed (/ vlax-list->3D-point i j ss e1 e2 o1 o2 iLst)
 ;; by Lee McDonnell  ~  03.12.2009
 (vl-load-com)

 (defun vlax-list->3D-point (lst)
   (if lst
     (cons (list (car lst) (cadr lst) (caddr lst))
           (vlax-list->3D-point (cdddr lst)))))

 (if (setq i -1 ss (ssget '((0 . "LINE"))))
   
   (while (setq j (1+ i) e1 (ssname ss (setq i (1+ i))))
     
     (while (setq e2 (ssname ss (setq j (1+ j))))
       
       (if (setq iLst
             (vlax-list->3D-point
               (vlax-invoke
                 (setq o1 (vlax-ename->vla-object e1)) 'IntersectWith
                   (setq o2 (vlax-ename->vla-object e2)) acExtendBoth)))

         (foreach x (list e1 e2)
           
           (if (< (distance (vlax-curve-getStartPoint x) (car iLst))
                  (distance (vlax-curve-getEndPoint x)   (car iLst)))
             (vla-put-StartPoint (vlax-ename->vla-object x) (vlax-3D-point (car iLst)))
             (vla-put-EndPoint   (vlax-ename->vla-object x) (vlax-3D-point (car iLst)))))))))

 (princ))

Link to comment
Share on other sites

That works just like i wanted it too! Thanks! :D

How could i modify it so that i would not have to window or select the lines but just click within the rectangular area and it automatic do this?

Link to comment
Share on other sites

That works just like i wanted it too! Thanks! :D

How could i modify it so that i would not have to window or select the lines but just click within the rectangular area and it automatic do this?

 

Is the window selection just too much effort? :geek:

Link to comment
Share on other sites

Sorry - No, Just toying with the possibilities since i am still learning what all that lisp routines can do.

 

I see - well to have the user click inside of the polylines is a difficult feat to accomplish, as there is no inherent method to detect whether a point is within a certain boundary. And - in your case the boundary is broken upon invoking the command, so this further complicates things.

 

I have written various functions to determine the inside of a boundary, but these are not quick to implement and the drawbacks outweigh the advantages in such a program.

 

Just my 2 cents,

 

Lee

Link to comment
Share on other sites

Food for thought you should be able to fillet any shape with as many lines as you like,

 

If you draw a line through all lines the equivalent to using FENCE going in a circle you then can know the inters point of a line and the next line etc hence then just fillet. Obviously you erase the fence line as you go.

 

I did something like this for converting a room layout into the outside multi line architectural wall.

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