TheSwamp

CAD Forums => CAD General => Topic started by: yarnstormer on July 29, 2015, 11:14:45 AM

Title: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 11:14:45 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.

Some of the lines are drawn in the wrong direction. I know how to switch the direction but what I don't know is if there is a way to know in advance if it's drawn wrong. I have to change the label style, curse appropriately, then reverse direction and redo the invert elevations. In some cases I don't want to have the label change immediately because I want to compare my cad calculated slopes to what I assume are manually calculated slopes from when this project was begun. So it would be nice to know in advance which ones were buggered up.

I am drawing in Civil 3D but this not a true sewer network - it's just a map we maintain for planning purposes.

Any ideas for some sort of query I can use to check the direction before labeling? maybe some elusive grip info?

Workaround - create a label style with just an arrow and insert it on the line perhaps so I don't have to dump my current labeling until I'm sure I have new info entered. sounds tedious.

Title: Re: How to determine start point of a polyline?
Post by: ronjonp on July 29, 2015, 11:25:21 AM
Maybe a quick visual cue would be to make a linetype (http://www.theswamp.org/index.php?topic=47058.msg520876#msg520876) with '>' as the character and apply it to all your lines. Then you can easily see the direction.
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 11:36:30 AM
Good idea - can always switch em back after if I don't like the look.

Keep em coming!
Title: Re: How to determine start point of a polyline?
Post by: ronjonp on July 29, 2015, 11:51:39 AM
Can you post the file with a "right & wrong" scenario?
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell on July 29, 2015, 12:27:25 PM
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.

Some of the lines are drawn in the wrong direction. I know how to switch the direction but what I don't know is if there is a way to know in advance if it's drawn wrong. I have to change the label style, curse appropriately, then reverse direction and redo the invert elevations. In some cases I don't want to have the label change immediately because I want to compare my cad calculated slopes to what I assume are manually calculated slopes from when this project was begun. So it would be nice to know in advance which ones were buggered up.

I am drawing in Civil 3D but this not a true sewer network - it's just a map we maintain for planning purposes.

Any ideas for some sort of query I can use to check the direction before labeling? maybe some elusive grip info?

Workaround - create a label style with just an arrow and insert it on the line perhaps so I don't have to dump my current labeling until I'm sure I have new info entered. sounds tedious.

I would suggest you convert them to feature lines....it will make assigning the elevations and calculating slopes much easier.
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 12:39:31 PM
I have not worked with feature lines. Can you give me a quick explanation?
Would I have to redo each label etc?

This is the entire sewer network for a largish county. I hesitate to reinvent the wheel in case some one else wants to edit the drawing down the line and is not familiar with feature lines either. I get fussed at for using mtext!
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell on July 29, 2015, 12:50:05 PM
well then....perhaps feature lines are not the way to go...

except the labels would be dynamic

perhaps a different option is to create them as Parcel Lines and then put elevations on them....

or draw them as pipes...easier to put elevation on them...

Just use Create Pipe Network from Object.....


The reason I'm pointing you in this direction....is eventual output as SDF (spatial data format)

You are technically creating a GIS data set and that SDF file could then be attached to MAP and maintained using MAP moving forward
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 01:01:20 PM
The reason I'm pointing you in this direction....is eventual output as SDF (spatial data format)

You are technically creating a GIS data set and that SDF file could then be attached to MAP and maintained using MAP moving forward


You are preaching to the choir man but I'm sorta stuck with this plan for now. I am at least allowed to give GIS dept info now. Took a couple of years to get to that point. Engineers + GIS = drama. At least in my hood.

Here's at bit of the file. Not a huge hassle just thought there might be a way to tell what direction lines were going that I was unaware of.
Title: Re: How to determine start point of a polyline?
Post by: Mark on July 29, 2015, 01:10:50 PM
I would suggest you convert them to feature lines....it will make assigning the elevations and calculating slopes much easier.

Close Civil3D and reboot your computer

You sound like a damn Autodesk salesperson.

:)
Title: Re: How to determine start point of a polyline?
Post by: ronjonp on July 29, 2015, 02:05:25 PM
The reason I'm pointing you in this direction....is eventual output as SDF (spatial data format)

You are technically creating a GIS data set and that SDF file could then be attached to MAP and maintained using MAP moving forward


You are preaching to the choir man but I'm sorta stuck with this plan for now. I am at least allowed to give GIS dept info now. Took a couple of years to get to that point. Engineers + GIS = drama. At least in my hood.

Here's at bit of the file. Not a huge hassle just thought there might be a way to tell what direction lines were going that I was unaware of.
Seems like the linetype would be the easiest visual indicator if you're doing this by hand anyways.

Title: Re: How to determine start point of a polyline?
Post by: mjfarrell on July 29, 2015, 02:08:40 PM
I would suggest you convert them to feature lines....it will make assigning the elevations and calculating slopes much easier.

Close Civil3D and reboot your computer

You sound like a damn Autodesk salesperson.

:)

Nah, you know I don't SELL the software....I do however provide TRAINING and or Continuing Education services for professionals at all levels.
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 02:10:50 PM

[/quote]
Seems like the linetype would be the easiest visual indicator if you're doing this by hand anyways.
[/quote]

I like it. I'll just pull all of my sewer files up and straighten them all out once and for all.
Title: Re: How to determine start point of a polyline?
Post by: ronjonp on July 29, 2015, 02:14:09 PM

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.
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell on July 29, 2015, 02:36:11 PM
Actually another method...would be to convert them to parcel lines en mass

This combined with segment direction label style will allow you to know what direction they are going in all at once.

Combine this with the  _AeccReverseFeature command will then let you reverse them if they are going the wrong way.

Side benefit they can then be exported as SDF
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on July 29, 2015, 02:54:15 PM

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.
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell 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
Title: Re: How to determine start point of a polyline?
Post by: ronjonp on July 29, 2015, 03:17:22 PM
The example drawing posted is using lines ( the subject line of the thread is incorrect ).
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell 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
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer 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
Title: Re: How to determine start point of a polyline?
Post by: Mark 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.
Title: Re: How to determine start point of a polyline?
Post by: mjfarrell 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.
Title: Re: How to determine start point of a polyline?
Post by: Mark 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]
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer 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.
Title: Re: How to determine start point of a polyline?
Post by: ronjonp 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. )

Title: Re: How to determine start point of a polyline?
Post by: mjfarrell 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
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer 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?
Title: Re: How to determine start point of a polyline?
Post by: ronjonp 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" (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=coincident).


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. )
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer 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...
Title: Re: How to determine start point of a polyline?
Post by: ronjonp 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.
Title: Re: How to determine start point of a polyline?
Post by: ronjonp 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. )
Title: Re: How to determine start point of a polyline?
Post by: yarnstormer on August 24, 2015, 09:56:09 AM
Just wanted to pop in and say how helpful your replies have been. I'll be using that lisp routine on a regular basis. Thanks!