algorithmic modeling for Rhino
please, what would be the correct way of determining if a geometry is a Plane?
the way I have done it Grasshopper detects even a planar surface as an endless Plane
pManager.AddGeometryParameter("Reference geometry", "G", "", GH_ParamAccess.list);
List<Object> geometry = new List<object>();
foreach (Object geo in geometry)
{Grasshopper.Kernel.Types.GH_Plane ghPlane = new Grasshopper.Kernel.Types.GH_Plane();
ghPlane.CastFrom(geo);
if (ghPlane.IsValid) { ghPlane.CastTo<Plane>(out testPlane);
if (testPlane.IsValid)
{
thanks!
Tags:
Try/catch should work:
private void RunScript(List<object> x, ref object A)
{
var ValidPlanes = new List<Plane>();
foreach(object TestItem in x)
{
Plane TestPlane;
try
{
TestPlane = (Plane) TestItem;
}
catch
{
continue;
}
ValidPlanes.Add(TestPlane);
}
A = ValidPlanes;
}
yup, thanks. that did the trick!
except the types were GH_Plane etc.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by