コード例 #1
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);
     }
 }
コード例 #2
0
ファイル: Utility.cs プロジェクト: marioguttman/hummingbird
        // ************************************************ 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);
        }
コード例 #3
0
ファイル: Site.cs プロジェクト: marioguttman/hummingbird
        public bool CreateOneFamilyExtrusion(CsvWriter csvWriter, double segmentX, double segmentY, double elevation, double height, double currentX, double currentY)
        {
            HbXYZ point01 = new HbXYZ(currentX + segmentX * 1, currentY + segmentY * 2, elevation);
            HbXYZ point02 = new HbXYZ(currentX + segmentX * 3, currentY + segmentY * 2, elevation);
            HbXYZ point03 = new HbXYZ(currentX + segmentX * 4, currentY + segmentY * 0, elevation);
            HbXYZ point04 = new HbXYZ(currentX + segmentX * 5, currentY + segmentY * 2, elevation);
            HbXYZ point05 = new HbXYZ(currentX + segmentX * 7, currentY + segmentY * 2, elevation);
            HbXYZ point06 = new HbXYZ(currentX + segmentX * 7, currentY + segmentY * 3, elevation);
            HbXYZ point07 = new HbXYZ(currentX + segmentX * 8, currentY + segmentY * 4, elevation);
            HbXYZ point08 = new HbXYZ(currentX + segmentX * 7, currentY + segmentY * 5, elevation);
            HbXYZ point09 = new HbXYZ(currentX + segmentX * 7, currentY + segmentY * 6, elevation);
            HbXYZ point10 = new HbXYZ(currentX + segmentX * 5, currentY + segmentY * 7, elevation);
            HbXYZ point11 = new HbXYZ(currentX + segmentX * 4, currentY + segmentY * 6, elevation);
            HbXYZ point12 = new HbXYZ(currentX + segmentX * 3, currentY + segmentY * 7, elevation);
            HbXYZ point13 = new HbXYZ(currentX + segmentX * 1, currentY + segmentY * 6, elevation);
            HbXYZ point14 = new HbXYZ(currentX + segmentX * 1, currentY + segmentY * 5, elevation);
            HbXYZ point15 = new HbXYZ(currentX + segmentX * 0, currentY + segmentY * 4, elevation);
            HbXYZ point16 = new HbXYZ(currentX + segmentX * 1, currentY + segmentY * 3, elevation);

            HbXYZ point17 = new HbXYZ(currentX + segmentX * 2, currentY + segmentY * 4, elevation);
            HbXYZ point18 = new HbXYZ(currentX + segmentX * 6, currentY + segmentY * 4, elevation);

            HbXYZ point19 = new HbXYZ(currentX + segmentX * 1.0, currentY + segmentY * 3.5, elevation);
            HbXYZ point20 = new HbXYZ(currentX + segmentX * 0.5, currentY + segmentY * 4.0, elevation);
            HbXYZ point21 = new HbXYZ(currentX + segmentX * 1.0, currentY + segmentY * 4.5, elevation);
            HbXYZ point22 = new HbXYZ(currentX + segmentX * 1.5, currentY + segmentY * 4.0, elevation);

            HbXYZ point23 = new HbXYZ(currentX + segmentX * 7.0, currentY + segmentY * 3.5, elevation);
            HbXYZ point24 = new HbXYZ(currentX + segmentX * 6.5, currentY + segmentY * 4.0, elevation);
            HbXYZ point25 = new HbXYZ(currentX + segmentX * 7.0, currentY + segmentY * 4.5, elevation);
            HbXYZ point26 = new HbXYZ(currentX + segmentX * 7.5, currentY + segmentY * 4.0, elevation);

            List <List <HbCurve> > curvesCurvesList = new List <List <HbCurve> >();
            List <HbCurve>         curvesList;
            HbLine          line;
            HbArc           arc;
            HbNurbSpline    spline;
            HbEllipse       ellipse;
            HbHermiteSpline hermiteSpline;

            // Outer Loop
            curvesList    = new List <HbCurve>();
            spline        = new HbNurbSpline();
            spline.Points = new List <HbXYZ> {
                point01, point02, point03, point04, point05
            };
            curvesList.Add(spline);

            line = new HbLine(); line.PointStart = point05; line.PointEnd = point06;
            curvesList.Add(line);
            arc = new HbArc(); arc.PointStart = point06; arc.PointMid = point07; arc.PointEnd = point08;
            curvesList.Add(arc);
            line = new HbLine(); line.PointStart = point08; line.PointEnd = point09;
            curvesList.Add(line);

            hermiteSpline        = new HbHermiteSpline();
            hermiteSpline.Points = new List <HbXYZ> {
                point09, point10, point11, point12, point13
            };
            curvesList.Add(hermiteSpline);

            line = new HbLine(); line.PointStart = point13; line.PointEnd = point14;
            curvesList.Add(line);
            arc = new HbArc(); arc.PointStart = point14; arc.PointMid = point15; arc.PointEnd = point16;
            curvesList.Add(arc);
            line = new HbLine(); line.PointStart = point16; line.PointEnd = point01;
            curvesList.Add(line);
            curvesCurvesList.Add(curvesList);

            // Ellipse
            curvesList = new List <HbCurve>();
            ellipse    = new HbEllipse(); ellipse.PointFirst = point17; ellipse.PointSecond = point18; ellipse.RadiusY = segmentY; ellipse.Mode = "Full";
            curvesList.Add(ellipse);
            curvesCurvesList.Add(curvesList);

            // Circles
            curvesList = new List <HbCurve>();
            arc        = new HbArc(); arc.PointStart = point19; arc.PointMid = point20; arc.PointEnd = point21;
            curvesList.Add(arc);
            arc = new HbArc(); arc.PointStart = point21; arc.PointMid = point22; arc.PointEnd = point19;
            curvesList.Add(arc);
            curvesCurvesList.Add(curvesList);
            curvesList = new List <HbCurve>();
            arc        = new HbArc(); arc.PointStart = point23; arc.PointMid = point24; arc.PointEnd = point25;
            curvesList.Add(arc);
            arc = new HbArc(); arc.PointStart = point25; arc.PointMid = point26; arc.PointEnd = point23;
            curvesList.Add(arc);
            curvesCurvesList.Add(curvesList);

            // Extrusion
            csvWriter.SetFamilyExtrusionHeight(height);
            csvWriter.AddFamilyExtrusion(curvesCurvesList, "Bldg", new HbXYZ(0, 0, 0));

            return(true);
        }
