Skip to content

Provides an extension method for UIDocument to allow users to pick two points in the Revit model using a RubberBand mechanism.

License

Notifications You must be signed in to change notification settings

SpeedCAD/SCADtools.Revit.UI.RubberBand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

SCADtools.Revit.UI.RubberBand

Provides an extension method for UIDocument to allow users to pick two points in the Revit model using a RubberBand mechanism.

🚀 Making

  • The DLL files are made using Visual Studio 2022. Compiled for Revit 2023 but easily adaptable to Revit 2024, 2025, or higher.

⌨️ Code example

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using SCADtools.Revit.UI.DB;
using SCADtools.Revit.UI.Extensions;
using System;

namespace Sample
{
    [Transaction(TransactionMode.Manual)]
    internal class RubberBandCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;
            View activeView = doc.ActiveView;

            try
            {
                XYZPair pickPoints = uidoc.PickPoints();
                if (pickPoints != null)
                {
                    using (Transaction tr = new Transaction(doc, "Detail Curve"))
                    {
                        tr.Start();

                        doc.Create.NewDetailCurve(activeView, Line.CreateBound(pickPoints.StartPoint, pickPoints.EndPoint));

                        tr.Commit();
                    }
                }

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
            finally
            {

            }
        }
    }
}

About

Provides an extension method for UIDocument to allow users to pick two points in the Revit model using a RubberBand mechanism.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages