The first snippet might be a clue to the real problem below. It shows that the rs.ProjectPointToSurface command returns a Rhino.Geometry.Point3d[] object instead of a Python list. This is not difficult to deal with.
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
pointOnSurface = rg.Point3d(415.630,0.000,-263.990)
pointDirection = rg.Vector3d(0.0, 0.0, -1.0)
surface = rs.ObjectsByName(‘lower’)[0]
print(type(pointOnSurface))
print(type(pointDirection))
print(type(surface))
below = rs.ProjectPointToSurface([pointOnSurface], [surface], pointDirection)
print(below)
This code outputs:
<class ‘Rhino.Geometry.Point3d’>
<class ‘Rhino.Geometry.Vector3d’>
<class ‘System.Guid’>
Rhino.Geometry.Point3[]
Here is the code snippet that I am struggling with:
print( type(surface) )
print( type(pointOnSurface) )
print( type(pointDirection) )
print( type(tolerance) )
print(80*‘~’)
above = self.rhino.Geometry.Intersect.Intersection.ProjectPointsToBreps([surface], [pointOnSurface], pointDirection, tolerance)
Here is the output of the code. What RhinoCommon lacks in simplicity it makes up for in error messages ![]()
<class ‘Rhino.Geometry.Brep’>
<class ‘Rhino.Geometry.Point3d’>
<class ‘Rhino.Geometry.Vector3d’>
<class ‘float’>
Python.Runtime.PythonException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep]
The above exception was the direct cause of the following exception:
System.ArgumentException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep] in method Rhino.Geometry.Point3d[] ProjectPointsToBreps(System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep], System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Point3d], Rhino.Geometry.Vector3d, Double) ---> Python.Runtime.PythonException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep]
--- End of inner exception stack trace ---
The above exception was the direct cause of the following exception:
System.AggregateException: One or more errors occurred. ---> System.ArgumentException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep] in method Rhino.Geometry.Point3d[] ProjectPointsToBreps(System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep], System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Point3d], Rhino.Geometry.Vector3d, Double) ---> Python.Runtime.PythonException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep]
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep] in method Rhino.Geometry.Point3d[] ProjectPointsToBreps(System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep], System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Point3d], Rhino.Geometry.Vector3d, Double) ---> Python.Runtime.PythonException: 'list' value cannot be converted to System.Collections.Generic.IEnumerable`1[Rhino.Geometry.Brep]
--- End of inner exception stack trace ---<---
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\mosaic\local\rhinoMemoryServer\adaptToolpath\adaptToolpath.py", line 901, in <module>
AT.start(iniFilename)
File "C:\mosaic\local\rhinoMemoryServer\adaptToolpath\adaptToolpath.py", line 703, in start
result = self.processSingleFile(self.allValues['inputfolder'])
File "C:\mosaic\local\rhinoMemoryServer\adaptToolpath\adaptToolpath.py", line 848, in processSingleFile
result = self.pointUtilities.distanceSourceToTarget(self.pointList, sourceSurfaceId, targetSurfaceId)
File "C:\mosaic\local\rhinoMemoryServer\rhinoUtilities\pointUtilities.py", line 264, in distanceSourceToTarget
targetInt = self.getClosestIntersection(listofPoints, n, targetSurfaceId)
File "C:\mosaic\local\rhinoMemoryServer\rhinoUtilities\pointUtilities.py", line 1019, in getClosestIntersection
above = self.rhino.Geometry.Intersect.Intersection.ProjectPointsToBreps([surface], [pointOnSurface], pointDirection, tolerance)
TypeError: No method matches given arguments for Intersection.ProjectPointsToBreps: (<class 'list'>, <class 'list'>, <class 'Rhino.Geometry.Vector3d'>, <class 'float'>)
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at UnsafeNativeMethods.CRhinoDoc_Delete(UInt32 serialNumber)
at Rhino.RhinoDoc.Finalize()
Of course, the ScriptSyntax uses several “coerce” methods, but I think that the parameters for Geometry.Intersect.Intersection.ProjectPointsToBreps are correct. The error message seems to be complaining about a list or list value. Is it possible that the same issue about rs.ProjectPointToSurface() not returning a list mean that Rhino.Geometry.Intersect.Intersection.ProjectPointsToBreps is also not accepting a list?
Does the Python list of Point3d objects need to be a System.Array - which is a C# thing and I don’t know how to do that.
Thanks for your suggestions