This class is utility class for form creation.
예제 #1
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            ExternalCommandData cdata = commandData;

            Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
            app = commandData.Application.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            Transaction transaction = new Transaction(doc, "MakeLoftForm");

            transaction.Start();

            // Create profiles array
            ReferenceArrayArray ref_ar_ar = new ReferenceArrayArray();

            // Create first profile
            ReferenceArray ref_ar = new ReferenceArray();

            int y = 100;
            int x = 50;

            Autodesk.Revit.DB.XYZ ptA        = new Autodesk.Revit.DB.XYZ(-x, y, 0);
            Autodesk.Revit.DB.XYZ ptB        = new Autodesk.Revit.DB.XYZ(x, y, 0);
            Autodesk.Revit.DB.XYZ ptC        = new Autodesk.Revit.DB.XYZ(0, y + 10, 10);
            ModelCurve            modelcurve = FormUtils.MakeArc(commandData.Application, ptA, ptB, ptC);

            ref_ar.Append(modelcurve.GeometryCurve.Reference);
            ref_ar_ar.Append(ref_ar);


            // Create second profile
            ref_ar = new ReferenceArray();

            y          = 40;
            ptA        = new Autodesk.Revit.DB.XYZ(-x, y, 5);
            ptB        = new Autodesk.Revit.DB.XYZ(x, y, 5);
            ptC        = new Autodesk.Revit.DB.XYZ(0, y, 25);
            modelcurve = FormUtils.MakeArc(commandData.Application, ptA, ptB, ptC);
            ref_ar.Append(modelcurve.GeometryCurve.Reference);
            ref_ar_ar.Append(ref_ar);

            // Create third profile
            ref_ar = new ReferenceArray();

            y          = -20;
            ptA        = new Autodesk.Revit.DB.XYZ(-x, y, 0);
            ptB        = new Autodesk.Revit.DB.XYZ(x, y, 0);
            ptC        = new Autodesk.Revit.DB.XYZ(0, y, 15);
            modelcurve = FormUtils.MakeArc(commandData.Application, ptA, ptB, ptC);
            ref_ar.Append(modelcurve.GeometryCurve.Reference);
            ref_ar_ar.Append(ref_ar);

            // Create fourth profile
            ref_ar = new ReferenceArray();

            y          = -60;
            ptA        = new Autodesk.Revit.DB.XYZ(-x, y, 0);
            ptB        = new Autodesk.Revit.DB.XYZ(x, y, 0);
            ptC        = new Autodesk.Revit.DB.XYZ(0, y + 10, 20);
            modelcurve = FormUtils.MakeArc(commandData.Application, ptA, ptB, ptC);
            ref_ar.Append(modelcurve.GeometryCurve.Reference);
            ref_ar_ar.Append(ref_ar);
            ref_ar = new ReferenceArray();
            ref_ar_ar.Append(ref_ar);

            Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewLoftForm(true, ref_ar_ar);

            transaction.Commit();

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
예제 #2
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            ExternalCommandData cdata = commandData;

            Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
            app = commandData.Application.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            Transaction transaction = new Transaction(doc, "MakeSweptBlendForm");

            transaction.Start();

            // Create first profile
            ReferenceArray ref_ar = new ReferenceArray();

            Autodesk.Revit.DB.XYZ ptA        = new Autodesk.Revit.DB.XYZ(10, 10, 0);
            Autodesk.Revit.DB.XYZ ptB        = new Autodesk.Revit.DB.XYZ(50, 10, 0);
            ModelCurve            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);

            ref_ar.Append(modelcurve.GeometryCurve.Reference);

            ptA        = new Autodesk.Revit.DB.XYZ(50, 10, 0);
            ptB        = new Autodesk.Revit.DB.XYZ(10, 50, 0);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            ref_ar.Append(modelcurve.GeometryCurve.Reference);

            ptA        = new Autodesk.Revit.DB.XYZ(10, 50, 0);
            ptB        = new Autodesk.Revit.DB.XYZ(10, 10, 0);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            ref_ar.Append(modelcurve.GeometryCurve.Reference);

            // Create second profile
            ReferenceArray ref_ar2 = new ReferenceArray();

            ptA        = new Autodesk.Revit.DB.XYZ(10, 10, 90);
            ptB        = new Autodesk.Revit.DB.XYZ(80, 10, 90);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            ref_ar2.Append(modelcurve.GeometryCurve.Reference);

            ptA        = new Autodesk.Revit.DB.XYZ(80, 10, 90);
            ptB        = new Autodesk.Revit.DB.XYZ(10, 50, 90);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            ref_ar2.Append(modelcurve.GeometryCurve.Reference);

            ptA        = new Autodesk.Revit.DB.XYZ(10, 50, 90);
            ptB        = new Autodesk.Revit.DB.XYZ(10, 10, 90);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            ref_ar2.Append(modelcurve.GeometryCurve.Reference);

            // Add profiles
            ReferenceArrayArray profiles = new ReferenceArrayArray();

            profiles.Append(ref_ar);
            profiles.Append(ref_ar2);

            // Create path for swept blend form
            ReferenceArray path = new ReferenceArray();

            ptA        = new Autodesk.Revit.DB.XYZ(10, 10, 0);
            ptB        = new Autodesk.Revit.DB.XYZ(10, 10, 90);
            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
            path.Append(modelcurve.GeometryCurve.Reference);

            Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewSweptBlendForm(true, path, profiles);

            transaction.Commit();

            return(Autodesk.Revit.UI.Result.Succeeded);
        }