# Intersection coordinates in Python script

**URL:** <https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962>\
**Category:** Scripting\
**Tags:** windows, python, rhino6\
**Created:** [November 8, 2021, 5:19am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962 "2021-11-08T05:19:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![user774](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user774/32/338512_2.png) [@user774](https://discourse.mcneel.com/u/user774)\
**Post date:** [November 8, 2021, 5:19am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/1 "2021-11-08T05:19:01Z")

</div>

Dear All,

Can you please advise how to extract intersection coordinates from the following Python script?

import rhinoscriptsyntax as rs  
startPoint = [1.0, 2.0, 0.0]  
endPoint = [4.0, 5.0, 0.0]  
line1 = [startPoint, endPoint]  
line1ID = rs.AddLine(line1[0],line1[1]) # Adds a line to the Rhino Document and returns an ObjectID  
startPoint2 = [1.0, 4.0, 0.0]  
endPoint2 = [4.0, 2.0, 0.0]  
line2 = [startPoint2, endPoint2]  
line2ID = rs.AddLine(line2[0],line2[1]) # Returns another ObjectID  
int1 = rs.LineLineIntersection(line1ID,line2ID) # passing the ObjectIDs to the function.

For example I want to use Y-coordinate of above lines intersection in my further calculations.  
Thank you for any advise.

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [November 8, 2021, 6:47am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/2 "2021-11-08T06:47:47Z")

</div>

Hope this help:

```python
import rhinoscriptsyntax as rs
lineA = rs.AddLine([1.0, 2.0, 0.0],[4.0, 5.0, 0.0])
lineB = rs.AddLine([1.0, 4.0, 0.0], [4.0, 2.0, 0.0])
pointA, pointB = rs.LineLineIntersection(lineA, lineB)
print pointA[1] #y coordinate of the intersection point on the first line

```

---

<div class="post-metadata">

**Author:** ![user774](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user774/32/338512_2.png) [@user774](https://discourse.mcneel.com/u/user774)\
**Post date:** [November 8, 2021, 6:56am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/3 "2021-11-08T06:56:29Z")

</div>

Thank you very much!  
It works and this is what I was looking for.

---

<div class="post-metadata">

**Author:** ![user774](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user774/32/338512_2.png) [@user774](https://discourse.mcneel.com/u/user774)\
**Post date:** [November 9, 2021, 5:12am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/4 "2021-11-09T05:12:58Z")

</div>

Could you please advise also how to get (or reference for sample script) Line/Curve intersection and Line/PolySurface intersection with next extraction of coordinates?

Here I have found sample of CurveSurface intersection, but cannot extract coordinates

> **[Curve Surface Intersection](https://developer.rhino3d.com/samples/rhinocommon/curve-surface-intersection/)**
>
> Demonstrates how to calculate the intersection points of a user-specified Brep and a curve.

And herebelow I scripted Line/Curve intersection. And as result I do get intersection coordinates in output, but cannot extract coordinates in list Y = Y.append(PointA[1]) and to use in further calculations.

import rhinoscriptsyntax as rs  
import Rhino

L = rs.GetReal(“X Length of curve projection”)  
B = 8  
H = 4

WL = rs.GetObject(“Select Curve”, rs.filter.curve)

x0 = rs.GetReal(“x0”)  
z = rs.GetReal(“z”)  
n = rs.GetReal(“Number of coordinates”)

def WLY():  
x = x0  
Y = #here should be rectangular brackets for empty list  
for x in rs.frange(x, L, L/n):  
lineA = [[x, 0, z], [x, B/2, z]]  
lineAID = rs.AddLine(lineA[0],lineA[1])  
pointA = rs.CurveCurveIntersection(lineAID, WL)  
print pointA  
x=x0 + L/n  
print (Y)  
WLY()

Appreciate any advise. Thank you.

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [November 9, 2021, 5:33am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/5 "2021-11-09T05:33:17Z")

</div>

Have you checked the function references on [rhinoscriptsyntax](https://developer.rhino3d.com/api/RhinoScriptSyntax)?  
[CurveCurveIntersection](https://developer.rhino3d.com/api/RhinoScriptSyntax/#curve-CurveCurveIntersection)  
[CurveBrepIntersect](https://developer.rhino3d.com/api/RhinoScriptSyntax/#curve-CurveBrepIntersect)  
If you’re using the internal Python script editor, you should have access to these references right after calling a function:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/b/8/2b866f8954839e4c9d8dec91b0603ca6f9502e07.png)

---

<div class="post-metadata">

**Author:** ![user774](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user774/32/338512_2.png) [@user774](https://discourse.mcneel.com/u/user774)\
**Post date:** [November 9, 2021, 5:39am UTC](https://discourse.mcneel.com/t/intersection-coordinates-in-python-script/132962/6 "2021-11-09T05:39:19Z")

</div>

Indeed, I am using the internal Python script editor.  
Thank you, I will study these examples.
