Author Topic: fillet and block insert  (Read 6540 times)

0 Members and 1 Guest are viewing this topic.

jermjmm

  • Guest
fillet and block insert
« on: November 01, 2007, 02:38:51 PM »
I've been working on a lisp to fillet 2 lines then insert a block on the layer of one of the lines selected.  With some help/pointers from others (thanks Kent Cooper) I've got it working . . . . mostly.  the lisp does not always trim the lines correctly.  for instance if you have 2 lines that form a t and I pick the top of the vertical line and the right side of the horisontal line it should fillet the lines to endup looking like an L, correct? well it doesn't always do that.

My question is not only why is it doing this, but is fillet the best way to do it?  Would it be better to modify the endpoints?  If you modify the endpoints a click could be elimanated by using the new endpoint as the insertion of the block, the problem is I only know about this process I've never seen code to do it let alone know how.

here is the lisp:

Code: [Select]
(DEFUN C:TEMP (/ oldlay line1)
(setq oldlay (getvar 'clayer)
line1 (car (entsel "\nPick first line: "))
); end setq
(setvar 'clayer (cdr (assoc 8 (entget line1))))
(command "_.fillet" line1 pause)
(command "-insert" "elbow" "s" (getvar 'dimscale) "end,int" pause pause)
(setvar 'clayer oldlay)
(princ)
)

edit: changed Subject line
« Last Edit: November 03, 2007, 07:40:30 AM by Mark Thomas »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: just can't get it to work correctly!
« Reply #1 on: November 01, 2007, 04:24:47 PM »
Jermjmm.
Can you post a drawing with the before & after example in it?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: just can't get it to work correctly!
« Reply #2 on: November 01, 2007, 04:28:49 PM »
When you use the fillet command you should include the picked point like this:
Code: [Select]
(setq line1  (entsel "\nPick first line: "))
(setq line2  (entsel "\nPick second line: "))
(and line1 line2 (command "_.fillet" line1 line2))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: just can't get it to work correctly!
« Reply #3 on: November 01, 2007, 04:40:56 PM »
Code: [Select]
(DEFUN C:TEMP (/ oldlay line1)
  (setq oldlay (getvar 'clayer)
line1  (entsel "\nPick first line: ")
  )
  (setvar 'clayer (cdr (assoc 8 (entget (car line1)))))
  (command "_.fillet" (cadr line1) pause)
  (command "-insert"
   "elbow"
   "s"
   (getvar 'dimscale)
   "end,int"
   pause
   pause
  )
  (setvar 'clayer oldlay)
  (princ)
)

jermjmm

  • Guest
Re: just can't get it to work correctly!
« Reply #4 on: November 01, 2007, 04:42:21 PM »
here is a pic of what it does

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: just can't get it to work correctly!
« Reply #5 on: November 01, 2007, 04:45:31 PM »
When you use the fillet command you should include the picked point like this:
Code: [Select]
(setq line1  (entsel "\nPick first line: "))
(setq line2  (entsel "\nPick second line: "))
(and line1 line2 (command "_.fillet" line1 line2))
we should pass (cadr line1) and (cadr line2), fillet doesn't like the (entsel)

jermjmm

  • Guest
Re: just can't get it to work correctly!
« Reply #6 on: November 01, 2007, 04:48:08 PM »
aahhhh, verry interesting.  thanks! works good now. 
One final question, is fillet the best way to do it or would modifing the endpoints be a better way?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: just can't get it to work correctly!
« Reply #7 on: November 01, 2007, 04:55:05 PM »
When you use the fillet command you should include the picked point like this:
Code: [Select]
(setq line1  (entsel "\nPick first line: "))
(setq line2  (entsel "\nPick second line: "))
(and line1 line2 (command "_.fillet" line1 line2))
we should pass (cadr line1) and (cadr line2), fillet doesn't like the (entsel)

Are you sure about that? :evil:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: just can't get it to work correctly!
« Reply #8 on: November 01, 2007, 04:56:22 PM »
When you use the fillet command you should include the picked point like this:
Code: [Select]
(setq line1  (entsel "\nPick first line: "))
(setq line2  (entsel "\nPick second line: "))
(and line1 line2 (command "_.fillet" line1 line2))
we should pass (cadr line1) and (cadr line2), fillet doesn't like the (entsel)

Are you sure about that? :evil:
the autocad help is on my side sir :)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: just can't get it to work correctly!
« Reply #9 on: November 01, 2007, 04:58:40 PM »

I'll make a deal,
change the avatar and I'll give you the answer.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Maverick®

  • Seagull
  • Posts: 14778
Re: just can't get it to work correctly!
« Reply #10 on: November 01, 2007, 05:07:33 PM »

I'll make a deal,
change the avatar and I'll give you the answer.

 :-D

jermjmm

  • Guest
Re: just can't get it to work correctly!
« Reply #11 on: November 01, 2007, 05:16:53 PM »
is that avatar better? but with the help of everybody here (and a friend in my office) i've rewrote it already and it works great:
Code: [Select]
(DEFUN C:fe (/ oldlay line1)
(setq oldlay (getvar 'clayer)
line1 (entsel "\nPick first line: ")
); end setq
(setvar 'clayer (cdr (assoc 8 (entget (car line1)))))
(command "_.fillet" line1 pause)
(command "-insert" "elbow" "s" (getvar 'dimscale) "end,int" pause)
(setvar 'clayer oldlay)
(princ)
)
« Last Edit: November 01, 2007, 05:57:24 PM by Maverick® »

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: just can't get it to work correctly!
« Reply #12 on: November 01, 2007, 05:39:33 PM »
it does not work with your "cross" example on my autocad 2004 :(

jermjmm

  • Guest
Re: just can't get it to work correctly!
« Reply #13 on: November 01, 2007, 05:50:50 PM »
don't know if acad versions make a dif (I'm using 2008) it works on mine.

anybody want to give lessons on how to extract endpoints from a line and use them for the insertion of a block?  I know assoc 10 and 11 are the starting point and ending point but how would you determine which one is which?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: just can't get it to work correctly!
« Reply #14 on: November 01, 2007, 05:56:10 PM »
don't know if acad versions make a dif (I'm using 2008) it works on mine.

anybody want to give lessons on how to extract endpoints from a line and use them for the insertion of a block?  I know assoc 10 and 11 are the starting point and ending point but how would you determine which one is which?
You can use the 'osnap' function of Lisp, or you could check the distance from the two points to the select point (the one returned by 'entsel').
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.