Author Topic: How to determine start point of a polyline?  (Read 8341 times)

0 Members and 1 Guest are viewing this topic.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: How to determine start point of a polyline?
« Reply #15 on: July 29, 2015, 03:06:35 PM »
Yes you can tell in properties which way is which....

Select the line/polyline

Properties

Vertex....it lights up with an X
Be your Best


Michael Farrell
http://primeservicesglobal.com/

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to determine start point of a polyline?
« Reply #16 on: July 29, 2015, 03:17:22 PM »
The example drawing posted is using lines ( the subject line of the thread is incorrect ).

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: How to determine start point of a polyline?
« Reply #17 on: July 29, 2015, 03:28:30 PM »
did not notice they were all lines...however a quick run of MPEDIT will turn them all into polylines fast enough
Be your Best


Michael Farrell
http://primeservicesglobal.com/

yarnstormer

  • Guest
Re: How to determine start point of a polyline?
« Reply #18 on: July 30, 2015, 08:44:38 AM »
Yes you can tell in properties which way is which....

Select the line/polyline

Properties

Vertex....it lights up with an X


What!!! Clearly I asked the wrong question in the first place.
That is what I needed to know. I'll convert them all to polylines.

Sorry about the polyline in thread title - I assumed they were. I never draw "lines" and didn't even notice they weren't polylines until after I started the thread. Again...inherited drawing full of surprises

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How to determine start point of a polyline?
« Reply #19 on: July 30, 2015, 09:29:10 AM »
I'm editing a large file that I did not begin that contains a number of lines to indicate sewer lines. I edit the beginning and end Z coordinates to properly elevate the line and use a custom "above w slope" label to label the distance, pipe size and slope.
Double check the polyline will allow you to do what you want. I'm thinking it won't though.
TheSwamp.org  (serving the CAD community since 2003)

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: How to determine start point of a polyline?
« Reply #20 on: July 30, 2015, 09:35:20 AM »
right they would want to be 3d polylines....

however a quick trip through the revolving door and they can become 3d polylines....


Create FEATURE
Lines from Objects>>>Select objects
They become Feature lines

Use Quick Editor to assign elevations

EXPLODE them

They become 3d polylines @ correct elevations and slopes.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How to determine start point of a polyline?
« Reply #21 on: July 30, 2015, 09:59:11 AM »
Create FEATURE
Lines from Objects>>>Select objects
They become Feature lines

Use Quick Editor to assign elevations

EXPLODE them

They become 3d polylines @ correct elevations and slopes.
Cool. [LIKE]
TheSwamp.org  (serving the CAD community since 2003)

yarnstormer

  • Guest
Re: How to determine start point of a polyline?
« Reply #22 on: July 30, 2015, 10:15:25 AM »
right they would want to be 3d polylines....

however a quick trip through the revolving door and they can become 3d polylines....


Create FEATURE
Lines from Objects>>>Select objects
They become Feature lines

Use Quick Editor to assign elevations

EXPLODE them

They become 3d polylines @ correct elevations and slopes.

That is cool but I'm not editing the entire drawing just portions that I come across that are incorrect.
Converting to polylines seems to wipe out my label - not an option.

However I just discovered in the properties if you click in the box is the Z a red X pops up - click it and you get a line on your drawing to that point. I knew there had to be a way!
Thanks everyone for your responses.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to determine start point of a polyline?
« Reply #23 on: July 30, 2015, 10:32:49 AM »

If you want to send me the file, I could probably whip up some code to orient them correctly for you. Doing this by hand seems extremely tedious.

Interesting. How would you decide which/how to orient them? High end is the start? What would happen if some were not yet elevated? It is the process of elevating that is aggravating.

