private void RunScript(Guid id, double Sx, double Sy, double Sz, ref object A, ref object B) { object obj = RhinoDocument.Objects.Find(id); Rhino.DocObjects.PointCloudObject cloudObject = obj as Rhino.DocObjects.PointCloudObject; if (cloudObject == null) { return; } PointCloud cloud = cloudObject.PointCloudGeometry; // var PCO = new { PC = cloud }; // A = PCO; //cloudObject.PointCloudGeometry //Get Bounding Box of Mesh and find the X,Y,Z extents discritizations: BoundingBox BB = cloud.GetBoundingBox(false); //M.GetBoundingBox(True) Vector3d VSize = new Vector3d(Sx, Sy, Sz); BoundingBox Zbbox = RBBox_to_ZBBox(BB, VSize); int CX = Convert.ToInt32(Math.Floor((Zbbox.Max.X - Zbbox.Min.X) / Sx)); int CY = Convert.ToInt32(Math.Floor((Zbbox.Max.Y - Zbbox.Min.Y) / Sy)); int CZ = Convert.ToInt32(Math.Floor((Zbbox.Max.Z - Zbbox.Min.Z) / Sz)); bool[, ,] Voxels3I = new bool[CX + 1, CY + 1, CZ + 1]; List <Point3d> VoxelsOut = new List <Point3d>(); //FileSystem.Print(string.Format("{0},{1},{2}", CX, CY, CZ)); foreach (Point3d point in cloud.GetPoints()) { int i = Convert.ToInt32(Math.Floor((point.X - Zbbox.Min.X) / Sx)); int j = Convert.ToInt32(Math.Floor((point.Y - Zbbox.Min.Y) / Sy)); int k = Convert.ToInt32(Math.Floor((point.Z - Zbbox.Min.Z) / Sz)); if (!Voxels3I[i, j, k]) { Voxels3I[i, j, k] = true; Point3d VoxelOut = new Point3d(i * Sx, j * Sy, k * Sz) + VSize / 2 + Zbbox.Min; VoxelsOut.Add(VoxelOut); } } A = VoxelsOut; B = Voxels_to_Boxels(VoxelsOut.ToArray(), new Vector3d(Sx, Sy, Sz)); }
internal static RhinoObject CreateRhinoObjectHelper(IntPtr pRhinoObject) { if (IntPtr.Zero == pRhinoObject) return null; uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(pRhinoObject); if (sn < 1) return null; int type = UnsafeNativeMethods.CRhinoRhinoObject_GetRhinoObjectType(pRhinoObject); if (type < 0) return null; RhinoObject rc; switch (type) { case idxCRhinoPointObject: //1 rc = new PointObject(sn); break; case idxCRhinoCurveObject: //2 rc = new CurveObject(sn); break; case idxCRhinoMeshObject: //3 rc = new MeshObject(sn); break; case idxCRhinoBrepObject: //4 rc = new BrepObject(sn); break; case idxCRhinoPointCloudObject: //5 rc = new PointCloudObject(sn); break; case idxCRhinoAnnotationTextObject: //6 rc = new TextObject(sn); break; case idxCRhinoSurfaceObject: //7 rc = new SurfaceObject(sn); break; case idxCRhinoInstanceObject: //8 rc = new InstanceObject(sn); break; case idxCRhinoHatchObject: //9 rc = new HatchObject(sn); break; case idxCRhinoDetailViewObject: //10 rc = new DetailViewObject(sn); break; case idxCRhinoClippingPlaneObject: //11 rc = new ClippingPlaneObject(sn); break; case idxCRhinoTextDot: //12 rc = new TextDotObject(sn); break; case idxCRhinoGripObject: //13 rc = new GripObject(sn); break; #if USING_V5_SDK case idxCRhinoExtrusionObject: //14 rc = new ExtrusionObject(sn); break; #endif case idxCRhinoLinearDimension: //15 rc = new LinearDimensionObject(sn); break; case idxCRhinoAnnotationObject: //16 rc = new AnnotationObjectBase(sn); break; case idxCRhinoLight: //17 rc = new LightObject(sn); break; case idxCRhinoMorphControl: //18 rc = new MorphControlObject(sn); break; case idxCRhinoRadialDimension: //19 rc = new RadialDimensionObject(sn); break; case idxCRhinoAngularDimension: //20 rc = new AngularDimensionObject(sn); break; default: rc = new RhinoObject(sn); break; } return rc; }