Hello,
I tried to convert my old Dynamo scripts to Python scripts and failed at using the Project Method to get the closest points by projecting a list of points to a curve. Please see my error message and script below and let me know where I did wrong. Thanks a lot!
error message:
Warning: TypeError : No method matches given arguments for Project: (<class ‘Autodesk.Revit.DB.XYZ’>) [’ File “”, line 29, in \n’]
script
import clr
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference("RevitNodes")
import System,Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# collect inputs into center point list
if not isinstance(IN[0], list):
centerPtLst= UnwrapElement([IN[0]])
else:
centerPtLst = UnwrapElement(IN[0])
# collect input curve
curve = UnwrapElement(IN[1])
# closest point
closestPtLst = []
for pt in centerPtLst:
closestPt = curve.Project(pt.ToXyz())
closestPtLst.append(closestPt)
# Assign your output to the OUT variable.
OUT = closestPtLst