Could you write something that let me pick a line near one end, manually enter an elevation for that end, and would then request an elevation for the other end. If possible it might reverse the line by using the higher elevation as the new starting point.
I honestly don't care what direction they "think" they are going I just get aggravated that I can't tell in properties which end is which until I change the elevations.
Give this a try .. should speed up the process. Pick near an endpoint on a line to edit, if a coincident point is found at an elevation other than zero it will apply that elevation otherwise it prompts for an elevation.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:putelev (/ _getends _ss2l _vc c e o p p2 ss)
  2.   (defun _vc (center segments color / lst cnt)
  3.     (setq cnt 0)
  4.     (repeat segments
  5.       (setq lst (cons
  6.                   (trans (polar center (* cnt (/ (* pi 2) segments)) (* 0.01 (car (getvar 'screensize))))
  7.                          0
  8.                          1
  9.                   )
  10.                   lst
  11.                 )
  12.             cnt (1+ cnt)
  13.       )
  14.     )
  15.     (grvecs (cons color (append lst (cdr lst) (list (car lst)))))
  16.     (princ)
  17.   )
  18.   (defun _ss2l (ss / n out)
  19.     (if (= (type ss) 'pickset)
  20.       (repeat (setq n (sslength ss)) (setq out (cons (ssname ss (setq n (1- n))) out)))
  21.     )
  22.   )
  23.   (defun _getends (e /)
  24.     (vl-remove-if
  25.       '(lambda (p) (= 0.0 (last p)))
  26.     )
  27.   )
  28.   (if (and (setq ss (ssget "_A" '((0 . "line"))))
  29.            (setq e (entsel "\nPick a line near an end point to edit: "))
  30.            (= "LINE" (cdr (assoc 0 (entget (car e)))))
  31.            (setq p (cadr e))
  32.            (setq e (car e))
  33.            (setq o (vlax-ename->vla-object e))
  34.            (setq p (vlax-curve-getclosestpointto e p))
  35.            (setq p (cond ((< (vlax-curve-getparamatpoint e p) (/ (vlax-curve-getendparam e) 2.))
  36.                           (setq c 'startpoint)
  37.                           (vlax-curve-getstartpoint e)
  38.                          )
  39.                          (t (setq c 'endpoint) (vlax-curve-getendpoint e))
  40.                    )
  41.            )
  42.       )
  43.     (cond ;; Look for matching endpoint at an elevation other than zero
  44.           ((setq p2
  45.                   (car
  46.                     (vl-remove-if-not
  47.                       (function (lambda (x) (equal (list (car p) (cadr p)) (list (car x) (cadr x)) 0.01)))
  48.                       (apply 'append (mapcar '_getends (_ss2l (ssdel e ss))))
  49.                     )
  50.                   )
  51.            )
  52.            (vlax-put o c p2)
  53.            (_vc p  30 2)
  54.            (print (strcat "\nZ value " (vl-princ-to-string (last p2)) " found.."))
  55.           )
  56.           ;; Else prompt
  57.           ((setq p2 (getreal "\nEnter Z value: "))
  58.            (_vc p  30 2)
  59.            (vlax-put o c (list (car p) (cadr p) p2))
  60.           )
  61.     )
  62.   )
  63.   (princ)
  64. )


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: How to determine start point of a polyline?
« Reply #24 on: July 30, 2015, 11:01:41 AM »
Create FEATURE
Lines from Objects>>>Select objects
They become Feature lines

Use Quick Editor to assign elevations

EXPLODE them

They become 3d polylines @ correct elevations and slopes.
Cool. [LIKE]
It has other uses as well and thus even cooler than you now know
Be your Best


Michael Farrell
http://primeservicesglobal.com/

yarnstormer

  • Guest
Re: How to determine start point of a polyline?
« Reply #25 on: July 30, 2015, 11:13:06 AM »

Hey now that's great - also a good way to check the elevation in cases where it's not 0 but it's not correct either! Thank you so much! Only improvement I could suggest would be the opportunity to choose to default to the current elevation or change it rather than end the routine if the elev is other than 0

Explain coincident point please. Is that a point on the line in question or would a point on a line adjacent to it be included?

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to determine start point of a polyline?
« Reply #26 on: July 30, 2015, 12:00:30 PM »

Hey now that's great - also a good way to check the elevation in cases where it's not 0 but it's not correct either! Thank you so much! Only improvement I could suggest would be the opportunity to choose to default to the current elevation or change it rather than end the routine if the elev is other than 0

Explain coincident point please. Is that a point on the line in question or would a point on a line adjacent to it be included?


The routine looks at the end point being modified, then looks at all other endpoints of all lines in the drawing to see if one of those point is "equal".


Give this version a try:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:putelev (/ _getends _ss2l _vc c e o p p2 ss)
  2.   (defun _vc (center segments color / lst cnt)
  3.     (setq cnt 0)
  4.     (repeat segments
  5.       (setq lst (cons
  6.                   (trans (polar center (* cnt (/ (* pi 2) segments)) (* 0.01 (car (getvar 'screensize))))
  7.                          0
  8.                          1
  9.                   )
  10.                   lst
  11.                 )
  12.             cnt (1+ cnt)
  13.       )
  14.     )
  15.     (grvecs (cons color (append lst (cdr lst) (list (car lst)))))
  16.     (princ)
  17.   )
  18.   (defun _ss2l (ss / n out)
  19.     (if (= (type ss) 'pickset)
  20.       (repeat (setq n (sslength ss)) (setq out (cons (ssname ss (setq n (1- n))) out)))
  21.     )
  22.   )
  23.   (defun _getends (e /)
  24.     (vl-remove-if
  25.       '(lambda (p) (= 0.0 (last p)))
  26.     )
  27.   )
  28.   ;; Global to store elevation
  29.   (or *elev* (setq *elev* (getvar 'elevation)))
  30.   (if (and (setq ss (ssget "_A" '((0 . "line"))))
  31.            (setq e (entsel "\nPick a line near an end point to edit: "))
  32.            (= "LINE" (cdr (assoc 0 (entget (car e)))))
  33.            (setq p (cadr e))
  34.            (setq e (car e))
  35.            (setq o (vlax-ename->vla-object e))
  36.            (setq p (vlax-curve-getclosestpointto e p))
  37.            (setq p (cond ((< (vlax-curve-getparamatpoint e p) (/ (vlax-curve-getendparam e) 2.))
  38.                           (setq c 'startpoint)
  39.                           (vlax-curve-getstartpoint e)
  40.                          )
  41.                          (t (setq c 'endpoint) (vlax-curve-getendpoint e))
  42.                    )
  43.            )
  44.       )
  45.     (cond
  46.       ;; Look for matching endpoint at an elevation other than zero
  47.       ((setq p2
  48.               (car
  49.                 (vl-remove-if-not
  50.                   (function (lambda (x) (equal (list (car p) (cadr p)) (list (car x) (cadr x)) 0.01)))
  51.                   (apply 'append (mapcar '_getends (_ss2l (ssdel e ss))))
  52.                 )
  53.               )
  54.        )
  55.        (initget "YES NO")
  56.        (if
  57.          (= "YES"
  58.             (getkword
  59.               (strcat "\nUse Coincident Z value <" (vl-princ-to-string (last p2)) ">? [YES/NO]: ")
  60.             )
  61.          )
  62.           (setq *elev* (last p2))
  63.           (setq
  64.             *elev* (cond ((getreal (strcat "\nEnter Z value [" (vl-princ-to-string *elev*) "]: ")))
  65.                          (*elev*)
  66.                    )
  67.           )
  68.        )
  69.        (vlax-put o c (list (car p2) (cadr p2) *elev*))
  70.        (_vc p 30 2)
  71.       )
  72.       ;; Else prompt
  73.       ((setq
  74.          *elev* (cond ((getreal (strcat "\nEnter Z value [" (vl-princ-to-string *elev*) "]: ")))
  75.                       (*elev*)
  76.                 )
  77.        )
  78.        (_vc p 30 2)
  79.        (vlax-put o c (list (car p) (cadr p) *elev*))
  80.       )
  81.     )
  82.   )
  83.   (princ)
  84. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

yarnstormer

  • Guest
Re: How to determine start point of a polyline?
« Reply #27 on: July 30, 2015, 12:17:40 PM »
Ah problem is that there may be as many as 4 lines converging all with different elevations due to different pipe inverts. So, the line needs to only reference itself - display the current elevation at that end, let me default and move on to other end and enter or default as necessary.

It might be good if it did as you have written and picked up on the adjacent invert but still let me override if the actual invert is different.

Is that possible? I really need to learn this stuff...

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to determine start point of a polyline?
« Reply #28 on: July 30, 2015, 12:25:27 PM »
Ah problem is that there may be as many as 4 lines converging all with different elevations due to different pipe inverts. So, the line needs to only reference itself - display the current elevation at that end, let me default and move on to other end and enter or default as necessary.

It might be good if it did as you have written and picked up on the adjacent invert but still let me override if the actual invert is different.

Is that possible? I really need to learn this stuff...
All you need to do is take out the coincident point check (lines 48 - 73). I added something I thought would be useful but apparently it's not ( I don't do this type of drafting).


After rereading your post the code already does this:
Quote
It might be good if it did as you have written and picked up on the adjacent invert but still let me override if the actual invert is different.
« Last Edit: July 30, 2015, 12:36:46 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7527
Re: How to determine start point of a polyline?
« Reply #29 on: July 30, 2015, 12:34:05 PM »
If you'd like to find all your lines that have a point (or two) @ elevation 0, you could run this little snippet:
Code - Auto/Visual Lisp: [Select]
  1.   nil
  2.   (ssget "_X"
  3.     '((0 . "line")
  4.       (-4 . "<OR")
  5.       (-4 . "*,*,=")
  6.       (10 0.0 0.0 0.0)
  7.       (-4 . "*,*,=")
  8.       (11 0.0 0.0 0.0)
  9.       (-4 . "OR>")
  10.      )
  11.   )
  12. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC