Author Topic: Chamfer - pick less do more question  (Read 2277 times)

0 Members and 1 Guest are viewing this topic.

jermjmm

  • Guest
Chamfer - pick less do more question
« on: October 04, 2007, 10:22:28 AM »
I have this lisp of 2 combined ones.  what I'm trying to do is figure out how to not have to pick the line the second time or the break point.  Any ideas of where to start.  I've been fiddling with it for a couple days now and nothing has worked.

Code: [Select]
(defun c:sy2 (/ ln bkpt)
   (setq om (getvar "osmode"))
   (setvar "cmdecho" 0)
   (setq pick1 (entsel "\nPick first line (to remain): "))
   (setq ent1 (car pick1))
   (redraw ent1 3)
   (setvar "chamfera" (* 0.0833 (getvar "dimscale")))
   (setvar "chamferb" (* 0.0833 (getvar "dimscale")))
   (setq pick2 (entsel "\nPick second line: "))
   (setq ent2 (car pick2))
   (redraw ent2 3)
   (command "_copy" pick1 "" '(0 0 0) "")
   (command "._chamfer" pick1 pick2)
   (entdel ent1)

   (setvar "osmode" 32)
   (setq ln (entsel "\nChoose Line to Break..."))
   (setq bkpt (getpoint "\nPick Break Point.. "))
   (command "break" ln "f" bkpt "@")
   (setvar "osmode" om)
   (setvar "cmdecho" 1)
   )
   (princ)
)
thanks for your help!

<edit: code tags added>
« Last Edit: October 04, 2007, 11:05:05 AM by CAB »

ronjonp

  • Needs a day job
  • Posts: 7533
Re: pick less do more question
« Reply #1 on: October 04, 2007, 10:40:30 AM »
Perhaps a picture with the end result would help....

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jermjmm

  • Guest
Re: pick less do more question
« Reply #2 on: October 04, 2007, 10:43:51 AM »
Here is a pic.  the horizontal line in the final pic is broken (2 lines) where the 45 line connects in.
. . . . hmmm, this sounds familar, if I've posted this somewhere else in the swamp sorry, couldn't find it this morning when I was looking.

Guest

  • Guest
Re: pick less do more question
« Reply #3 on: October 04, 2007, 10:45:38 AM »
Maybe this will help with what you're trying to do...

Code: [Select]
(defun C:BAP ( / lista objEnt)
   (princ "\n BREAK object at point... ")
   (setq objEnt (entsel))
   (while objEnt
      (command ".break" objEnt "F" "none" (cadr objEnt) "none" (cadr objEnt))
      (setq objEnt (entsel))
   )
   (princ)
)

...and do a search for a thread called "Enhanced Fillet".   :-)

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: pick less do more question
« Reply #4 on: October 04, 2007, 10:54:19 AM »
or this:
Code: [Select]
(defun c:sy2 (/ ln bkpt ELIST1 ELIST2 ENDPT ENT1 ENT2 OM PICK1 PICK2 STPT)
   (setq om (getvar "osmode"))
   (setvar "cmdecho" 0)
   (setq pick1 (entsel "\nPick first line (to remain): "))
   (setq ent1 (car pick1))
  (setq stPt (cdr (assoc 10 (setq elist1 (entget ent1))))
endPt (cdr (assoc 11 elist1))
)
   (redraw ent1 3)
   (setvar "chamfera" (* 0.0833 (getvar "dimscale")))
   (setvar "chamferb" (* 0.0833 (getvar "dimscale")))
   (setq pick2 (entsel "\nPick second line: "))
   (setq ent2 (car pick2))
   (redraw ent2 3)
   ;(command "_copy" pick1 "" '(0 0 0) "")
   (command "._chamfer" pick1 pick2)
  (setq elist2 (entget ent1))
  (if (equal stpt (cdr (assoc 10 elist2)) 0.0001)
      (entmake (subst (cons 10 (cdr (assoc 11 elist2))) (assoc 10 elist1) elist1))
      (entmake (subst (cons 11 (cdr (assoc 10 elist1))) (assoc 11 elist2) elist2))
    )
 
   ;(entdel ent1)

   ;(setvar "osmode" 32)
   ;(setq ln (entsel "\nChoose Line to Break..."))
   ;(setq bkpt (getpoint "\nPick Break Point.. "))
   ;(command "break" ln "f" bkpt "@")
   (setvar "osmode" om)
   (setvar "cmdecho" 1)
   
   (princ)
)

jermjmm

  • Guest
Re: pick less do more question
« Reply #5 on: October 04, 2007, 10:59:38 AM »
wow! that was quick.  thanks it worked great!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Chamfer - pick less do more question
« Reply #6 on: October 04, 2007, 11:06:42 AM »
« Last Edit: October 04, 2007, 11:08:22 AM by CAB »
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.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Chamfer - pick less do more question
« Reply #7 on: October 04, 2007, 01:03:18 PM »
A little late to the party.... but this will chamfer all lines crossing a selected picked line  :-):



Have fun.

Code: [Select]
(defun c:mcham
       (/ e e2 e2_ep e2_sp ent e_ep e_sp int lst m p1 p2 ppt ss x)
  (setq ent (entsel "\n Pick line to keep: ")
m   (* 0.0833 (getvar 'dimscale))
  )
  (if (and ent
   (= (cdr (assoc 0 (entget (car ent)))) "LINE")
      )
    (progn
      (setq e (car ent)
    ppt (cadr ent)
    e_sp (cdr (assoc 10 (entget e)))
    e_ep (cdr (assoc 11 (entget e)))
      )
      (setq ss (ssget "_f" (list e_sp e_ep)))
      (if ss
(progn
  (mapcar
    '(lambda (x)
       (if (and (not (equal x e))
(equal (cdr (assoc 0 (entget x))) "LINE")
   )
(setq lst (cons x lst))
       )
     )
    (mapcar 'cadr (ssnamex ss))
  )
  (if lst
    (progn
      (mapcar
'(lambda (x)
   (setq e2    (entget x)
e2_sp (cdr (assoc 10 e2))
e2_ep (cdr (assoc 11 e2))
int   (inters e_sp e_ep e2_sp e2_ep)
p1    (polar int (angle e_sp e_ep) m)
p2    (polar int (angle e2_sp e2_ep) m)
   )
   (if (> (distance p1 ppt)
  (distance ppt int)
       )
     (setq p1 (polar int (angle e_ep e_sp) m))
   )
   (entmake
     (list
       '(0 . "LINE")
       (cons 8 (cdr (assoc 8 e2)))
       (cons 10 p1)
       (cons 11 p2)
     )
   )
   (entmake
     (list
       '(0 . "LINE")
       (cons 8 (cdr (assoc 8 e2)))
       (cons 10 p2)
       (cons 11 e2_ep)
     )
   )
   (entdel x)
)
lst
      )
    )
  )
)
      )
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jermjmm

  • Guest
Re: Chamfer - pick less do more question
« Reply #8 on: October 04, 2007, 02:04:28 PM »
that's cool. give me a couple years I'll be able to write that stuff.