lsp: Break/cut a line

Discussion in 'AutoCAD' started by MS, Sep 16, 2004.

  1. MS

    MS Guest

    Hello.

    I need a command/lsp.

    I have a line(A-A) and want to break/cut the line at the point(x) where I
    "click" on it.
    At that point I want to "cut away" a part of the line ( 10mm of bouth side
    of the point).

    A----------------------x---------------------A


    After the "click":

    A-------------A 20mm A---------------A



    Can you help me?


    Br
    Morten S
     
    MS, Sep 16, 2004
    #1
  2. MS

    R.K. McSwain Guest


    Something like this should get you started.
    (Note there is no error checking and it only works in WCS)

    (defun c:break20 ()
    (setq ent (entsel))
    (setq pt1 (cadr ent))
    (setq obj (entget (car ent)))
    (setq ang (angle (cdr (assoc 10 obj)) (cdr (assoc 11 obj))))
    (setq pt2 (polar pt1 ang 10.0))
    (setq pt3 (polar pt1 ang -10.0))
    (command "._break" ent "_F" pt2 pt3)
    (princ)
    )
     
    R.K. McSwain, Sep 16, 2004
    #2
  3. MS

    mattis Guest

    Here you go! It only works on lines.

    (defun c:lbreak (/ cmd ent entinfo stpt endpt1 endpt2 lang newpt1 newpt2)
    (setq cmd (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq ent (nentsel))
    (if ent
    (progn
    (setq entinfo (entget (car ent)))
    (if (not (= (cdr (assoc 0 entinfo)) "LINE"))
    (princ "\nA line must be selected.\n")
    (progn
    (setq stpt (cadr ent))
    (setq endpt1 (cdr (assoc 10 entinfo)))
    (setq endpt2 (cdr (assoc 11 entinfo)))
    (setq lang (angle endpt1 endpt2))
    (setq newpt1 (polar stpt lang (/ 100.0 254.0)))
    (setq newpt2 (polar stpt (- lang pi) (/ 100.0 254.0)))
    (command "break" newpt1 newpt2 nil)
    )
    )
    )
    )
    (setvar "cmdecho" cmd)
    (princ)
    )
     
    mattis, Sep 16, 2004
    #3
  4. MS

    MS Guest

    Exactly what I needed.! Thank you for your quick respond!

    If I want a bigger gap/cut, is it just to add a bigger value at "polar pt1
    ang xx" and "polar pt2 ang -xx" ?

    MS


    Something like this should get you started.
    (Note there is no error checking and it only works in WCS)

    (defun c:break20 ()
    (setq ent (entsel))
    (setq pt1 (cadr ent))
    (setq obj (entget (car ent)))
    (setq ang (angle (cdr (assoc 10 obj)) (cdr (assoc 11 obj))))
    (setq pt2 (polar pt1 ang 10.0))
    (setq pt3 (polar pt1 ang -10.0))
    (command "._break" ent "_F" pt2 pt3)
    (princ)
    )
     
    MS, Sep 16, 2004
    #4
  5. MS

    MS Guest

    Nice, can cut pline!

    Thank you!

    MS
     
    MS, Sep 16, 2004
    #5
  6. Morten,

    Here are two much simpler versions that work on lines, arcs, polylines (even
    around corners!), splines, xlines, rays, etc, and do not require saving any
    variables, local or global or cosmic or anything!

    Just break the object at the selected point (using the same point twice),
    and use Lengthen with a DElta value of -10, again picking the same point
    twice to shorten each broken piece (it doesn't matter which one it shortens
    first; the other one will then be the only one there to shorten for the
    second try).

    Tablet/Screen/Toolbar macro (automatically repeating for as many as you want
    to pick):

    [Break 20mm]*^C^CBREAK \@ LENGTHEN DE -10 @ @ ;

    Lisp:

    (command "break" (getpoint "Select item to break: ")
    (getvar "LASTPOINT")
    "lengthen" "de" "-10"
    (getvar "LASTPOINT")
    (getvar "LASTPOINT") ""
    )

    It wouldn't work on a circle because you can't break a circle at a single
    point. You'd want to calculate two break points as in other people's
    routines, finding a direction for them by going perpendicular to the
    direction from the pick point to the center of the circle. That would be
    not quite precisely a 10mm shortening along the curve, if exactness is
    important to you, but that could also be done with some arc-length and angle
    calculation. And it doesn't work on a trace (it does break it, but you
    can't use lengthen on a trace).

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 16, 2004
    #6
  7. They also don't work on a closed ellipse for the same reason they don't work
    on a circle (but neither would other people's routines that use Break).
    [They WOULD work on earlier-ACAD ellipses that were polyline
    approximations.] They (and others' routines) don't work on Mlines either,
    because you can't use break on them. They DO work on a "circle" if it's
    really a Donut.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 16, 2004
    #7
  8. Ooops... My mistake -- those that use break with two different calculated
    points WOULD work on circles and closed ellipses.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 16, 2004
    #8
  9. MS

    Jürg Menzi Guest

    You're welcome...¦-)

    Cheers
     
    Jürg Menzi, Sep 16, 2004
    #9
  10. Another approach that, like my single-point-break and negative-lengthen
    suggestion, doesn't require saving ANY variables or entity names or
    association lists, calculating any angles, figuring out what kind of entity
    you're cutting so you know where to look for information to calculate angles
    from, or any of those complications:

    Draw a circle with a 10mm radius with (x) as its center, then call up trim
    and select the circle (last) as the cutting edge, and pick at (x) again to
    trim out the object you want a gap in. Then erase the circle.

    That would work on absolutely any trimmable entity, including the circles
    and closed ellipses that my other one wouldn't.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 17, 2004
    #10
  11. [Break20mm]*^C^CCIRCLE (prompt "Select item to cut: ") \10 TRIM L ;@ ERASE P
    ;

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 17, 2004
    #11
  12. Missed a ";" after the "@ " --

    [Break20mm]*^C^CCIRCLE (prompt "Select item to cut: ") \10 TRIM L ;@ ;ERASE
    P ;

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 17, 2004
    #12
  13. MS

    MS Guest

    Thanks for your help!

    MS


     
    MS, Sep 20, 2004
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.