Hi all,
I now have a script that extends a Line to the edge of a Polygon (see my previous post), and I would like to use this extended Line as input for another Toolbar — specifically, in "Create a TIN" as a "Soft Line." Does anyone know how I can do this?
Hier what I'm missing: since I can't connect two Processes, I don't know how I can proceed.
Hier there is my Script:
import arcpy
import math
dist = 500
fc_line = arcpy.GetParameterAsText(0)
fc_poly = arcpy.GetParameterAsText(1)
output_fc = arcpy.GetParameterAsText(2)
temp_fc = "in_memory/temp_fc"
arcpy.CopyFeatures_management(fc_line, temp_fc)
with arcpy.da.SearchCursor(fc_poly, "SHAPE@") as scur:
for poly, in scur:
boundary = poly.boundary()
arcpy.SelectLayerByLocation_management(temp_fc, "WITHIN", poly)
with arcpy.da.UpdateCursor(temp_fc, "SHAPE@") as ucur:
for line, in ucur:
arr, = line.getPart()
SR = line.spatialReference # Räumliche Referenz der Linie
p1, p2 = arr[:2]
angle = math.atan2(p2.Y - p1.Y, p2.X - p1.X)
p = arcpy.Point(p1.X - dist * math.cos(angle), p1.Y - dist * math.sin(angle))
arr.insert(0, p)
pn1, pn = arr[-2:]
angle = math.atan2(pn.Y - pn1.Y, pn.X - pn1.X)
p = arcpy.Point(pn.X + dist * math.cos(angle), pn.Y + dist * math.sin(angle))
arr.append(p)
line = arcpy.Polyline(arr, SR)
line = line.cut(boundary)[1]
ucur.updateRow([line])
arcpy.CopyFeatures_management(temp_fc, output_fc)
arcpy.Delete_management(temp_fc)
arcpy.SetParameterAsText(2, output_fc)
Thanks for any Tipps,
Donatella
Solved! Go to Solution.
You need to define the outputfc result layer as an output parameter of your tool.
https://pro.arcgis.com/en/pro-app/latest/help/sharing/overview/inputs-and-outputs.htm
Once that is done, when you add the tool to ModelBuilder, the tool will show an output oval that you can connect as input to other processes.
You need to define the outputfc result layer as an output parameter of your tool.
https://pro.arcgis.com/en/pro-app/latest/help/sharing/overview/inputs-and-outputs.htm
Once that is done, when you add the tool to ModelBuilder, the tool will show an output oval that you can connect as input to other processes.