# 3D intersection of 2 3D polylines with Python

Question asked by ashkan.hassanzadeh on Jul 3, 2018
Latest reply on Jul 10, 2018 by dkwiens

I am new to the arcpy. I searched the community and I didn't find the answer to the question.

I have problem with finding the intersection of two 3D polylines (each one with 2 vertex) with python in arcgis standard 10.5.  Polylines are not in a .shp file, because they created using polyline1 = arcpy.polyline(...) so I can call them directly.

Using point = polyline1.intersect(polyline2 , 1)  just create a multipoint class without anypoint in it.

I need the intersection point coordination (with z) as an answer

Also, I have problem with writing 3d polylines to .shp and .mdb files. after writing polylines to the file, the arcmap omit the z values and all the lines are horizontal.

So I really appriciate help with these 2 questions.

This is an example of the problems:

from os.path import expanduser
from os.path import join as joinadd
import os
import arcpy

#first question:

#2 below polylines obviously have intersection

#creating 3d polylines

polytemp1=arcpy.Polyline(arcpy.Array([arcpy.Point(1,2,1),arcpy.Point(10,11,10)]),"Unknown",True,False)

polytemp2=arcpy.Polyline(arcpy.Array([arcpy.Point(1,2,5),arcpy.Point(10,11,5)]),"Unknown",True,False)

#check for the intersection with disjoint

polytemp1.disjoint(polytemp2) #The answer is False, which means there is an intersection, but is disjoint check in 3D???? or just 2D????

#finding the point (3D)

pnt = polyline1.intersect(polyline2 , 1)

print 'newpoint' ,newpoint.pointCount, newpoint.type, newpoint.partCount #This shows that there is no point in the multipoint!!

#second question: writing a 3d polyline in a .shp file:

cursor = arcpy.da.InsertCursor(polyline1add, ["SHAPE@"])

cursor.insertRow([polyline1])

del cursor

#now I have the .shp file, but the lines are 2D!!