Example #1
0
        private HbReferenceArrayArray UnitsAndTranslation(HbReferenceArrayArray hbReferenceArrayArray)
        {
            HbReferenceArrayArray hbReferenceArrayArrayNew = new HbReferenceArrayArray();

            foreach (HbReferenceArray hbReferenceArray in hbReferenceArrayArray)
            {
                hbReferenceArrayArrayNew.Add(UnitsAndTranslation(hbReferenceArray));
                if (this.ErrorMessage != "")
                {
                    return(null);
                }
            }
            return(hbReferenceArrayArrayNew);
        }
Example #2
0
        public bool ProcessLoftForm(HbReferenceArrayArray hbReferenceArrayArray)    //hbInputItem.HbReferenceArrayArray  - (multiple HbReferenceArray)
        {
            try {
                List <Point3d> points = new List <Point3d>();
                List <Curve>   curves = new List <Curve>();
                Brep           brep   = null;
                int            uCount = hbReferenceArrayArray.Count();
                int            vCount = 0; // Dummy value for compiler
                bool           first  = true;
                foreach (HbReferenceArray hbReferenceArray in hbReferenceArrayArray)
                {
                    if (first)
                    {
                        vCount = hbReferenceArray.Count();
                        first  = false;
                    }
                    List <Point3d> pointsCurve = new List <Point3d>();
                    foreach (HbReferencePoint hbReferencePoint in hbReferenceArray)
                    {
                        Point3d point3d = new Point3d(hbReferencePoint.X, hbReferencePoint.Y, hbReferencePoint.Z);
                        points.Add(point3d);
                        pointsCurve.Add(point3d);
                    }
                    curves.Add(NurbsCurve.Create(false, 3, pointsCurve));
                }
                try {
                    NurbsSurface nurbsSurface = NurbsSurface.CreateFromPoints(points, uCount, vCount, 3, 3);
                    brep = nurbsSurface.ToBrep();
                }
                catch { }


                // Add to outputs
                this.dataTreePoints.AddRange(points, new GH_Path(indexPoints));
                indexPoints++;
                this.dataTreeCurves.AddRange(curves, new GH_Path(indexCurves));
                indexCurves++;
                if (brep != null)
                {
                    this.dataTreeBreps.AddRange(new List <Brep> {
                        brep
                    }, new GH_Path(indexBreps));
                    indexBreps++;
                }

                // Create geometry
                if (createGeometryPoints)
                {
                    foreach (Point3d point3d in points)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(point3d);
                    }
                }
                if (createGeometryCurves)
                {
                    foreach (Curve curve in curves)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curve);
                    }
                }
                if (createGeometrySurfaces)
                {
                    if (brep != null)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep);
                    }
                }
                return(true);
            }
            catch {
                return(false);
            }
        }