Fillet command where two lines meet at the same coordinates

Fillet command where two lines meet at the same coordinates

craig-s-sunderland
Enthusiast Enthusiast
4,885 Views
34 Replies
Message 1 of 35

Fillet command where two lines meet at the same coordinates

craig-s-sunderland
Enthusiast
Enthusiast

Good evening

I have two lines being drawn via lisp and the calculated coordinates that one end of each of the lines meet needs to be filleted.

 

Sadly I haven't got this working yet as when specifying the same coordinates twice in the command (first and second selection) results in an error specifying I am trying to fillet the same entity twice...

 

Could one of the experts shed some light on where I have gone wrong?

 

 

4,886 Views
34 Replies
Replies (34)
Message 21 of 35

Scottu2
Advocate
Advocate

Hi guys,

Perhaps drawing the lines short, instead of landing at a coincident point, then the fillet command can catch the endpoint of each line to form the specified radius.

The lines at angle A and I should extend beyond the ID so they can be selected for the trimming circle.

The fillet angles A, I, D, F, H and L may be tricky to select the arc endpoint instead of the line.

Scott U.

Message 22 of 35

john.uhden
Mentor
Mentor

A method that works using the FILLET command is like this...

(setvar "filletrad" 0.5)
(and
  (setq e1 (entsel "\nSelect fist line: "))
  (setq e2 (entsel "\nSelect second line: "))
  (vl-cmdf "_.fillet" e1 e2)
)

because entsel returns a list of both the entity name selected and the point at which it was selected.

John F. Uhden

Message 23 of 35

john.uhden
Mentor
Mentor

But you may have just entmade the two lines and don't want to have to select them each again.  In that case, use entmakex, as in (setq e1 (entmakex ...) e2 (entmakex ...))

Then find the midpoint of each line (say mid1 and mid2) and (setq e1 (cons e1 mid1)) and (setq e2 (cons e2 mid2)).  Then you can fillet e1 e2.

John F. Uhden

Message 24 of 35

craig-s-sunderland
Enthusiast
Enthusiast

Thank you all very much for your help so far, learning this stuff is fun and I 'think' i'm starting to get the hang of the flow of it.

 

This is the code I have so far: ( I know in advance I need to add the error handling which has already been suggested, but I wanted to make sure the bulk of this worked before adding the extra bits). 

 

I am wanting to also fillet the lines that have an intersection with the 'id' but when I try using the method in the code below, odd things happen lol. Trimming eventually would be great between those lines that intersect with the 'id'.

 

As always,  suggestions are very much appreciated.

 

beforebeforeafter filleting lines to 'id' and trimmingafter filleting lines to 'id' and trimming

 

