I’m attempting to get the distance between the closest two points, but struggling to figure out the final input (which in C# is show as out resultList) to get it to work.
The code I have is :
And the error message I get is :
I can’t seem to get past this. Any thoughts?
Hello, follow this link you will have the answers to your questions
a try
import clr
import sys
import System
from System.Collections.Generic import List,IList
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
#######OK NOW YOU CAN CODE########
elem1=UnwrapElement(IN[0])
elem2=UnwrapElement(IN[1])
a=elem1.Location.Curve
b=elem2.Location.Curve
outrefClosest = clr.Reference[IList[ClosestPointsPairBetweenTwoCurves]](List[ClosestPointsPairBetweenTwoCurves]())
res=ClosestPointsPairBetweenTwoCurves()
lst=IList[ClosestPointsPairBetweenTwoCurves]
#c=a.ComputeClosestPoints(b,True,True,True,lst)
d=a.ComputeClosestPoints(b,True,True,True,outrefClosest)
closestPt=outrefClosest.Value[0]
distance=0.3048*closestPt.Distance
Pt_curv1=closestPt.XYZPointOnFirstCurve.ToPoint()
OUT =type(lst),type(outrefClosest),closestPt,distance,Pt_curv1
I tried in CPython with no success.
cordially
christian.stan
3 Likes
Yeah that was the concept… i ended up pivoting and leveraging those very nodes but in python form so Geomery.ClosestPointTo(Curve1, Pt1) and got closer to my final goal ; however, still stumped as to why the method from the API gave me that error.
thanks for the information , I’ll def check that one out as well.
1 Like
Hi @christopher.riddell
You can use
from BriMohareb_XXXX pak.
4 Likes
hi, finally found in CPython (with great difficulty)
Thanks Mr. Nick and Mr. Jacob
elem1=UnwrapElement(IN[0])
elem2=UnwrapElement(IN[1])
a=elem1.Location.Curve
b=elem2.Location.Curve
lst=List[ClosestPointsPairBetweenTwoCurves]
c=a.ComputeClosestPoints(b,True,True,True,lst())
dis=0.3048*c[0].Distance
pt1=c[0].XYZPointOnFirstCurve.ToPoint()
pt2=c[0].XYZPointOnSecondCurve.ToPoint()
OUT=c,dis,pt1,pt2
cordially
christian.stan
2 Likes
wow this is awesome. Thank you so much for diving deep into that one.
I for the life of me could not figure out how to get that method set up and in the short term leaned on calling the dynamo node for closest point but really wanted to do it just like you have shown.
Thanks again for the help I really appreciate it!
1 Like
Thank you, but without Mr. Poupin’s Initial post, (My reaction would have been: number of head scratches before getting there:
the magicians are elsewhere (humble as well)
cordially
christian.stan
1 Like
someone explain this part of code to me so that I can use the knowledge for other methods in the api as well
I am getting error though for this
it says Name List is not defined
Hello, you need an Output list (see api)
you must have these 2 lines of code
import System
from System.Collections.Generic import List,IList
to have an output container
by specifying the type of container.
Sincerely
christian.stan
1 Like