示例#1
0
        public string formatCurve(HbCurve curve)
        {
            string curveName   = curve.GetType().Name.Substring(2); //Strips the "Hb"
            string buildString = curveName + ": ";

            switch (curveName)
            {
            case "Arc":
                HbArc arc = (HbArc)curve;
                buildString += formatPoints(arc.PointStart, arc.PointEnd, arc.PointMid);
                break;

            case "Line":
                HbLine line = (HbLine)curve;
                buildString += formatPoints(line.PointStart, line.PointEnd);
                break;

            case "Ellipse":
            case "HermiteSpline":
            case "NurbSpline":
            default:
                break;
            }
            return(buildString);
        }
示例#2
0
 private HbCurve UnitsAndTranslation(HbCurve hbCurve)
 {
     try {
         if (hbCurve is HbLine)
         {
             HbLine hbLine = (HbLine)hbCurve;
             return(new HbLine(UnitsAndTranslation(hbLine.PointStart), UnitsAndTranslation(hbLine.PointEnd)));
         }
         else if (hbCurve is HbArc)
         {
             HbArc hbArc = (HbArc)hbCurve;
             return(new HbArc(UnitsAndTranslation(hbArc.PointStart), UnitsAndTranslation(hbArc.PointEnd), UnitsAndTranslation(hbArc.PointMid)));
         }
         else if (hbCurve is HbEllipse)
         {
             HbEllipse hbEllipse = (HbEllipse)hbCurve;
             return(new HbEllipse(UnitsAndTranslation(hbEllipse.PointFirst), UnitsAndTranslation(hbEllipse.PointSecond), hbEllipse.RadiusY * this.unitsFactor, hbEllipse.Mode));
         }
         else if (hbCurve is HbNurbSpline)
         {
             HbNurbSpline hbNurbSpline = (HbNurbSpline)hbCurve;
             List <HbXYZ> listHbXyz    = new List <HbXYZ>();
             foreach (HbXYZ hbXyz in hbNurbSpline.Points)
             {
                 listHbXyz.Add(UnitsAndTranslation(hbXyz));
             }
             return(new HbNurbSpline(listHbXyz));
         }
         else if (hbCurve is HbHermiteSpline)
         {
             HbHermiteSpline hbHermiteSpline = (HbHermiteSpline)hbCurve;
             List <HbXYZ>    listHbXyz       = new List <HbXYZ>();
             foreach (HbXYZ hbXyz in hbHermiteSpline.Points)
             {
                 listHbXyz.Add(UnitsAndTranslation(hbXyz));
             }
             return(new HbHermiteSpline(listHbXyz));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception exception) {
         this.ErrorMessage = "Error in UnitsAndTranslation: " + exception.Message + ".";
         return(null);
     }
 }
示例#3
0
        // ************************************************ RevitModelBuilder Data Functions *****************************************************
        public HbCurve Hb(NurbsCurve nurbsCurveRhino)
        {
            HbNurbSpline nurbSplineRevit = new HbNurbSpline();

            Rhino.Geometry.Collections.NurbsCurvePointList points = nurbsCurveRhino.Points;
            for (int k = 0; k < points.Count; k++)
            {
                Rhino.Geometry.ControlPoint controlPoint = points[k];
                Point3d xyzRhino = controlPoint.Location;
                HbXYZ   xyzRevit = new HbXYZ(xyzRhino.X, xyzRhino.Y, xyzRhino.Z);
                nurbSplineRevit.Points.Add(xyzRevit);
            }
            HbCurve hbCurve = nurbSplineRevit;

            return(hbCurve);
        }
示例#4
0
        public HbCurve Hb(ArcCurve arcCurveRhino)
        {
            HbCurve hbCurve       = new HbCurve();
            Point3d xyzRhinoStart = arcCurveRhino.PointAtStart;
            Point3d xyzRhinoEnd   = arcCurveRhino.PointAtEnd;
            Point3d xyzRhinoMid   = arcCurveRhino.PointAtNormalizedLength(0.5);

            if (arcCurveRhino.IsArc())
            {
                HbArc hbArcRevit = new HbArc();
                hbArcRevit.PointStart = new HbXYZ(xyzRhinoStart.X, xyzRhinoStart.Y, xyzRhinoStart.Z);
                hbArcRevit.PointEnd   = new HbXYZ(xyzRhinoEnd.X, xyzRhinoEnd.Y, xyzRhinoEnd.Z);
                hbArcRevit.PointMid   = new HbXYZ(xyzRhinoMid.X, xyzRhinoMid.Y, xyzRhinoMid.Z);
                hbCurve = hbArcRevit;
            }
            return(hbCurve);
        }
示例#5
0
        public HbCurve Hb(LineCurve lineCurveRhino)
        {
            HbCurve hbCurve       = new HbCurve();
            Point3d xyzRhinoStart = lineCurveRhino.PointAtStart;
            Point3d xyzRhinoEnd   = lineCurveRhino.PointAtEnd;

            //Not sure why we get the midpoint here for a line object?
            //Point3d xyzRhinoMid = lineCurveRhino.PointAt(0.5);
            if (lineCurveRhino.IsLinear())
            {
                HbLine hbLineRevit = new HbLine();
                hbLineRevit.PointStart = new HbXYZ(xyzRhinoStart.X, xyzRhinoStart.Y, xyzRhinoStart.Z);
                hbLineRevit.PointEnd   = new HbXYZ(xyzRhinoEnd.X, xyzRhinoEnd.Y, xyzRhinoEnd.Z);
                hbCurve = hbLineRevit;
            }
            return(hbCurve);
        }
示例#6
0
 public void Add(HbCurve hbItem)
 {
     HbCurves.Add(hbItem);
 }
示例#7
0
        private string ProcessHbCurve(string objectCurrent, DataRow dataRow, List <HbXYZ> hHbXyzList, out HbCurve hbCurve)
        {
            switch (objectCurrent)
            {
            case "Line":
                if (hHbXyzList.Count < 2)
                {
                    hbCurve = null;
                    return("");
                }
                hbCurve = new HbLine(hHbXyzList[0], hHbXyzList[1]);
                break;

            case "Arc":
                if (hHbXyzList.Count < 3)
                {
                    hbCurve = null;
                    return("");
                }
                hbCurve = new HbArc(hHbXyzList[0], hHbXyzList[1], hHbXyzList[2]);
                break;

            case "NurbSpline":
                if (hHbXyzList.Count < 2)
                {
                    hbCurve = null;
                    return("");
                }
                hbCurve = new HbNurbSpline(hHbXyzList);
                break;

            case "Ellipse":
                HbXYZ point1 = new GetHbValue(dataRow[4].ToString()).AsHbXYZ();
                HbXYZ point2 = new GetHbValue(dataRow[5].ToString()).AsHbXYZ();
                if (point1 == null || point2 == null)
                {
                    hbCurve = null;
                    return("");
                }
                double radius = (double)new GetHbValue(dataRow[6].ToString()).AsDouble();
                string mode   = dataRow[6].ToString();
                hbCurve = new HbEllipse(point1, point2, radius, mode);
                break;

            case "HermiteSpline":
                if (hHbXyzList.Count < 2)
                {
                    hbCurve = null;
                    return("");
                }
                hbCurve = new HbHermiteSpline(hHbXyzList);
                break;

            default:
                hbCurve = null;
                return("Object '" + objectCurrent + "' encountered during ProcessHbCurve.");
            }
            return("");
        }
示例#8
0
 private string ProcessHbCurve(string objectCurrent, DataRow dataRow, out HbCurve hbCurve)
 {
     return(ProcessHbCurve(objectCurrent, dataRow, null, out hbCurve));
 }
示例#9
0
 private string ProcessHbCurve(string objectCurrent, List <HbXYZ> hHbXyzList, out HbCurve hbCurve)
 {
     return(ProcessHbCurve(objectCurrent, null, hHbXyzList, out hbCurve));
 }
示例#10
0
        private string GetNextInputItem(ref int dataTableIndex, out HbInputItem inputItem)
        {
            inputItem = new HbInputItem();

            // Manage initial end of file conditions
            // This is not an error; it indicates that the last item has been processed
            if (dataTableIndex > dataTable.Rows.Count - 1)
            {
                return("EOF");
            }

            bool endOfFileCondition = false;

            if (dataTableIndex == dataTable.Rows.Count - 1)
            {
                endOfFileCondition = true;
            }

            // Create the new InputItem to be returned at the end.
            inputItem = new HbInputItem();
            string returnValue = "";

            // Get the initial data rows and set initial state
            DataRow dataRowCurrent = this.dataTable.Rows[dataTableIndex];
            DataRow dataRowNext    = null;

            if (!endOfFileCondition)
            {
                dataRowNext = this.dataTable.Rows[dataTableIndex + 1];
            }
            string arrayState = ""; // = "", "InCurveArray", "InReferenceArray"  //"InUseSet",

            // Primary loop
            List <HbXYZ>          currentHbXyzList             = null; // Null values just for compiler; a new one of these three is created whenever it is used
            HbCurveArrArray       currentHbCurveArrayArray     = null;
            HbReferenceArrayArray currentHbReferenceArrayArray = null;

            bool continueLoop = true;

            while (continueLoop)
            {
                string commandActionCurrent = dataRowCurrent[2].ToString();
                string commandObjectCurrent = dataRowCurrent[3].ToString();
                string commandActionNext    = null;
                string commandObjectNext    = null;
                if (!endOfFileCondition)
                {
                    commandActionNext = dataRowNext[2].ToString();
                    commandObjectNext = dataRowNext[3].ToString();
                }

                // Branch based on array state and current action
                HbCurve            hbCurve            = null;
                List <HbXYZ>       listHbXyz          = null;
                GetHbEllipseValues getHbEllipseValues = null;
                List <string>      stringValues       = null;
                List <int>         intValues          = null;
                List <double>      doubleValues       = null;
                List <bool>        boolValues         = null;
                switch (arrayState)
                {
                case "":
                    switch (commandActionCurrent)
                    {
                    //TODO Not really checking any of the input for valid data here.  We should?
                    case "Add":
                        switch (commandObjectCurrent)
                        {
                        case "Level":
                            doubleValues = new List <double> {
                                Convert.ToDouble(dataRowCurrent[4].ToString(), this.provider)
                            };                                                                                                             // Level datum
                            stringValues = new List <string> {
                                dataRowCurrent[5].ToString()
                            };                                                                                              // Level Name (optional)
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, stringValues, null, doubleValues, null);
                            break;

                        case "Grid":
                            listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            if (listHbXyz.Count > 2)
                            {
                                hbCurve = new HbArc(listHbXyz[0], listHbXyz[1], listHbXyz[1]);
                            }
                            else
                            {
                                hbCurve = new HbLine(listHbXyz[0], listHbXyz[1]);
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "", hbCurve);
                            break;

                        case "DetailLine":
                        case "ModelLine":
                            listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            hbCurve   = new HbLine(listHbXyz[0], listHbXyz[1]);
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "DetailArc":
                        case "ModelArc":
                            listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            hbCurve   = new HbArc(listHbXyz[0], listHbXyz[1], listHbXyz[2]);
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "DetailEllipse":
                        case "ModelEllipse":
                            getHbEllipseValues = new GetHbEllipseValues(dataRowCurrent);
                            currentHbXyzList   = new List <HbXYZ>();
                            currentHbXyzList.Add(getHbEllipseValues.PointFirst);
                            currentHbXyzList.Add(getHbEllipseValues.PointSecond);
                            hbCurve = new HbEllipse(getHbEllipseValues.PointFirst, getHbEllipseValues.PointSecond, getHbEllipseValues.RadiusY, getHbEllipseValues.Mode);
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "DetailNurbSpline":
                        case "ModelNurbSpline":
                            if (currentHbXyzList != null)
                            {
                                listHbXyz = currentHbXyzList;
                            }
                            else
                            {
                                listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            }
                            hbCurve = new HbNurbSpline(listHbXyz);
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "AreaBoundaryLine":
                        case "RoomSeparationLine":
                            if (currentHbXyzList != null)
                            {
                                hbCurve = new HbNurbSpline(currentHbXyzList);
                            }
                            else
                            {
                                if (dataRowCurrent[7].ToString().ToLower() == "full" || dataRowCurrent[7].ToString().ToLower() == "half")
                                {
                                    getHbEllipseValues = new GetHbEllipseValues(dataRowCurrent);
                                    currentHbXyzList   = new List <HbXYZ>();
                                    currentHbXyzList.Add(getHbEllipseValues.PointFirst);
                                    currentHbXyzList.Add(getHbEllipseValues.PointSecond);
                                    hbCurve = new HbEllipse(getHbEllipseValues.PointFirst, getHbEllipseValues.PointSecond, getHbEllipseValues.RadiusY, getHbEllipseValues.Mode);
                                }
                                else
                                {
                                    listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                                    if (listHbXyz.Count == 2)
                                    {
                                        hbCurve = new HbLine(listHbXyz[0], listHbXyz[1]);
                                    }
                                    else
                                    {
                                        hbCurve = new HbArc(listHbXyz[0], listHbXyz[1], listHbXyz[2]);
                                    }
                                }
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "TopographySurface":
                        case "AdaptiveComponent":
                            if (currentHbXyzList != null)
                            {
                                listHbXyz = currentHbXyzList;
                            }
                            else
                            {
                                listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "", listHbXyz);
                            break;

                        case "Wall":
                            listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            if (listHbXyz.Count < 2)
                            {
                                break;
                            }
                            if (listHbXyz.Count == 2)
                            {
                                hbCurve = new HbLine(listHbXyz[0], listHbXyz[1]);
                            }
                            else
                            {
                                hbCurve = new HbArc(listHbXyz[0], listHbXyz[1], listHbXyz[2]);
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Curve", hbCurve);
                            break;

                        case "Floor":
                            if (currentHbXyzList != null)
                            {
                                listHbXyz = currentHbXyzList;                                        // Note that use group input of points is not documented but is a good option
                            }
                            else
                            {
                                listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "Points", listHbXyz);
                            break;

                        case "FamilyInstance":
                        case "Column":
                        case "Beam":
                        case "Area":
                        case "Room":
                            listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;              // Only one for family instance, area, and room; two with column and beam.
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "", listHbXyz);
                            break;

                        case "ReferencePoint":
                            HbReferencePoint hbReferencePoint = new GetHbReferencePoint(dataRowCurrent).HbReferencePoint;              // Only one point
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, hbReferencePoint, null, null);
                            break;

                        case "CurveByPoints":
                            HbReferenceArray hbReferenceArray = new HbReferenceArray();
                            //if (currentHbXyzList.Count != 0) listHbXyz = currentHbXyzList;  // Note that use single line input of points is not documented but is a good option
                            if (currentHbXyzList != null)
                            {
                                listHbXyz = currentHbXyzList;                                        // Note that use single line input of points is not documented but is a good option
                            }
                            else
                            {
                                listHbXyz = new GetHbXyzRow(dataRowCurrent).HbPoints;
                            }
                            foreach (HbXYZ hbXyz in listHbXyz)
                            {
                                hbReferenceArray.Add(new HbReferencePoint(hbXyz));
                            }
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, null, hbReferenceArray, null);
                            break;

                        //TODO Not handling this case for now.  It is not allowed in the specification and not sure how it got inot the sample data
                        //case "FamilyExtrusion":
                        ////    //csvWriter.AddFamilyExtrusion(curvesListList, "ExtrusionFamilyName", point11);
                        ////    //csvWriter.AddFamilyExtrusion(curvesListList, "ExtrusionFamilyName");
                        ////    //csvWriter.AddFamilyExtrusion(curvesListList, point11);
                        ////    //csvWriter.AddFamilyExtrusion(curvesListList);

                        ////if (commandObjectCurrent == "FamilyExtrusion") {
                        ////    stringValues = new List<string> { dataRowCurrent[4].ToString() };           // Name
                        ////    listHbXyz = new List<HbXYZ>();
                        ////    listHbXyz.Add(new GetHbValue(dataRowCurrent[5].ToString()).AsHbXYZ());      // Insertion point optional (function will return null)
                        ////    AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, listHbXyz, null, currentHbCurveArrayArray, null, null, null, stringValues, null, null, null);
                        //break;
                        default:
                            MessageBox.Show("Program error: Unknown 'CommandObject' in HummingbirdUtility.GetNextInputItem: " + commandObjectCurrent);
                            break;
                        }
                        currentHbXyzList = null;         // reset for next use loop or other use
                        //inputItem.DataRowPrimary = dataRowCurrent;
                        continueLoop = false;
                        break;

                    case "Draw":          // Implicit that action is CurveArray
                        currentHbCurveArrayArray = new HbCurveArrArray();
                        arrayState = "InCurveArrArray";
                        break;

                    case "Model":
                        arrayState = "InReferenceArrayArray";
                        break;

                    case "Use":
                        returnValue = ProcessUse(dataTable, ref dataTableIndex, out currentHbXyzList);
                        if (returnValue != "")
                        {
                            return(returnValue);
                        }
                        break;

                    case "Set":
                        switch (commandObjectCurrent)
                        {
                        case "WallType":
                        case "FloorType":
                        case "Level":
                        case "BeamJustification":
                        case "FilledRegionType":
                            stringValues = new List <string> {
                                dataRowCurrent[4].ToString()
                            };
                            break;

                        case "FamilyType":
                        case "BeamType":
                        case "AdaptiveComponentType":
                        case "MullionType":
                            stringValues = new List <string> {
                                dataRowCurrent[4].ToString(), dataRowCurrent[5].ToString()
                            };
                            break;

                        case "ColumnMode":
                            stringValues = new List <string> {
                                dataRowCurrent[4].ToString(), dataRowCurrent[5].ToString(), dataRowCurrent[6].ToString()
                            };
                            break;

                        case "WallHeight":
                        case "FamilyRotation":
                        case "ColumnHeight":
                        case "ColumnRotation":
                        case "BeamRotation":
                        case "FamilyExtrusionHeight":
                            doubleValues = new List <double> {
                                Convert.ToDouble(dataRowCurrent[4].ToString(), this.provider)
                            };
                            break;

                        case "FamilyMirrored":
                        case "FamilyFlipped":
                            boolValues = new List <bool> {
                                Convert.ToBoolean(dataRowCurrent[4].ToString()), Convert.ToBoolean(dataRowCurrent[5].ToString())
                            };
                            break;

                        default:
                            MessageBox.Show("Program error: Unknown 'CommandObject'.");
                            break;
                        }
                        AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, stringValues, intValues, doubleValues, boolValues);
                        continueLoop = false;
                        //inputItem.DataRowPrimary = dataRowCurrent;
                        break;

                    case "Modify":
                        switch (commandObjectCurrent)
                        {
                        case  "ParameterSet":
                            stringValues = new List <string> {
                                dataRowCurrent[4].ToString(), dataRowCurrent[5].ToString()
                            };                                                                                                           // Note that second item is kept as string until we actually set the parameter
                            break;

                        case  "CurtainGridUAdd":
                        case  "CurtainGridVAdd":
                        case  "MullionUAdd":
                        case  "MullionVAdd":
                            if (dataRowCurrent[5].ToString() == "" || dataRowCurrent[5].ToString() == null)
                            {
                                doubleValues = new List <double> {
                                    Convert.ToDouble(dataRowCurrent[4].ToString(), this.provider)
                                }
                            }
                            ;
                            else
                            {
                                doubleValues = new List <double> {
                                    Convert.ToDouble(dataRowCurrent[4].ToString()), Convert.ToDouble(dataRowCurrent[5].ToString(), this.provider)
                                }
                            };
                            break;

                        default:
                            MessageBox.Show("Program error: Unknown 'CommandObject'.");
                            break;
                        }
                        AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, stringValues, intValues, doubleValues, boolValues);
                        //inputItem.DataRowPrimary = dataRowCurrent;
                        continueLoop = false;
                        break;

                    default:
                        MessageBox.Show("Program error: Unknown 'actionValue'.");
                        break;
                    }
                    break;

                case "InCurveArrArray":
                    switch (commandActionCurrent)
                    {
                    // Valid cases
                    case "Add":
                        if (commandObjectCurrent == "FamilyExtrusion")
                        {
                            stringValues = new List <string> {
                                dataRowCurrent[4].ToString()
                            };                                                                                  // Name
                            HbXYZ insertionPoint = new GetHbValue(dataRowCurrent[5].ToString()).AsHbXYZ();      // Insertion point optional (function will return null)
                            if (insertionPoint == null)
                            {
                                listHbXyz = null;
                            }
                            else
                            {
                                listHbXyz = new List <HbXYZ>();
                                listHbXyz.Add(insertionPoint);
                            }
                            //listHbXyz = new List<HbXYZ>();
                            //listHbXyz.Add(new GetHbValue(dataRowCurrent[5].ToString()).AsHbXYZ());      // Insertion point optional (function will return null)
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, listHbXyz, null, currentHbCurveArrayArray, null, null, null, stringValues, null, null, null);
                        }
                        else            // Floor, Wall, AreaBoundaryLine etc. with curvearray
                        {
                            AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, "CurveArrArray", currentHbCurveArrayArray);
                        }
                        //inputItem.DataRowPrimary = dataRowCurrent;
                        continueLoop = false;
                        break;

                    case "Use":
                    case "Draw":
                        ProcessDraw(dataTable, ref dataTableIndex, out currentHbCurveArrayArray);
                        if (returnValue != "")
                        {
                            return(returnValue);
                        }
                        break;

                    // Error cases
                    case "Set":
                    case "Model":
                    case "Modify":
                        MessageBox.Show("Program error: '" + commandActionCurrent + "' value encountered during Curve Array.");
                        break;

                    default:
                        MessageBox.Show("Program error: Unknown 'actionValue'.");
                        break;
                    }
                    break;

                case "InReferenceArrayArray":
                    switch (commandActionCurrent)
                    {
                    // Valid cases
                    case "Add":
                        AddCommand(inputItem, commandActionCurrent, commandObjectCurrent, null, null, null, currentHbReferenceArrayArray);
                        //inputItem.DataRowPrimary = dataRowCurrent;
                        continueLoop = false;
                        break;

                    case "Use":
                        returnValue = ProcessModel(dataTable, ref dataTableIndex, out currentHbReferenceArrayArray);
                        if (returnValue != "")
                        {
                            return(returnValue);
                        }
                        break;

                    //Error cases
                    case "Set":
                    case "Model":          // Currently "Model will never occur; we are past the "Model - ReferenceArray" line at this point
                    case "Draw":
                    case "Modify":
                        MessageBox.Show("Program error: '" + commandActionCurrent + "' value encountered while in 'ReferenceArray' state.");
                        break;

                    default:
                        MessageBox.Show("Program error: Unknown 'actionValue'.");
                        break;
                    }
                    break;

                default:
                    return("Unknown arrayState: " + arrayState);
                }

                // Always do these actions at the end
                this.lastAction = commandActionCurrent;
                this.lastObject = commandObjectCurrent;

                // Increment index and get the next row if continuing loop.
                dataTableIndex++;
                if (continueLoop)
                {
                    if (dataTableIndex > dataTable.Rows.Count - 1)
                    {
                        return("Program error: End of file encountered.");
                    }
                    dataRowCurrent = this.dataTable.Rows[dataTableIndex];
                    if (dataTableIndex == dataTable.Rows.Count - 1)
                    {
                        endOfFileCondition = true;
                        dataRowNext        = null;
                    }
                    else
                    {
                        dataRowNext = this.dataTable.Rows[dataTableIndex + 1];
                    }
                }

                if (continueLoop == false)    // About to exit the loop so capture the current row
                {
                    inputItem.DataRowPrimary = dataRowCurrent;
                }
            }  //end loop

            // Set RowId based on last action
            inputItem.RowId = dataRowCurrent[0].ToString();

            // Set the ElementId based on the last Add
            if (!(this.lastAction == "Set" || this.lastAction == "Modify"))
            {
                inputItem.ElementId = new GetHbValue(dataRowCurrent[1].ToString()).AsHbElementId();
            }

            return("");
        }