(defun C:Y-BAR( / zero osm od id idf bw bw2 aa bb aat aab bbt bbb irad erad a b c d e f g h i j k l )
  (setq
    od (getdist "\nOD (mm): ")
    id (getdist "\nID (mm): ")
    id2 (/ id 2)
    bw (getdist "\nBar Width (mm): ")
    bw2 (/ bw 2)
    aa (getdist "\nMeasurement 'AA' (mm): ")
    bb (getdist "\nMeasurement 'BB' (mm): ")
    aat (+ aa bw2)
    aab (- aa bw2)
    bbt (- bb bw2)
    bbb (+ bb bw2)
    irad (getdist "\nInternal Rad (mm): ")
    erad (getdist "\nExternal Rad (mm): ")
    zero '(0 0)
    a (list (- id2) bw2)
    b (list (- bw2) bw2)
    c (list (- bw2) aat)
    d (list id2 aat)
    e (list bw2 aab)
    f (list id2 aab)
    g (list bw2 (- bbt))
    h (list id2 (- bbt))
    i (list (- id2) (- bw2))
    j (list (- bw2) (- bw2))
    k (list (- bw2) (- bbb))
    l (list id2 (- bbb))
    osm (getvar 'osmode)
  )
  (setvar 'osmode 0)
  (command "_.Circle" "_non" zero "D" od)
  (command "_.Circle" "_non" zero "D" id)
  (setq idf (entlast))
  (command "_.Line" "_non" a "_non" b "")
  (setq ab (entlast))
  (command "_.Line" "_non" b "_non" c "")
  (setq bc (entlast))
  (command "_.Line" "_non" c "_non" d "")
  (setq cd (entlast))
  (command "_.Line" "_non" e "_non" f "")
  (setq ef (entlast))
  (command "_.Line" "_non" e "_non" g "")
  (setq eg (entlast))
  (command "_.Line" "_non" g "_non" h "")
  (setq gh (entlast))
  (command "_.Line" "_non" i "_non" j "")
  (setq ij (entlast))
  (command "_.Line" "_non" j "_non" k "")
  (setq jk (entlast))
  (command "_.Line" "_non" k "_non" l "")
  (setq kl (entlast))
  (setvar "filletrad" irad)
    (and
      (vl-cmdf "_.fillet" ab bc)
      (vl-cmdf "_.fillet" ef eg)
      (vl-cmdf "_.fillet" eg gh)
      (vl-cmdf "_.fillet" ij jk)
    )
  (setvar "filletrad" erad)
    (and
      (vl-cmdf "_.fillet" bc cd)
      (vl-cmdf "_.fillet" jk kl)
    )
  (setvar 'osmode osm)
  (princ)
)

I hope all the information is of some use...

0 Likes
Message 25 of 35

john.uhden
Mentor
Mentor

Not bad, my friend.  Keep up the good work!

John F. Uhden

Message 26 of 35

craig-s-sunderland
Enthusiast
Enthusiast

Appreciated John, would you happen to have any tips for the filleting at the ID and the trimming by any chance?

 

🙂

0 Likes
Message 27 of 35

john.uhden
Mentor
Mentor
To deal with the circls, practice the TRIM and BREAK commands. Circles are
not 360° arcs. In fact arcs can not be 360°.
OR.. draws arcs instead of circles in the first place.

John F. Uhden

0 Likes
Message 28 of 35

ВeekeeCZ
Consultant
Consultant

One more little step to me, giant...

 

(vl-load-com)

(defun C:Y-BAR( / zero osm od id idf bw bw2 aa bb aat aab bbt bbb irad erad a b c d e f g h i j k l )
 
  (setq
    od (getdist "\nOD (mm): ")
    id (getdist "\nID (mm): ")
    id2 (/ id 2)
    bw (getdist "\nBar Width (mm): ")
    bw2 (/ bw 2)
    aa (getdist "\nMeasurement 'AA' (mm): ")
    bb (getdist "\nMeasurement 'BB' (mm): ")
    aat (+ aa bw2)
    aab (- aa bw2)
    bbt (- bb bw2)
    bbb (+ bb bw2)
    irad (getdist "\nInternal Rad (mm): ")
    erad (getdist "\nExternal Rad (mm): ")
    zero '(0 0)
    a (list (- id2) bw2)
    b (list (- bw2) bw2)
    c (list (- bw2) aat)
    d (list id2 aat)
    e (list bw2 aab)
    f (list id2 aab)
    g (list bw2 (- bbt))
    h (list id2 (- bbt))
    i (list (- id2) (- bw2))
    j (list (- bw2) (- bw2))
    k (list (- bw2) (- bbb))
    l (list id2 (- bbb))
    osm (getvar 'osmode)
  )
  (setvar 'osmode 0)
  (command "_.Circle" "_non" zero "D" od)
  (command "_.Circle" "_non" zero "D" id)
  (setq idf (entlast))
  (command "_.Line" "_non" a "_non" b "")
  (setq ab (entlast))
  (command "_.Line" "_non" b "_non" c "")
  (setq bc (entlast))
  (command "_.Line" "_non" c "_non" d "")
  (setq cd (entlast))
  (command "_.Line" "_non" e "_non" f "")
  (setq ef (entlast))
  (command "_.Line" "_non" e "_non" g "")
  (setq eg (entlast))
  (command "_.Line" "_non" g "_non" h "")
  (setq gh (entlast))
  (command "_.Line" "_non" i "_non" j "")
  (setq ij (entlast))
  (command "_.Line" "_non" j "_non" k "")
  (setq jk (entlast))
  (command "_.Line" "_non" k "_non" l "")
  (setq kl (entlast))
  (setvar "filletrad" irad)
    (and   ; <- no point of this and, it's always T
      (vl-cmdf "_.fillet" ab bc)
      (vl-cmdf "_.fillet" ef eg)
      (vl-cmdf "_.fillet" eg gh)
      (vl-cmdf "_.fillet" ij jk)
    )
  (setvar "filletrad" erad)
    (and ; <-the same here
      (vl-cmdf "_.fillet" bc cd)
      (vl-cmdf "_.fillet" jk kl)
    )

  (and (setq ia (car (LM:intersections (vlax-ename->vla-object ab) (vlax-ename->vla-object idf) acextendnone)))
       (setq ii (car (LM:intersections (vlax-ename->vla-object ij) (vlax-ename->vla-object idf) acextendnone)))
       (vl-cmdf "_.break" idf "_non" ia "_non" ii)
       (setvar "filletrad" irad)
       (vl-cmdf "_.fillet" (list idf ia) (list ab ia))
       )
  
  (setvar 'osmode osm)
  
  (princ)
)

  ;; Intersections  -  Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;;     mod - [int] acextendoption enum of intersectwith method

(defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
             (vlax-method-applicable-p ob2 'intersectwith)
             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
        )
        (repeat (/ (length lst) 3)
            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
                  lst (cdddr lst)
            )
        )
    )
    (reverse rtn)
)

For more info look HERE 

0 Likes
Message 29 of 35

ВeekeeCZ
Consultant
Consultant

Sorry @john.uhden  to spoil your little game here. I thought the OP needs this little push to get further... But it should be enough to get the job done by himself, am I right @craig-s-sunderland? Although there are still some minor challenges left to you to figure out!

 

Message 30 of 35

john.uhden
Mentor
Mentor
Excuse me @ВeekeeCZ but there is no I in TEAM.

John F. Uhden

Message 31 of 35

craig-s-sunderland
Enthusiast
Enthusiast

Good morning John, thank you for the pointer on the trim and break, I will certainly have a look at those.

 

My problem is not quite knowing how to approach it. For instance, I know I can draw an arc, but how do I know where to start and end the arc bearing in mind there will be an intersection against a calculated line... or is that actually the point? To understand where the intersection will be, break and trim from there and fillet later?

0 Likes
Message 32 of 35

craig-s-sunderland
Enthusiast
Enthusiast

Thank you for your offering Bee, much appreciated. I'm just trying to get my head around what is happening there but from what I gather this code that Lee has written looks for existing intersections or potential intersections? Interesting stuff.

 

You mentioned that other bits can be cleaned up, however, you may have already caught onto an issue I have just now realised is present.

 

The code in the lisp seems to be ignoring my (setq variable (entlast)) on the circles... if I run my lisp routine and use the command line 'select' and '!idf', nil is returned as if the variable was never set in entlast. BUT if I just randomly draw a circle on the screen and use the (setq blob (entlast)) and then in command 'Select!' and '!blob' the selection works... is there any reason why doing the same thing in lisp isn't selecting the circle?

 

(defun c:IBC ( / OD ID p1 ODs IDs )
  (setq
    OD (getdist "OD (mm): ")
    ID (getdist "ID (mm): ")
    p1 '(0 0)
  )
  (command "_.Circle" "_non" p1 "D" OD)
  (setq ODs (entlast))
  (command "_.Circle" "_non" p1 "D" ID)
  (setq IDs (entlast))
  (princ)
)

 

 

0 Likes
Message 33 of 35

ВeekeeCZ
Consultant
Consultant

@craig-s-sunderland wrote:

Thank you for your offering Bee, much appreciated. I'm just trying to get my head around what is happening there but from what I gather this code that Lee has written looks for existing intersections or potential intersections? Interesting stuff.


 

Well, look HERE to help first. Very handy method for such case. All what Lee did is just that he put it into a nice suite.

See the last parameter. I used 'acextendnone' since I wanted the real one (and only one). If I use the extend option, it will find 2 intersections and you need to somehow decide which one is the one you wanted to get.

 

 


@craig-s-sunderland wrote:

You mentioned that other bits can be cleaned up, however, you may have already caught onto an issue I have just now realised is present.

 

The code in the lisp seems to be ignoring my (setq variable (entlast)) on the circles... if I run my lisp routine and use the command line 'select' and '!idf', nil is returned as if the variable was never set in entlast. BUT if I just randomly draw a circle on the screen and use the (setq blob (entlast)) and then in command 'Select!' and '!blob' the selection works... is there any reason why doing the same thing in lisp isn't selecting the circle?

 

(defun c:IBC ( / OD ID p1 ODs IDs ) ; localized variables
  (setq
    OD (getdist "OD (mm): ")
    ID (getdist "ID (mm): ")
    p1 '(0 0)
  )
  (command "_.Circle" "_non" p1 "D" OD)
  (setq ODs (entlast))
  (command "_.Circle" "_non" p1 "D" ID)
  (setq IDs (entlast))
  (princ)
)

 

Your code is perfectly fine. But since you localized these variables, which is actually a good thing, you need to realize that these variables are valid only within this program IBC, nowhere outside. Try to remove them...

Use the VLIDE editor to trace and watch the difference as I did HERE

0 Likes
Message 34 of 35

john.uhden
Mentor
Mentor
You should investigate and learn about ActiveX methods such as
vla-intersectwith which takes two arguments being each of the vla-objects
to intersect plus an integer option to extend one or the other or both.
Don't forget to include (vl-load-com) at the top of your code. It can be
called a million times a day and cost you just a few milliseconds.

John F. Uhden

Message 35 of 35

craig-s-sunderland
Enthusiast
Enthusiast

I tested by removing the variables from the declaration at the top of the lisp and was immediately able to interact with the drawn objects using the command line afterwards.

Thank you for the pointer, very much appreciated!

0 Likes