Jump to content

Recommended Posts

Posted

hello everyone ...

i have a base reference polyline "the white one" and i want to draw another polyline along its path between two points p1 and p2 "the green one"

...

any suggestions ...

thanks in advance

2017-06-05_23h02_36.jpg

Posted

How should the program determine the length of the horizontal segments?

Posted
How should the program determine the length of the horizontal segments?

 

the two points are selected by user manually ...

Posted
the two points are selected by user manually ...

 

Yes, but how should the program determine the lengths of the two green horizontal segments? The position of the vertical segment appears to be arbitrary.

Posted
Yes, but how should the program determine the lengths of the two green horizontal segments? The position of the vertical segment appears to be arbitrary.

sorry i don't understand what you mean exactly ... but i can explain the procedure as follow ...

 

the user will select a multi-vertex polyline

 

and then prompted to select two points on this polyline

 

the program should loop through the polyline verticies list and make a new list of verticies points which lies between the two selected points

 

at last after this new list established it can be drawn as a polyline...

 

.... there is a lisp made by curmudgeon

this lisp draw a polyline between the intersection of two "lines" with the base polyline

 

but it shows an error when the selection of two lines reversed

 

(defun c:break_pline ( / plne l1 l2 pt_lst it nu_pt_lst nu_pline nu )
;;;get the polyline and line 1 and line 2
(setq plne (entget (car (entsel "\n Pick your Polyline :")))
     l1 (entget (car (entsel "\n Pick your first line to trim from :")))
     l2 (entget (car (entsel "\n Pick your other line to trim from :")))
     )
;;;create a list of vertexes
 (foreach a plne
   (if    (= (car a) 10)
     (setq pt_lst (append pt_lst (list (cdr a))))
   )
 )

;;; remove points from list "before" first intersection
(while (not (setq it (inters (list (car (nth 0 pt_lst))(cadr (nth 0 pt_lst)) 0.0 )
           (list (car (nth 1 pt_lst))(cadr (nth 1 pt_lst)) 0.0 )
           (cdr (assoc 10 l1))(cdr (assoc 11 l1))
           )
         )
       )
 (setq pt_lst (cdr pt_lst))
 )

(setq pt_lst (subst (list (car it)(cadr it))(car pt_lst) pt_lst) )

;;; only save points coming "before" second intersection
;;;(setq nu_pt_lst (list (car pt_lst)))

(while (not (setq it (inters (list (car (nth 0 pt_lst)) (cadr (nth 0 pt_lst)) 0.0)
             (list (car (nth 1 pt_lst)) (cadr (nth 1 pt_lst)) 0.0)
             (cdr (assoc 10 l2))
             (cdr (assoc 11 l2))
         )
    )
      )
 (setq    nu_pt_lst (append nu_pt_lst (list (car pt_lst)))
   pt_lst      (cdr pt_lst)
 )
)

(setq nu (append nu_pt_lst (list (car pt_lst)) (list (list (car it)(cadr it)))))

;;;remove old polyline
(entdel (cdr (assoc -1 plne)))

;;;create new polyline
(foreach a nu
 (setq nu_pline (append nu_pline (list (cons 10 a))))
 )
 (entmake (append (list '(0 . "LWPOLYLINE")
            '(100 . "AcDbEntity")
            (assoc 8 plne)
            '(100 . "AcDbPolyline")
            (cons 90 (- (length nu) 1))
            (assoc 70 plne)
          )
          nu_pline
      )
 )
)

Posted (edited)
If I've understood correctly, comment or remove lines 25-32 & 131-133 in this program.

 

yes ... this worked like a charm ...

thanks for your patience and your helpful assistance Mr. Lee

 

... one last question please ...

how can the user alerted with the length of the newly created polyline ?

Edited by handasa
Posted
yes ... this worked like a charm ...

thanks for your patience and your helpful assistance Mr. Lee

 

Excellent - you're welcome.

 

... one last question please ...

how can the user alerted with the length of the newly created polyline ?

 

Simply select the newly created polyline and view the length in the Properties Palette.

Posted
Excellent - you're welcome.

 

 

 

Simply select the newly created polyline and view the length in the Properties Palette.

 

this lisp is a part of a large program that the length of the created polyline must be obtained during the processing of the program ...

anyway ... so far so good ... iam very grateful to you and thanks again

Posted

Add thes two line just after making pline,

 

(setq len (vla-get-length (vlax-ename->vla-object (entlast))))
(alert (strcat "Length of new line is " (rtos len 2 3))) 

Posted
Add thes two line just after making pline,

 

(setq len (vla-get-length (vlax-ename->vla-object (entlast))))
(alert (strcat "Length of new line is " (rtos len 2 3))) 

 

thanks Mr.Bigal ... this worked for me ... brilliant :)

  • 3 years later...
Posted

Hello and good day!

 

Can this be applied to multiple polylines? The user inputs would be as follows:

1. Pick 1st point

2. Pick 2nd point

3. Select polylines

 

Please see attached photo. 

 

image.thumb.png.11b31b09227f8b86c9558a1762df1d9d.png

Posted

I dont know how many of these you do but setting osnap to near and intersection then just do PLINE pick the points in order all done. Lots of coding time for a simple manual method. It took me longer to draw all the test lines than to do pline.

 

Osmode 544 then PLINE

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...