示例#11
0
 // Full signature
 private bool AddCommand(HbInputItem inputItem, string commandAction, string commandObject, string commandModifier, List <HbXYZ> hbXyzList, HbCurve hbCurve, HbCurveArrArray hbCurveArrayArray,
                         HbReferencePoint hbReferencePoint, HbReferenceArray hbReferenceArray, HbReferenceArrayArray hbReferenceArrayArray, List <string> stringValues, List <int> intValues, List <double> doubleValues, List <bool> boolValues)
 {
     // Always required
     inputItem.CommandAction = commandAction;
     inputItem.CommandObject = commandObject;
     // Requirements depend on command; null values are OK
     inputItem.CommandModifier       = commandModifier;
     inputItem.ListHbXYZ             = hbXyzList;
     inputItem.HbCurve               = hbCurve;           // includes all Hb curves but not ReferencePoint
     inputItem.HbCurveArrArray       = hbCurveArrayArray; // includes HbCurveArray as single item
     inputItem.HbReferencePoint      = hbReferencePoint;
     inputItem.HbReferenceArray      = hbReferenceArray;
     inputItem.HbReferenceArrayArray = hbReferenceArrayArray;  // includes HbReferenceArray as single item
     inputItem.StringValues          = stringValues;
     inputItem.IntValues             = intValues;
     inputItem.DoubleValues          = doubleValues;
     inputItem.BoolValues            = boolValues;
     return(true);
 }
