Find intersection point between curves using CPython3

Find intersection point between curves using CPython3

SONA-ARCHITECTURE
Advocate Advocate
1,030 Views
4 Replies
Message 1 of 5

Find intersection point between curves using CPython3

SONA-ARCHITECTURE
Advocate
Advocate

Hi, with ItonPython2.7, I've got no error with this line declaration

 

 

results = clr.Reference[IntersectionResultArray]()

 

 

I can get my point coordinates

In CPython3, I try

 

 

results =  IntersectionResultArray()
setCompResult = curve1.Intersect(curve2, results)  

 

 

I've got no error but result is empty

Do you know why?

 

I saw this for Rhino but does not work for me...
https://discourse.pyrevitlabs.io/t/pyrevit-cpython-python-3-equivalent-of-the-ironpython-python-2-im...

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Accepted solutions (1)
1,031 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

No idea. Remember that this forum is for the Revit API, not for obscure Python related .NET wrapping issues. They will probably be answered better elsewhere. I would assume that you need some clr wrapper or conversion for CPython3 as well, just like you do for IronPython (or are you using ItonPython, as your question states? (Is that a typo?)).

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

SONA-ARCHITECTURE
Advocate
Advocate

Hi jeremy,
hope you fill fine!
Yes, sorry, I know that this is for Revit API C#, but I founded a post about this subject in Python and thought it was possible here..Sorry
I've got a client who asked me a Python script to get intersection point of two curves from grid and I can't get works the interesct function of curve with Cpython3...

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 4 of 5

SONA-ARCHITECTURE
Advocate
Advocate

I found this : https://github.com/DynamoDS/Dynamo/wiki/Work-in-progress-to-improve-Python-3-support#parameters-usin...

 

Maybe it's not planed

 

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 5 of 5

SONA-ARCHITECTURE
Advocate
Advocate
Accepted solution

I founded the solution here : https://forum.dynamobim.com/t/bounding-box-at-grid-curve-intersections/95989/8?u=sona_architecture

 

So, the correct code is :

 

if pyEngineName == "ironpython":
            intersectResultArray = clr.Reference[IntersectionResultArray]()
            result = curve_1.Intersect(curve_2, intersectResultArray)
            if result == DB.SetComparisonResult.Overlap:
                interResult = intersectResultArray.Value
                point = interResult[0].XYZPoint
                DSpoint = point.ToPoint()
                intersection_points.append(DSpoint)  
        else:
            intersectResultArray = IntersectionResultArray()
            result, intersectResultArray = curve_1.Intersect(curve_2, intersectResultArray)
            if result == DB.SetComparisonResult.Overlap:
                point = intersectResultArray[0].XYZPoint
                DSpoint = point.ToPoint()
                intersection_points.append(DSpoint)
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107