mstg007 发表于 2017-7-12 08:55:38

identify parallel lines

Any way to identify from a selection of lines or polylines which ones are parallel to the one you select? I really do not feel like redrawing something if I already know which ones are ok. Thanks for the help!

CAB 发表于 2017-7-12 09:09:13

Lots of info on this site.
http://www.theswamp.org/index.php?topic=23170.msg281630#msg281630

mstg007 发表于 2017-7-12 09:10:40

Thanks CAB, ill check it out.

dgorsman 发表于 2017-7-17 16:40:37

If the lines are reduced to unit vectors they should be directly comparable (with a bit of fuzz).

mstg007 发表于 2017-7-17 17:00:18

I kind of had to redraw it. But this is what I was looking at. We received an site plan from the architect. I wanted to make sure that the parking stalls were parallel with the building. So by selecting a line it would then high light all the lines that are parallel with it.

mstg007 发表于 2017-8-14 12:59:45

hate to do this... I still cannot figure this out. I looked through the link CAB provided. I thought I could get it figured out.   Apparently not.

Atook 发表于 2017-8-14 13:10:58

Basic approach will be to pick a line and get its slope, call it m.
Then select all lines/polylines in the drawing and iterate through them. You'll probably want to filter out for polylines that only have 2 vertices.
check the slope of each line, call it m2
if((m2.isclose(m)) or (m2.isclose(m+PI))) then the line/polyline is parallel if it's parallel, highlight it.
You can also find the slope of a line by getting the (change in Y)/(change in X) between the endpoints.
Edit: You'll also need to check for a vertical line, which has an undefined slope (change in x = 0).
Not sure what language you're hoping to work in, but that's the basic idea. I've no idea how to do this without code.

ronjonp 发表于 2017-8-14 15:12:31

Here's a quick one ..
(defun c:foo (/ _foo e i s)
(defun _foo (e) (rem (angle (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e)) pi))
(if (and (setq e (car (entsel "\nPick line to set angle: ")))
         (wcmatch (cdr (assoc 0 (entget e))) "LINE,*POLYLINE")
         (setq i (_foo e))
         (setq s (ssget "_X"
                        '((-4 . "
                            (0 . "line")
                            (-4 . "
                            (0 . "*polyline")
                            (90 . 2)
                            (-4 . "AND>")
                            (-4 . "OR>")
                           )
                   )
         )
      )
    (progn (foreach pl (mapcar 'cadr (ssnamex s))
             (if (not (equal (_foo pl) i 1e-3))
               (ssdel pl s)
             )
         )
         (sssetfirst nil s)
    )
)
(princ)
)

mstg007 发表于 2017-8-14 15:37:25

saving the day once again! I didn't even think slope. Thank you

ronjonp 发表于 2017-8-14 16:02:06

Glad to help
页: [1] 2
查看完整版本: identify parallel lines