Vertical lines between two poly line points

Vertical lines between two poly line points

ayadmustafa
Participant Participant
1,737 Views
5 Replies
Message 1 of 6

Vertical lines between two poly line points

ayadmustafa
Participant
Participant

hi there

I have two poly-lines red and black drawn  one above the other and I want to draw vertical lines (green) from points of the first poly-line which ends when it intersect with poly-line above...pls

0 Likes
Accepted solutions (1)
1,738 Views
5 Replies
Replies (5)
Message 2 of 6

devitg
Advisor
Advisor

Please upload a sample.dwg .

 

0 Likes
Message 3 of 6

dlanorh
Advisor
Advisor
Accepted solution

Try this

 

(defun c:vline (/ *error* c_doc ms e_obj f_obj ent ans cnt e_p s_pt e_pt x_obj i_pt)

  (defun *error* ( msg )
    (mapcar 'setvar sv_lst sv_vals)
    (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
    (princ)
  );_end_*error*_defun
  
  (setq sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
        c_doc (vla-get-activedocument (vlax-get-acad-object))
        ms (vla-get-modelspace c_doc)
        e_obj (vlax-ename->vla-object (car (entsel "\nSelect Extents Polyline : ")))
        f_obj (vlax-ename->vla-object (setq ent (car (entsel "\nSelect From Polyline : "))))
  );end_setq
  
  (initget "All Select")
  (setq ans (cond ( (getkword "\nLine from All Vertices of Polyline or Selected Points [All/Select] <All> : ")) ("All")))
  
  (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
  (vla-startundomark c_doc)
  
  (cond ( (= ans "All")
          (setq cnt 1.0
                e_p (vlax-curve-getendparam ent)
          );end_setq
          (while (< 0.0 cnt e_p)
            (setq s_pt (vlax-curve-getpointatparam ent cnt)
                  e_pt (mapcar '+ s_pt (list 0.0 1.0 0.0))
                  x_obj (vla-addray ms (vlax-3D-point s_pt) (vlax-3D-point e_pt))
                  i_pt (vlax-invoke x_obj 'intersectwith e_obj acextendnone)
                  cnt (1+ cnt)
            );end_setq
            (cond (i_pt (setq l_obj (vla-addline ms (vlax-3d-point s_pt) (vlax-3d-point i_pt)))))
            (vla-delete x_obj)
          );end_while
        )
        (t 
          (mapcar 'setvar sv_lst (list 0 545))
          (while (setq s_pt (getpoint "\nSelect Line Start Point : "))
            (cond ( (not (equal 0.0 (distance s_pt (vlax-curve-getclosestpointto ent s_pt)) 0.001))
                    (setq e_pt (mapcar '+ s_pt (list 0.0 -1.0 0.0))
                          x_obj (vla-addray ms (vlax-3D-point s_pt) (vlax-3D-point e_pt))
                          i_pt (vlax-invoke x_obj 'intersectwith f_obj acextendnone)
                    );end_setq
                  )
                  (t 
                    (setq e_pt (mapcar '+ s_pt (list 0.0 1.0 0.0))
                          x_obj (vla-addray ms (vlax-3D-point s_pt) (vlax-3D-point e_pt))
                          i_pt (vlax-invoke x_obj 'intersectwith e_obj acextendnone)
                    );end_setq
                  )
            );end_cond
            (cond (i_pt (setq l_obj (vla-addline ms (vlax-3d-point s_pt) (vlax-3d-point i_pt)))))
            (vla-delete x_obj)
          );end_while
        )
  );end_cond
  
  (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
  (mapcar 'setvar sv_lst sv_vals)
);end_defun  
  

You are asked to select the extend To polyline and the extend from polyline, then are asked if you want to generate lines from all vertices of the from polyine or selected points.

 

If you select "all" it will generate line from all vertices except the start and end points as these are assume to meet the extend "To" polyline.

 

If you select "select" you are asked to select points in a loop. "osmode is set to 545 so you can select "End" "Intersection" or "Nearest", and your points can be on the "From" polyline or the "To" polyline.

 

The generated lines will be in the current layer.

 

To exit the "select" while loop press enter or right click if your mouse is set up that way.

I am not one of the robots you're looking for

Message 4 of 6

ayadmustafa
Participant
Participant

I have tried your routine ....but selecting two poly lines every time is too hard ... can you change that to something like clicking inside the area between the two poly lines ?

0 Likes
Message 5 of 6

dlanorh
Advisor
Advisor

Without additional information e.g. which lines are on which layers, how can the lisp decide which polyline is which if it only finds two polylines?

 

Given your image above it is almost certain that it will find a minimum of three.

I am not one of the robots you're looking for

0 Likes
Message 6 of 6

devitg
Advisor
Advisor

Maybe , and only maybe. If you would  upload a sample.dwg , not an image , some one could solve the way you whish. 

0 Likes