selecting 2 lines

Discussion in 'AutoCAD' started by Marcel Janmaat, Nov 25, 2004.

  1. Has anyone got a good suggestion for me on how to select two parrallel lines
    witch are on the same layer by giving a pont between them. It might be that
    other line interfere.

    M
     
    Marcel Janmaat, Nov 25, 2004
    #1
  2. No reply yet on this one.
    I'm looking for somthing like bpoly, but then it only has to select the two
    parrallel lines.
     
    Marcel Janmaat, Dec 7, 2004
    #2
  3. Marcel Janmaat

    Paul Turvill Guest

    Two clicks will do it ...

    Your original question is pretty vague. How would the point be selected? If
    it's a mouse pick, then it would be fairly straightforward to just pick one
    of the lines, and then come up with logic to search in either direction for
    the nearest parallel line. But, really, it is really a lot simpler to just
    have the user pick *both* lines at the outset.
    ___
     
    Paul Turvill, Dec 7, 2004
    #3
  4. Yes I know.
    You can call me fool :) but I still would like to be able to do it by
    picking a boint inbetween them.
    I think it makes my command a lot cooler/smoother what ever.
    _________________
     
    Marcel Janmaat, Dec 7, 2004
    #4
  5. Marcel Janmaat

    David Kozina Guest

    Group a Point with an MLine? (Maybe 2-points - one at each end - if MLine
    is not closed)

    Use an MLine and forget about the point? Once selected, if zero justified
    and defined sanely, you have grips at the vertices where the 'point' would
    be.

    Group a 3-element MLine (on Defpoints) with a 2-element Standard-like MLine?
    (use equal spaced members located +1/2, 0, -1/2 for the 3-element
    MLinestyle).

    Just some ideas for you to consider.

    hth,
    David Kozina
     
    David Kozina, Dec 8, 2004
    #5
  6. All these well ment ideas are not what i'm looking for.
    I just want to select two parrallel lines by pointing between them.
    No more no less.

    Thanx anyway!
     
    Marcel Janmaat, Dec 8, 2004
    #6
  7. Marcel Janmaat

    CAB2k Guest

    Try this.
    (defun c:pp (/ dist p p1 p2 p3 p4 ss idx entlst pair)

    (setq dist 20) ; get lines within 20 units of pick point
    (if (and
    (setq p (getpoint "\Pick point between."))
    (setq p1 (polar p 0.7854 dist)
    p2 (polar p 2.3562 dist)
    p3 (polar p 3.927 dist)
    p4 (polar p 5.4978 dist)
    )
    (setq ss (ssget "CP" (list p1 p2 p3 p4) '((0 . "LINE"))))
    (> (setq idx (sslength ss)) 1)
    )
    (progn
    (while (>= (setq idx (1- idx)) 0)
    (setq entlst (cons (entget (ssname ss idx)) entlst))
    ) ; while
    (foreach a entlst
    (foreach b entlst
    (cond
    ((= (car a) (car b))
    )
    ((parallel a b)
    (setq pair (list (cdr (car a)) (cdr (car b))))
    )
    )
    )
    )
    )
    ) ; endif
    pair
    )
    (defun parallel (a b / ang1 ang2)
    (setq ang1 (angle (cdr (assoc 10 a)) (cdr (assoc 11 a))))
    (setq ang2 (angle (cdr (assoc 10 b)) (cdr (assoc 11 b))))
    (if (or
    (equal ang1 ang2 0.001)
    ;; Check for lines drawn in opposite directions
    (equal ang1 (- ang2 pi) 0.001)
    (equal ang1 (+ ang2 pi) 0.001)
    (equal (+ ang1 pi) ang2 0.001)
    (equal (- ang1 pi) ang2 0.001)
    )
    t
    )
    )
     
    CAB2k, Dec 10, 2004
    #7
  8. hanx for the input, but sorry, nothing happens.

    Here the result.

    Command:
    Command: pp
    Pick point between.nil

    Command:

    M
     
    Marcel Janmaat, Dec 10, 2004
    #8
  9. Marcel Janmaat

    CAB2k Guest

    Ok, I added some print statements to tell weather you are selecting LINE objects or not
    and to tell you that parallel lines were found.
    Remember the lines may not be farther apart than 20 units.
    Also the objects must be LINES not polylines.
    If you need a greater working distance adjust the number 20 on line 4.


    (defun c:pp (/ dist p p1 p2 p3 p4 ss idx entlst pair)
    (setq useros (getvar "osmode"))
    (setvar "osmode" 0)
    (setq dist 20) ; get lines within 20 units of pick point
    (if (and
    (setq p (getpoint "\Pick point between."))
    (setq p1 (polar p 0.7854 dist)
    p2 (polar p 2.3562 dist)
    p3 (polar p 3.927 dist)
    p4 (polar p 5.4978 dist)
    )
    (setq ss (ssget "CP" (list p1 p2 p3 p4) '((0 . "LINE"))))
    (> (setq idx (sslength ss)) 1)
    )
    (progn
    ;; debug - print # of items selected
    (print idx)
    (princ " LINE objects selected.")
    ;; end debug

    (while (>= (setq idx (1- idx)) 0)
    (setq entlst (cons (entget (ssname ss idx)) entlst))
    ) ; while
    (foreach a entlst
    (foreach b entlst
    (cond
    ((= (car a) (car b))
    )
    ((parallel a b)
    (setq pair (list (cdr (car a)) (cdr (car b))))
    )
    )
    )
    )
    )
    ) ; endif
    (setvar "osmode" useros)
    ;; debug - display results
    (if pair
    (print "*** Two lines found parallel.")
    (print " *** No Parallel lines found.")
    )
    ;; end debug
    pair
    )


    (defun parallel (a b / ang1 ang2)
    (setq ang1 (angle (cdr (assoc 10 a)) (cdr (assoc 11 a))))
    (setq ang2 (angle (cdr (assoc 10 b)) (cdr (assoc 11 b))))
    (if (or
    (equal ang1 ang2 0.001)
    ;; Check for lines drawn in opposite directions
    (equal ang1 (- ang2 pi) 0.001)
    (equal ang1 (+ ang2 pi) 0.001)
    (equal (+ ang1 pi) ang2 0.001)
    (equal (- ang1 pi) ang2 0.001)
    )
    t
    )
    )
     
    CAB2k, Dec 10, 2004
    #9
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.