DynamoDS / Dynamo

Open Source Graphical Programming for Design
https://dynamobim.org
Other
1.74k stars 634 forks source link

IntersectionResultArray in CPython3 #14678

Closed SonaBIMDev closed 1 year ago

SonaBIMDev commented 1 year ago

Dynamo Version

2.13.1.3887

Host

Revit 2023

Operating System

Windows 11

What did you do?

Trying to get intersection points result btween two curves I'v got 2 curves and want to get intersection between them. It works with IronPython engine not in CPython3, rsult is empty

`resultArray = clr.Reference[IntersectionResultArray]()

setCompResult = curve_1.Intersect(curve_2, resultArray)

if (setCompResult != SetComparisonResult.Overlap): continue

if resultArray is None or resultArray.Size != 1: continue

for i in range(resultArray.Size): point = resultArray.Item[0].XYZPoint DSpoint = point.ToPoint() intersection_points.append(DSpoint) `

What did you expect to see?

A list of point

What did you see instead?

In IronPython, it's ok but in CpYthon3, error returned is : Clr has no attribut reference

What packages or external references (if any) were used?

IronPython2

Stack Trace

No response

Details

No response

github-actions[bot] commented 1 year ago

Thank you for submitting the issue to us. We are sorry to see you get stuck with your workflow. While waiting for our team member to respond, please feel free to browse our forum at https://forum.dynamobim.com/ for more Dynamo related information.

SonaBIMDev commented 1 year ago

Hi, I founded the solution here : https://forum.dynamobim.com/t/bounding-box-at-grid-curve-intersections/95989/9?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)