示例#12
0
 // Simple Curve (Line/Arc/Ellipse/NurbSpline/HermiteSpline)
 private bool AddCommand(HbInputItem inputItem, string commandAction, string commandObject, string commandModifier, HbCurve hbCurve)
 {
     return(AddCommand(inputItem, commandAction, commandObject, commandModifier, null, hbCurve, null, null, null, null, null, null, null, null));
 }
示例#13
0
 public void Add(HbCurve hbItem)
 {
     HbList.Add(hbItem);
 }
示例#14
0
 public static void Add(HbItemList list, HbCurve hbItem)
 {
     list.HbList.Add(hbItem);
 }
示例#15
0
 private bool ConvertHbCurve(HbCurve hbCurve, ref Curve curve)
 {
     try {
         curve = null;
         XYZ xyz1, xyz2, xyz3;
         if (hbCurve is HbLine)
         {
             HbLine hbLine = (HbLine)hbCurve;
             if (!ConvertHbXyz(hbLine.PointStart, out xyz1))
             {
                 return(false);
             }
             if (!ConvertHbXyz(hbLine.PointEnd, out xyz2))
             {
                 return(false);
             }
             curve = Line.CreateBound(xyz1, xyz2);
         }
         else if (hbCurve is HbArc)
         {
             HbArc hbArc = (HbArc)hbCurve;
             if (!ConvertHbXyz(hbArc.PointStart, out xyz1))
             {
                 return(false);
             }
             if (!ConvertHbXyz(hbArc.PointEnd, out xyz2))
             {
                 return(false);
             }
             if (!ConvertHbXyz(hbArc.PointMid, out xyz3))
             {
                 return(false);
             }
             curve = Arc.Create(xyz1, xyz2, xyz3);
         }
         else if (hbCurve is HbEllipse)
         {
             HbEllipse hbEllipse = (HbEllipse)hbCurve;
             if (!ConvertHbXyz(hbEllipse.PointFirst, out xyz1))
             {
                 return(false);
             }
             if (!ConvertHbXyz(hbEllipse.PointSecond, out xyz2))
             {
                 return(false);
             }
             XYZ    center, xVec, yVec;
             double radX, radY, param0, param1;
             CalculateEllipsePoints(xyz1, xyz2, hbEllipse.RadiusY, hbEllipse.Mode, out center, out radX, out radY, out xVec, out yVec, out param0, out param1);
             curve = Ellipse.CreateCurve(center, radX, radY, xVec, yVec, param0, param1);
             //curve = Ellipse.Create(center, radX, radY, xVec, yVec, param0, param1);  //2018 upgrade
         }
         else if (hbCurve is HbNurbSpline)
         {
             HbNurbSpline hbNurbSpline = (HbNurbSpline)hbCurve;
             List <XYZ>   points       = new List <XYZ>();
             foreach (HbXYZ point in hbNurbSpline.Points)
             {
                 if (!ConvertHbXyz(point, out xyz1))
                 {
                     return(false);
                 }
                 points.Add(xyz1);
             }
             List <double> weights = new List <double>();
             // Note that we are just using fixed weights for now.  It doesn't appear that Revit is actually using these values anyway.
             for (int i = 0; i < hbNurbSpline.Points.Count; i++)
             {
                 weights.Add(1.0);
             }
             //curve = NurbSpline.Create(points, weights);  // Fails if < 4 points although manually can create with 2 or 3 points.
             curve = NurbSpline.CreateCurve(points, weights);
             //TODO This failed in older versions if < 4 points although manually can create with 2 or 3 points.  Is this fixed in 2017?
         }
         else if (hbCurve is HbHermiteSpline)
         {
             HbHermiteSpline hbHermiteSpline = (HbHermiteSpline)hbCurve;
             List <XYZ>      points          = new List <XYZ>();
             foreach (HbXYZ point in hbHermiteSpline.Points)
             {
                 if (!ConvertHbXyz(point, out xyz1))
                 {
                     return(false);
                 }
                 points.Add(xyz1);
             }
             curve = HermiteSpline.Create(points, false);
         }
         return(true);
     }
     catch (Exception exception) {
         this.ErrorMessage = "Error in ConvertHbCurve: " + exception.Message + ".";
         curve             = null;
         return(false);
     }
 }
示例#16
0
 public List <HbCurve> AddToListHbItem(List <HbCurve> list, HbCurve item)
 {
     list.Add(item);
     return(list);
 }