コード例 #4
0
        // ------------------------------------------------------------ Conversion Utilities ---------------------------------------------------------------------

        private bool HbToRhino(Object hbObject, out List <Point3d> points, out Curve curve)
        {
            points = null;
            curve  = null;
            try {
                HbTypes hbType;
                if (hbTypeDictionary.TryGetValue(hbObject.GetType(), out hbType))
                {
                    switch (hbType)
                    {
                    case HbTypes.HbLine:
                        points = new List <Point3d>();
                        HbLine hbLine = (HbLine)hbObject;
                        points.Add(new Point3d(hbLine.PointStart.X, hbLine.PointStart.Y, hbLine.PointStart.Z));
                        points.Add(new Point3d(hbLine.PointEnd.X, hbLine.PointEnd.Y, hbLine.PointEnd.Z));
                        Line rhLine = new Line(points[0], points[1]);
                        curve = new LineCurve(rhLine);
                        break;

                    case HbTypes.HbArc:
                        points = new List <Point3d>();
                        HbArc hbArc = (HbArc)hbObject;
                        points.Add(new Point3d(hbArc.PointStart.X, hbArc.PointStart.Y, hbArc.PointStart.Z));
                        points.Add(new Point3d(hbArc.PointMid.X, hbArc.PointMid.Y, hbArc.PointMid.Z));
                        points.Add(new Point3d(hbArc.PointEnd.X, hbArc.PointEnd.Y, hbArc.PointEnd.Z));
                        curve = new ArcCurve(new Arc(points[0], points[1], points[2]));
                        break;

                    case HbTypes.HbEllipse:
                        //points = new List<Point3d>();
                        //HbEllipse hbEllipse = (HbEllipse)hbObject;
                        //HbXYZ hbXYZ1 = hbEllipse.PointFirst;
                        //HbXYZ hbXYZ2 = hbEllipse.PointSecond;
                        //points.Add(new Point3d(hbXYZ1.X, hbXYZ1.Y, hbXYZ1.Z));
                        //points.Add(new Point3d(hbXYZ1.X, hbXYZ1.Y, hbXYZ1.Z));
                        //double radiusY = hbEllipse.RadiusY;
                        //if (hbEllipse.Mode.ToLower() == "full") {
                        //    Ellipse ellipse = new Ellipse(
                        //}
                        //else {  // "half" case
                        //}
                        //TODO finish; requires some geometry

                        break;

                    case HbTypes.HbNurbSpline:
                        points = new List <Point3d>();
                        HbNurbSpline hbNurbSpline   = (HbNurbSpline)hbObject;
                        int          numberOfPoints = hbNurbSpline.Points.Count;

                        foreach (HbXYZ hbXYZ in hbNurbSpline.Points)
                        {
                            points.Add(new Point3d(hbXYZ.X, hbXYZ.Y, hbXYZ.Z));
                        }
                        curve = NurbsCurve.Create(false, 3, points);
                        break;

                    default:       // Ignore unknown cases

                        break;
                    }
                }
                return(true);
            }
            catch {
                return(false);
            }
        }
