Exemplo n.º 1
0
 private bool ConvertHbCurveArrArray(HbCurveArrArray hbCurveArrArray, CurveArrArray curveArrArray)
 {
     try {
         foreach (HbCurveArray hbCurveArray in hbCurveArrArray)
         {
             CurveArray curveArray = new CurveArray();
             foreach (HbCurve hbCurve in hbCurveArray)
             {
                 Curve curve = null;
                 if (!ConvertHbCurve(hbCurve, ref curve))
                 {
                     curveArrArray = null;
                     return(false);
                 }
                 curveArray.Append(curve);
             }
             curveArrArray.Append(curveArray);
         }
         return(true);
     }
     catch {
         curveArrArray = null;
         return(false);
     }
 }
Exemplo n.º 2
0
        private HbCurveArrArray UnitsAndTranslation(HbCurveArrArray hbCurveArrArray)
        {
            HbCurveArrArray hbCurveArrArrayNew = new HbCurveArrArray();

            foreach (HbCurveArray hbCurveArray in hbCurveArrArray)
            {
                hbCurveArrArrayNew.Add(UnitsAndTranslation(hbCurveArray));
            }
            return(hbCurveArrArrayNew);
        }
Exemplo n.º 3
0
        private bool ProcessCurveArrArray(HbCurveArrArray hbCurveArrArray)     // various kinds of lines, vertical wall, or planar floor
        {
            try {
                double brepTolerence = GH_Component.DocumentTolerance();  // Not sure what this is but suggested by McNeel
                if (brepTolerence <= 0.0)
                {
                    brepTolerence = 0.001;                                // Since we are not sure what the effect would be
                }
                List <Point3d> pointsInnerLoop;
                Curve          curveInnerLoop;
                List <Point3d> points = new List <Point3d>();
                List <Curve>   curves = new List <Curve>();
                PolyCurve      polyCurve;
                foreach (HbCurveArray hbCurveArray in hbCurveArrArray)
                {
                    //List<Curve> curvesInnerLoop = new List<Curve>();
                    polyCurve = new PolyCurve();
                    foreach (HbCurve hbCurve in hbCurveArray)
                    {
                        HbTypes hbType;
                        if (hbTypeDictionary.TryGetValue(hbCurve.GetType(), out hbType))
                        {
                            HbToRhino(hbCurve, out pointsInnerLoop, out curveInnerLoop);
                            if (pointsInnerLoop != null)
                            {
                                foreach (Point3d point3d in pointsInnerLoop)
                                {
                                    points.Add(point3d);
                                }
                            }
                            if (curveInnerLoop != null)
                            {
                                polyCurve.Append(curveInnerLoop);
                            }
                        }
                    }
                    if (polyCurve.SegmentCount > 0)
                    {
                        curves.Add(polyCurve);
                    }
                }
                // Obsolete w Revit 6
                // Brep brep = Brep.CreatePlanarBreps(curves)[0];
                Brep brep = Brep.CreatePlanarBreps(curves, brepTolerence)[0];

                // Add to outputs
                this.dataTreePoints.AddRange(points, new GH_Path(indexPoints));
                indexPoints++;
                this.dataTreeCurves.AddRange(curves, new GH_Path(indexCurves));
                indexCurves++;

                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 curveItem in curves)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curveItem);
                    }
                }
                if (createGeometrySurfaces)
                {
                    if (brep.Faces.Count > 0)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep);
                    }
                }

                return(true);
            }
            catch {
                return(false);
            }
        }