from polyline startpoint, endpoint, turn angles of 0,90,180,270 with distance

765
4
06-27-2019 05:52 AM
johncoon
New Contributor

Hi All,

New to ESRI and New to Python.

I'm trying to find out if it's possible to turn angles of 0,90,180,270, from a defined line / polyline .startpoint and .endpoints with distance based on whatever the line direction is. Using the direction of the line / polyline object, either start to end or end to start to define what end I want to use, and what direction I'm going.

I'm looking to be able to do Three things, first, use the cursor tool to loop thru all the, in my case (centerlines) layer and draw new polylines, see attached figure. Getting started I can hard code the angle and distance to draw. in the end,

I'd like to get those values from a field.

Second, the same draw function, but this time, I want to select a single (centerline) by some name field and be able to draw from a selected end. either .startpoint or .endpoint. with a supplied distance and create something like what is in the attached pdf.

Third, same as number 2, but the .startpoint and .endpoints locations or direction would come from a text file.

Read text file, startpoint .endpoint, distance to go, angle to use, create new point.

 {startpoint}, {endpoint},{Distance}, {create new point}, draw polyline from points.

This is my first attempt with Python. First week. It looks pretty powerful, Hopefully someone can point me to some samples that do similar tasks, so I can get stated automating a few tasks. Hopefully what I'm trying to do makes sense.

Thanks

John   

0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

Sharing with Python‌ and Analysis

0 Kudos
johncoon
New Contributor

I looked in the link. I didn't see anything that jumped out at me for what I'm trying to do. I did look in the API, but didn't find anything. But with names like searchcursor, I would of never looked under that to do some type of selection set. It all new. 

John

0 Kudos
johncoon
New Contributor

so I'm guessing that python doesn't have a method to turn an angle off the start or end point of a line.

0 Kudos
johncoon
New Contributor

This is basically what I want to do. see attached pdf also. this is for Autocad, I need to do the same in ESRI

Set objWCS = ThisDrawing.UserCoordinateSystems.Add(dblOrigin, dblXVector, dblYVector, "WCS")
ThisDrawing.ActiveUCS = objWCS

On Error GoTo errhndlr

point1 = ThisDrawing.Utility.GetPoint(, "Select Runway Centerline at First Threshold Point,")
point2 = ThisDrawing.Utility.GetPoint(point1, "Select Runway Centerline at Second Threshold Point")

Dim insertionPnt10(0 To 2) As Double
    insertionPnt10(0) = point1(0) 'x
    insertionPnt10(1) = point1(1) 'y
    insertionPnt10(2) = 0 'z

Dim insertionPnt11(0 To 2) As Double
    insertionPnt11(0) = point2(0) 'x
    insertionPnt11(1) = point2(1) 'y
    insertionPnt11(2) = 0 'z

Dim rw1, rw2, rwdist, rwhalfdist As Double
rw1 = point1(0) - point2(0)
rw2 = point1(1) - point2(1)
rwdist = Sqr(rw1 ^ 2 + rw2 ^ 2)
rwhalfdist = rwdist / 2
Module1.rwhalfdist = rwhalfdist

Dim dblRot As Double
Dim pi As Double
pi = 3.14159265358979
 
 
 pt1 = insertionPnt10
 pt2 = insertionPnt11

Module1.pt1 = pt1
Module1.pt2 = pt2


'WBC:replace with this line
 dblRot = ThisDrawing.Utility.AngleFromXAxis(pt1, pt2)

newpt9000 = ThisDrawing.Utility.PolarPoint(pt1, (pi + dblRot), -0#)
newpt9001 = ThisDrawing.Utility.PolarPoint(pt1, (pi + dblRot), -thresoffset)
newpt9002 = ThisDrawing.Utility.PolarPoint(pt1, (pi + dblRot), -thresoffset + -150)
'left side bars
newpt9003 = ThisDrawing.Utility.PolarPoint(newpt9001, (pi/2 + dblRot), 5.75)
newpt9004 = ThisDrawing.Utility.PolarPoint(newpt9001, ((pi/2 + dblRot), 11.5)
newpt9005 = ThisDrawing.Utility.PolarPoint(newpt9002, ((pi/2 + dblRot), 11.5)
newpt9006 = ThisDrawing.Utility.PolarPoint(newpt9002, ((pi/2 + dblRot), 5.75)

0 Kudos