コード例 #5
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);
     }
 }
コード例 #6
0
        // ******************************************************** Private Functions ********************************************************
        private bool RunProcess()
        {
            Cursor.Current = Cursors.WaitCursor;
            try {
                CsvWriter csvWriter = new CsvWriter();

                // ********************************************************************************************************************************
                // ************************************* HummingbirdUtility Basic Function Signatures ***************************************
                // ********************************************************************************************************************************
                //
                // "Version" is a property of the ExcelWriter object.

                // Revit classes "XYZ", "Line", "Arc", "Ellipse", "NurbSpline", and "HermiteSpline" have corresponding classes in Hummingbird named
                // "HbXYZ", "HbLine", "HbArc", "HbEllipse", "HbNurbSpline", and "HbHermiteSpline" which derive from a parent class of "HbItem".
                // These have constructors:
                // HbXYZ(double x, double y, double z)
                // HbLine(HbXYZ pointStart, HbXYZ pointEnd)
                // HbArc(HbXYZ pointStart, HbXYZ pointEnd, HbXYZ pointMid)
                // HbEllipse(HbXYZ pointFirst, HbXYZ pointSecond, double radiusY, string mode)  radiusY is perpendicular to points; mode "Half" or "Full".
                // HbNurbSpline(List<HbXYZ> points)
                // HbHermiteSpline(List<HbXYZ> points)
                // (Note, these also have a default constructor with no parameters and properties that correspond to the parameters that must be set individually.)
                // They also have special functions specifically for use with Autodesk DesignScript
                // static HbXYZ New(double x, double y, double z)
                // static HbLine New(HbXYZ pointStart, HbXYZ pointEnd)
                // static HbArc New(HbXYZ pointStart, HbXYZ pointEnd, HbXYZ pointMid)
                // static HbEllipse New(HbXYZ pointFirst, HbXYZ pointSecond, double radiusY, string mode)  radiusY is perpendicular to points; mode "Half" or "Full".
                // static HbNurbSpline New(List<HbXYZ> points)
                // static HbHermiteSpline New(List<HbXYZ> points)
                // There are also some list functions that workaround the lack of a native "List" object in DesignScript
                // HbItemList()
                // static void Add(HbItemList list, HbItem hbItem)
                // HbItemListList()
                // static void Add(HbItemListList listList, HbItemList list)
                //
                // The following are methods of the ExcelWriter object.
                //
                // List of worksheet names:
                // List<string> GetWorksheetNames()
                //
                // Set Actions:
                // void SetLevel(string levelName)
                // void SetWallType(string wallTypeName)
                // void SetWallHeight(double height)
                // void SetFloorType(string floorTypeName)
                // void SetFamilyType(string familyName, string typeName)
                // void SetFamilyFlipped(bool flipHand, bool flipFacing)
                // void SetFamilyMirrored(bool mirrorX, bool mirrorY)
                // void SetFamilyRotation(double rotation)
                // void SetColumnMode(string mode, string familyName, string typeName)
                // void SetColumnHeight(double height)
                // void SetColumnRotation(double rotation)
                // void SetBeamType(string familyName, string typeName)
                // void SetBeamJustification(string justification) {
                // void SetBeamRotation(double rotation) {
                // void SetAdaptiveComponentType(string familyName, string typeName)
                // void SetFamilyExtrusionHeight(double height)
                // void SetMullionType(string familyName, string typeName)
                //
                // Add Actions:
                // void AddGrid(HbXYZ point1, HbXYZ point2)                  // Line case
                // void AddGrid(HbXYZ point1, HbXYZ point2, HbXYZ point3)    // Arc case (point1 = start; point2 = end; point3 = any point in arc.)
                // void AddLevel(double elevation, string name = null) {     // name is optional
                // void AddDetailLine(HbXYZ point1, HbXYZ point2)
                // void AddDetailArc(HbXYZ point1, HbXYZ point2, HbXYZ point3)
                // void AddDetailEllipse(HbXYZ point1, HbXYZ point2, double radiusY, string mode)
                // void AddDetailNurbsSpline(HbXYZ point1, HbXYZ point2, HbXYZ point3 = null, HbXYZ point4 = null) // points 3 and 4 are optional
                // void AddDetailNurbsSpline(List<HbXYZ> points)
                // void AddDetailCurves(List<HbItem> curves)
                // void AddModelLine(HbXYZ point1, HbXYZ point2)
                // void AddModelArc(HbXYZ point1, HbXYZ point2, HbXYZ point3)
                // void AddModelEllipse(HbXYZ point1, HbXYZ point2, double radiusY, string mode)
                // void AddModelNurbsSpline(HbXYZ point1, HbXYZ point2, HbXYZ point3 = null, HbXYZ point4 = null) // points 3 and 4 are optional
                // void AddModelNurbsSpline(List<HbXYZ> points)
                // void AddModelCurves(List<HbItem> curves)
                // void AddTopographySurface(HbXYZ point1, HbXYZ point2, HbXYZ point3, HbXYZ point4 = null) {
                // void AddTopographySurface(List<HbXYZ> points) {

                // void AddWall(HbXYZ point1, HbXYZ point2)                   // Straight line in plan.
                // void AddWall(HbXYZ point1, HbXYZ point2, HbXYZ point3)  // Arc in plan
                // void AddWall(List<HbItem> curvesList)                         // List of lines, arcs, ellipses, or splines in plan
                // void AddWall(List<List<HbItem>> curvesList)                   // List of Lists controls profile in elevation
                // void AddFloor(HbXYZ point1, HbXYZ point2, HbXYZ point3, HbXYZ point4)
                // void AddFloor(List<List<HbItem>> curvesList)
                // void AddFamilyInstance(HbXYZ point1)
                // void AddColumn(HbXYZ point1)
                // void AddColumn(HbXYZ point1, HbXYZ point2)
                // void AddBeam(HbXYZ point1, HbXYZ point2)
                // void AddAdaptiveComponent(HbXYZ point1, HbXYZ point2 = null, HbXYZ point3 = null, HbXYZ point4 = null)   // points 2, 3, and 4 are optional
                // void AddAdaptiveComponent(List<HbXYZ> points)
                // void AddAreaBoundaryLine(HbXYZ point1, HbXYZ point2)                                // Line case
                // void AddAreaBoundaryLine(HbXYZ point1, HbXYZ point2, HbXYZ point3)               // Arc case
                // void AddAreaBoundaryLine(HbXYZ point1, HbXYZ point2, double radiusY, string mode)   // Ellipse case
                // void AddAreaBoundaryLine(List<HbXYZ> points)                                           // Spline case
                // void AddAreaBoundaryLine(List<HbItem> curves)                                          // List of lines, arcs, ellipses, or splines in plan
                // void AddRoomSeparationLine(HbXYZ point1, HbXYZ point2)                              // Line case
                // void AddRoomSeparationLine(HbXYZ point1, HbXYZ point2, HbXYZ point3)             // Arc case
                // void AddRoomSeparationLine(HbXYZ point1, HbXYZ point2, double radiusY, string mode) // Ellipse case
                // void AddRoomSeparationLine(List<HbXYZ> points)                                         // Spline case
                // void AddRoomSeparationLine(List<HbItem> curves)                                        // List of lines, arcs, ellipses, or splines in plan
                // void AddArea(HbXYZ point1);
                // void AddRoom(HbXYZ point1);
                // void AddReferencePoint(HbXYZ point)
                // void AddCurveByPoints(List<HbXYZ> points)
                // void AddloftForm(List<List<HbXYZ>> points)
                // void AddFamilyExtrusion(List<List<HbItem>> curvesList, string nameFamily = null, HbXYZ pointInsert = null) {
                // void AddFamilyExtrusion(List<List<HbItem>> curvesList, HbXYZ pointInsert) {
                //
                // Modify Actions:
                // void ModifyParameterSet(string parameterName, string value)
                // void ModifyCurtainGridUAdd(double offsetPrimary);
                // void ModifyCurtainGridUAdd(double offsetPrimary, double offsetSecondary);
                // void ModifyCurtainGridVAdd(double offsetPrimary);
                // void ModifyCurtainGridVAdd(double offsetPrimary, double offsetSecondary);
                // void ModifyMullionUAdd(double offsetPrimary);
                // void ModifyMullionUAdd(double offsetPrimary, double offsetSecondary);
                // void ModifyMullionVAdd(double offsetPrimary);
                // void ModifyMullionVAdd(double offsetPrimary, double offsetSecondary);

                // ************************************************************************************************************************************
                // ************************************* RevitModelBuilderUtility Component Function Signatures ***************************************
                // ************************************************************************************************************************************
                //
                // Users will typically avoid using these in favor of the basic forms.  Provided here only for completeness
                //
                // Use-Add Actions:
                // void UsePoints(HbXYZ point1, HbXYZ point2 = null, HbXYZ point3 = null, HbXYZ point4 = null) { // points 2, 3, and 4 are optional
                // void UsePoints(List<HbXYZ> points) // General form of more than four points
                // void AddDetailNurbsSpline()  // Must follow UsePoints
                // void AddModelNurbsSpline()   // Must follow UsePoints
                // void AddAdaptiveComponent()  // Must follow UsePoints
                // void AddAreaBoundaryLine()   // Spline - Must follow UsePoints (Note: no simple form of spline is currently offered
                // void AddRoomSeparationLine() // Spline - Must follow UsePoints (Note: no simple form of spline is currently offered
                // void AddCurveByPoints()      // Must follow UsePoints
                // void AddTopographySurface()  // Must follow UsePoints
                //
                // Draw-Use-Add Actions:
                // (Also see UsePoints() above)
                // void DrawCurveArray()
                // void DrawLine(HbXYZ point1, HbXYZ point2)
                // void DrawArc(HbXYZ point1, HbXYZ point2, HbXYZ point3)
                // void AddWall()
                // void AddFloor()
                // void AddFamilyExtrusion(string nameFamily, HbXYZ pointInsert = null) {  // Must follow a Curve Array Set
                // void DrawCurveArray(List<HbItem> curves) {   // Combined form; curves must be HbItem type
                //
                // Model-Use-Add Actions:
                // (Also see UsePoints() above)
                // void ModelReferenceArray()  // Must be first statement
                // void AddLoftForm()          // Must follow ModelReferenceArray() and UsePoints()
                //

                // ****************************************************************************************************************
                // ******************************************* Start of Sample Code Section ***************************************
                // ****************************************************************************************************************
                //
                // This is the portion of the code that is typically emulated for a particular project use.

                // Sample Revit hb items and lists
                HbXYZ        point11 = new HbXYZ(0, 0, 0); HbXYZ point12 = new HbXYZ(10, 0, 0); HbXYZ point13 = new HbXYZ(20, 0, 0); HbXYZ point14 = new HbXYZ(15, 5, 0);
                HbXYZ        point21 = new HbXYZ(0, 10, 0); HbXYZ point22 = new HbXYZ(10, 10, 0); HbXYZ point23 = new HbXYZ(20, 10, 0); HbXYZ point24 = new HbXYZ(15, 15, 0);
                List <HbXYZ> pointsList1 = new List <HbXYZ>(); pointsList1.Add(point11); pointsList1.Add(point12); pointsList1.Add(point13); pointsList1.Add(point14);
                List <HbXYZ> pointsList2 = new List <HbXYZ>(); pointsList2.Add(point21); pointsList2.Add(point22); pointsList2.Add(point23); pointsList2.Add(point24);
                //List<HbXYZ> pointsList3 = new List<HbXYZ>(); pointsList3.Add(point21); pointsList3.Add(point22); pointsList3.Add(point23);
                //                                                   pointsList3.Add(point24); pointsList3.Add(point24); pointsList3.Add(point24);
                List <List <HbXYZ> > pointsListList = new List <List <HbXYZ> >(); pointsListList.Add(pointsList1); pointsListList.Add(pointsList2);
                HbLine       line1       = new HbLine(); line1.PointStart = point11; line1.PointEnd = point12;
                HbLine       line2       = new HbLine(); line2.PointStart = point21; line2.PointEnd = point22;
                HbArc        arc1        = new HbArc(); arc1.PointStart = point11; arc1.PointEnd = point12; arc1.PointMid = point13;
                HbArc        arc2        = new HbArc(); arc2.PointStart = point21; arc2.PointEnd = point22; arc2.PointMid = point23;
                HbNurbSpline nurbSpline1 = new HbNurbSpline(); nurbSpline1.Points.Add(point21); nurbSpline1.Points.Add(point12); nurbSpline1.Points.Add(point23);
                HbNurbSpline nurbSpline2 = new HbNurbSpline(); nurbSpline2.Points.Add(point11); nurbSpline2.Points.Add(point22); nurbSpline2.Points.Add(point13);
                HbNurbSpline nurbSpline3 = new HbNurbSpline(); nurbSpline3.Points.Add(point11); nurbSpline3.Points.Add(point22); nurbSpline3.Points.Add(point13);
                nurbSpline3.Points.Add(point11); nurbSpline3.Points.Add(point22); nurbSpline3.Points.Add(point13);
                List <HbCurve>         curvesList1    = new List <HbCurve>(); curvesList1.Add(line1); curvesList1.Add(arc1); curvesList1.Add(nurbSpline1);
                List <HbCurve>         curvesList2    = new List <HbCurve>(); curvesList2.Add(line2); curvesList2.Add(arc2); curvesList2.Add(nurbSpline3);
                List <List <HbCurve> > curvesListList = new List <List <HbCurve> >(); curvesListList.Add(curvesList1); curvesListList.Add(curvesList2);

                double levelElevation = 100;    //  for Level
                string levelName      = "A New Level";

                double radiusY = 10;   // for ellipse
                string mode    = "Full";

                double offsetPrimary   = 5; // for curtain gridds and mullions
                double offsetSecondary = 10;

                // Display the version
                MessageBox.Show("csvWriter.Version: " + csvWriter.Version);

                // Start .csv file
                textBoxCsvFolder.Text = textBoxCsvFolder.Text.Trim();
                if (!textBoxCsvFolder.Text.EndsWith(@"\"))
                {
                    textBoxCsvFolder.Text = textBoxCsvFolder.Text + @"\";
                }
                this.csvFolderPath      = textBoxCsvFolder.Text;
                textBoxCsvFileName.Text = textBoxCsvFileName.Text.Trim();
                if (!textBoxCsvFileName.Text.ToLower().EndsWith(".csv"))
                {
                    textBoxCsvFileName.Text = textBoxCsvFileName.Text + ".csv";
                }
                this.csvFileName = textBoxCsvFileName.Text;
                this.csvFilePath = this.csvFolderPath + this.csvFileName;
                string returnMMessage = csvWriter.ConnectToFile(this.csvFilePath);
                if (returnMMessage != "")
                {
                    MessageBox.Show(returnMMessage);
                    return(false);
                }

                // If checked, get ID values
                if (checkBoxPreserveId.Checked)
                {
                    // Note that if file doesn't exist yet we ignore option to preserve ID values
                    if (File.Exists(this.csvFilePath))
                    {
                        try {
                            string returnValue = csvWriter.ReadElementIds();
                            if (returnValue != "")
                            {
                                MessageBox.Show("csvWriter.ReadElementIds() failed: " + returnValue, PROGRAM_NAME);
                                return(false);
                            }
                        }
                        catch (Exception exception) {
                            MessageBox.Show("Exception in RunProcess() at csvWriter.ReadElementIds(): " + exception.Message, PROGRAM_NAME);
                            return(false);
                        }
                    }
                }

                // Set Actions:
                csvWriter.SetLevel("Level 1");
                csvWriter.SetWallType("WallTypeName");
                csvWriter.SetWallHeight(10);
                csvWriter.SetFloorType("FloorTypeName");
                csvWriter.SetFamilyType("FamilyFamilyName", "FamilyTypeName");
                csvWriter.SetFamilyFlipped(true, false);
                csvWriter.SetFamilyMirrored(false, true);
                csvWriter.SetFamilyRotation(45);
                csvWriter.SetColumnMode("Architectural", "ColumnFamilyName", "ColumnTypeName");
                csvWriter.SetColumnHeight(10);
                csvWriter.SetColumnRotation(45);
                csvWriter.SetBeamType("BeamFamilyName", "BeamTypeName");
                csvWriter.SetBeamJustification("Top");
                csvWriter.SetBeamRotation(45);
                csvWriter.SetAdaptiveComponentType("ACompFamilyName", "ACompTypeName");
                csvWriter.SetFamilyExtrusionHeight(40);
                csvWriter.SetMullionType("AMullionFamilyName", "AMullionTypeName");
                //
                // Add Actions:
                csvWriter.AddGrid(point11, point12);          // Line case
                csvWriter.AddGrid(point11, point12, point13); // Arc case
                levelElevation = 100;                         //  for Level
                csvWriter.AddLevel(levelElevation, levelName);
                csvWriter.AddLevel(levelElevation);           // name is optional
                csvWriter.AddDetailLine(point11, point12);
                csvWriter.AddDetailArc(point11, point12, point13);
                csvWriter.AddDetailEllipse(point11, point12, radiusY, mode);
                csvWriter.AddDetailNurbsSpline(point11, point12, point13, point14);
                csvWriter.AddDetailNurbsSpline(pointsList1);
                csvWriter.AddDetailCurves(curvesList1);
                csvWriter.AddDetailCurves(curvesList2);
                csvWriter.AddModelLine(point11, point12);
                csvWriter.AddModelArc(point11, point12, point13);
                csvWriter.AddModelEllipse(point11, point12, radiusY, mode);
                csvWriter.AddModelNurbsSpline(point11, point12);   // points 3 and 4 are optional
                csvWriter.AddModelNurbsSpline(point11, point12, point13);
                csvWriter.AddModelNurbsSpline(point11, point12, point13, point14);
                csvWriter.AddModelNurbsSpline(pointsList1);
                csvWriter.AddModelCurves(curvesList1);
                csvWriter.AddTopographySurface(point11, point12, point13);
                csvWriter.AddTopographySurface(point11, point12, point13, point14);
                csvWriter.AddTopographySurface(pointsList1);
                csvWriter.AddWall(point11, point12);
                csvWriter.AddWall(point11, point12, point13);
                csvWriter.AddWall(curvesList1);     // Plan list
                csvWriter.AddWall(curvesListList);  // Profile list of lists
                csvWriter.AddFloor(point11, point12, point13, point14);
                csvWriter.AddFloor(curvesListList);
                csvWriter.AddFamilyInstance(point11);
                csvWriter.AddColumn(point11);
                csvWriter.AddColumn(point11, point12);
                csvWriter.AddBeam(point11, point12);
                csvWriter.AddAdaptiveComponent(point11);  // points 2, 3, and 4 are optional
                csvWriter.AddAdaptiveComponent(point11, point12);
                csvWriter.AddAdaptiveComponent(point11, point12, point13);
                csvWriter.AddAdaptiveComponent(point11, point12, point13, point14);
                csvWriter.AddAdaptiveComponent(pointsList1);
                csvWriter.AddAreaBoundaryLine(point11, point12);                  // Line case
                csvWriter.AddAreaBoundaryLine(point11, point12, point13);         // Arc case
                csvWriter.AddAreaBoundaryLine(point11, point12, radiusY, mode);   // Ellipse case
                csvWriter.AddAreaBoundaryLine(pointsList1);                       // Spline case
                csvWriter.AddAreaBoundaryLine(curvesList1);                       // List of lines, arcs, ellipses, or splines in plan
                csvWriter.AddRoomSeparationLine(point11, point12);                // Line case
                csvWriter.AddRoomSeparationLine(point11, point12, point13);       // Arc case
                csvWriter.AddRoomSeparationLine(point11, point12, radiusY, mode); // Ellipse case
                csvWriter.AddRoomSeparationLine(pointsList1);                     // Spline case
                csvWriter.AddRoomSeparationLine(curvesList1);                     // List of lines, arcs, ellipses, or splines in plan
                csvWriter.AddArea(point11);
                csvWriter.AddRoom(point11);
                csvWriter.AddReferencePoint(point11);
                csvWriter.AddCurveByPoints(pointsList1);
                csvWriter.AddLoftForm(pointsListList);
                ////TODO Not handling this case for now.  It is not allowed in the specification and not sure how it got inot the sample data
                //csvWriter.AddFamilyExtrusion(curvesListList, "ExtrusionFamilyName", point11);
                //csvWriter.AddFamilyExtrusion(curvesListList, "ExtrusionFamilyName");
                //csvWriter.AddFamilyExtrusion(curvesListList, point11);
                //csvWriter.AddFamilyExtrusion(curvesListList);
                //
                // Modify Actions:
                csvWriter.ModifyParameterSet("ParameterName", "Value");
                csvWriter.ModifyCurtainGridUAdd(offsetPrimary);
                csvWriter.ModifyCurtainGridUAdd(offsetPrimary, offsetSecondary);
                csvWriter.ModifyCurtainGridVAdd(offsetPrimary);
                csvWriter.ModifyCurtainGridVAdd(offsetPrimary, offsetSecondary);
                csvWriter.ModifyMullionUAdd(offsetPrimary);
                csvWriter.ModifyMullionUAdd(offsetPrimary, offsetSecondary);
                csvWriter.ModifyMullionVAdd(offsetPrimary);
                csvWriter.ModifyMullionVAdd(offsetPrimary, offsetSecondary);

                // These commands can also be used but it is proably better to try to use one of the more compact forms above.

                // Use-Add Actions:
                csvWriter.UsePoints(point11, point12, point13, point14);
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddDetailNurbsSpline();
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddModelNurbsSpline();
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddAdaptiveComponent();
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddAreaBoundaryLine();   // Spline - Must follow UsePoints (Note: no simple form of spline is currently offered
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddRoomSeparationLine(); // Spline - Must follow UsePoints (Note: no simple form of spline is currently offered
                csvWriter.UsePoints(pointsList1);
                csvWriter.AddCurveByPoints();

                // Draw-Use-Add Actions:
                csvWriter.DrawCurveArray();          //This is non-combined form
                csvWriter.DrawLine(point11, point12);
                csvWriter.DrawArc(point11, point12, point13);
                csvWriter.AddWall();
                csvWriter.DrawCurveArray();
                csvWriter.DrawLine(point11, point12);
                csvWriter.DrawArc(point11, point12, point13);
                csvWriter.AddFloor();
                csvWriter.DrawCurveArray();
                csvWriter.DrawLine(point11, point12);
                csvWriter.DrawArc(point11, point12, point13);
                csvWriter.AddFamilyExtrusion("ExtrusionFamilyName", point11);
                csvWriter.DrawCurveArray();
                csvWriter.DrawLine(point11, point12);
                csvWriter.DrawArc(point11, point12, point13);
                csvWriter.AddFamilyExtrusion("ExtrusionFamilyName");
                csvWriter.DrawCurveArray(curvesList1);  //This is combined form
                csvWriter.AddFamilyExtrusion();

                // Model-Use-Add Actions:
                // (These examples are not complete)
                csvWriter.ModelReferenceArray();
                csvWriter.AddLoftForm();

                //  Write the file
                csvWriter.WriteFile();


                // ****************************************************************************************************************
                // ******************************************** End of Sample Code Section ****************************************
                // ****************************************************************************************************************

                MessageBox.Show("Process Completed", PROGRAM_NAME);

                return(true);
            }
            catch (Exception exception) {
                MessageBox.Show("Error in 'RunProcess()'.\nSystem message: " + exception.Message, PROGRAM_NAME);
                return(false);
            }
            finally {
                Cursor.Current = Cursors.Default;
            }
        }