MakeLine() public static method

Create line element
public static MakeLine ( UIApplication app, Autodesk ptA, Autodesk ptB ) : ModelCurve
app UIApplication revit application
ptA Autodesk start point
ptB Autodesk end point
return ModelCurve
Example #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, "MakeRevolveForm");

            transaction.Start();

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

            Autodesk.Revit.DB.XYZ norm = Autodesk.Revit.DB.XYZ.BasisZ;

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

            ref_ar.Append(modelcurve.GeometryCurve.Reference);

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

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

            // Create axis for revolve form
            ptA = new Autodesk.Revit.DB.XYZ(-5, 0, 10);
            ptB = new Autodesk.Revit.DB.XYZ(-5, 10, 10);
            ModelCurve axis = FormUtils.MakeLine(commandData.Application, ptA, ptB, norm);

            axis.ChangeToReferenceLine();

            Autodesk.Revit.DB.FormArray form = doc.FamilyCreate.NewRevolveForms(true, ref_ar, axis.GeometryCurve.Reference, 0, Math.PI / 4);

            transaction.Commit();

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Example #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, "MakeExtrusionForm");

            transaction.Start();

            // Create one 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(90, 10, 0);
            ModelCurve            modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);

            ref_ar.Append(modelcurve.GeometryCurve.Reference);

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

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

            // The extrusion form direction
            Autodesk.Revit.DB.XYZ direction = new Autodesk.Revit.DB.XYZ(0, 0, 50);

            Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewExtrusionForm(true, ref_ar, direction);

            transaction.Commit();

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Example #3
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);
        }