コード例 #1
0
        private bool ProcesssCurveItem(HbInputItem hbInputItem, double verticalHeight)
        {
            try {
                List <Point3d> points;
                Curve          curve;
                Extrusion      extrusion = null;
                //Brep brep = null;
                HbToRhino(hbInputItem.HbCurve, out points, out curve);

                // Add to outputs
                this.dataTreePoints.AddRange(points, new GH_Path(indexPoints));
                indexPoints++;
                this.dataTreeCurves.AddRange(new List <Curve> {
                    curve
                }, new GH_Path(indexCurves));
                indexCurves++;
                if (verticalHeight > 0)
                {
                    extrusion = Extrusion.Create(curve, verticalHeight, false);
                    this.dataTreeBreps.AddRange(new List <Brep> {
                        Brep.CreateFromSurface(extrusion)
                    }, new GH_Path(indexBreps));
                    indexBreps++;
                }

                // Create Geometry
                if (createGeometryPoints)
                {
                    if (points != null)
                    {
                        foreach (Point3d point3d in points)
                        {
                            Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(point3d);
                        }
                    }
                }
                if (createGeometryCurves)
                {
                    if (curve != null)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curve);
                    }
                }
                if (createGeometrySurfaces)
                {
                    if (extrusion != null)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddExtrusion(extrusion);
                    }
                }
                return(true);
            }
            catch {
                return(false);
            }
        }
コード例 #2
0
 private bool ProcesssCurveItem(HbInputItem hbInputItem)
 {
     return(ProcesssCurveItem(hbInputItem, 0));  // 0 is code to not try to make a vertical extrusion
 }
コード例 #3
0
        // Note: not building the ReferencePoint, ReferenceArray, or ReferenceArrayArray here since they require a model transaction

        #endregion

        #region Constructor                             // ****************************** Constructor ***********************************************

        public InputItem(HbInputItem hbInputItem, Double unitsFactor, XYZ translation, bool unitsOrTranslationNeeded)
        {
            this.ErrorMessage = "";
            if (unitsOrTranslationNeeded)
            {
                this.unitsFactor = unitsFactor;
                this.translation = translation;
                if (hbInputItem.HbCurve != null)
                {
                    hbInputItem.HbCurve = UnitsAndTranslation(hbInputItem.HbCurve);
                    if (hbInputItem.HbCurve == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
                if (hbInputItem.ListHbXYZ != null)
                {
                    hbInputItem.ListHbXYZ = UnitsAndTranslation(hbInputItem.ListHbXYZ);
                    if (hbInputItem.ListHbXYZ == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
                if (hbInputItem.HbCurveArrArray != null)
                {
                    hbInputItem.HbCurveArrArray = UnitsAndTranslation(hbInputItem.HbCurveArrArray);
                    if (hbInputItem.HbCurveArrArray == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
                if (hbInputItem.HbReferencePoint != null)
                {
                    hbInputItem.HbReferencePoint = UnitsAndTranslation(hbInputItem.HbReferencePoint);
                    if (hbInputItem.HbReferencePoint == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
                if (hbInputItem.HbReferenceArray != null)
                {
                    hbInputItem.HbReferenceArray = UnitsAndTranslation(hbInputItem.HbReferenceArray);
                    if (hbInputItem.HbReferenceArray == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
                if (hbInputItem.HbReferenceArrayArray != null)
                {
                    hbInputItem.HbReferenceArrayArray = UnitsAndTranslation(hbInputItem.HbReferenceArrayArray);
                    if (hbInputItem.HbReferenceArrayArray == null)
                    {
                        if (this.ErrorMessage == "")
                        {
                            this.ErrorMessage = "Error creating 'InputItem' object.";
                        }
                        return;
                    }
                }
            }

            this.HbInputItem = hbInputItem;
            if (HbInputItem.HbCurve != null)
            {
                if (!ConvertHbCurve(HbInputItem.HbCurve, ref this.curve))
                {
                    this.curve = null;
                    if (this.ErrorMessage == "")
                    {
                        this.ErrorMessage = "Error creating 'InputItem' object.";
                    }
                    return;
                }
            }
            else
            {
                this.Curve = null;
            }

            if (HbInputItem.ListHbXYZ != null && HbInputItem.ListHbXYZ.Count > 0)
            {
                this.ListXYZ = new List <XYZ>();
                if (!ConvertListHbXyz(HbInputItem.ListHbXYZ, this.ListXYZ))
                {
                    this.ListXYZ = null;
                    if (this.ErrorMessage == "")
                    {
                        this.ErrorMessage = "Error creating 'InputItem' object.";
                    }
                    return;
                }
            }
            else
            {
                this.ListXYZ = null;
            }

            if (HbInputItem.HbCurveArrArray != null && HbInputItem.HbCurveArrArray.Count() > 0)
            {
                this.CurveArrArray = new Autodesk.Revit.DB.CurveArrArray();
                if (!ConvertHbCurveArrArray(HbInputItem.HbCurveArrArray, this.CurveArrArray))
                {
                    this.CurveArrArray = null;
                    if (this.ErrorMessage == "")
                    {
                        this.ErrorMessage = "Error creating 'InputItem' object.";
                    }
                    return;
                }
            }
            else
            {
                this.CurveArrArray = null;
            }

            if (HbInputItem.StringValues != null)
            {
                this.StringValues = HbInputItem.StringValues;
                if (this.StringValues.Count > 0)
                {
                    this.String0 = this.StringValues[0];
                }
                else
                {
                    this.String0 = null;
                }
                if (this.StringValues.Count > 1)
                {
                    this.String1 = this.StringValues[1];
                }
                else
                {
                    this.String1 = null;
                }
                if (this.StringValues.Count > 2)
                {
                    this.String2 = this.StringValues[2];
                }
                else
                {
                    this.String2 = null;
                }
            }

            if (HbInputItem.IntValues != null)
            {
                this.IntValues = HbInputItem.IntValues;
                if (this.IntValues.Count > 0)
                {
                    this.Int0 = this.IntValues[0];
                }
                else
                {
                    this.Int0 = 0;
                }
            }

            if (HbInputItem.DoubleValues != null)
            {
                this.DoubleValues = HbInputItem.DoubleValues;
                if (this.DoubleValues.Count > 0)
                {
                    this.Double0 = this.DoubleValues[0];
                }
                else
                {
                    this.Double0 = 0;
                }
                if (this.DoubleValues.Count > 1)
                {
                    this.Double1 = this.DoubleValues[1];
                }
                else
                {
                    this.Double1 = 0;
                }
            }

            if (HbInputItem.BoolValues != null)
            {
                this.BoolValues = HbInputItem.BoolValues;
                if (this.BoolValues.Count > 0)
                {
                    this.Bool0 = this.BoolValues[0];
                }
                else
                {
                    this.Bool0 = false;
                }
                if (this.BoolValues.Count > 1)
                {
                    this.Bool1 = this.BoolValues[1];
                }
                else
                {
                    this.Bool1 = false;
                }
            }
        }