Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I created a quick-and-dirty Add-in that needs the user to input a distance. However, there doesn't seem to be a ready-made input function in revit - only single-point input (or box). I'm looking for something similar to AutoLISP's getdist or getpoint (that would show a line from the first point as the user is inputting the second point)? Code is below.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; namespace MeasSchedRowHt { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class Class1 : IExternalCommand { static double ScheduleRowHeightToTextSizeRatio = 0.521725; // for Arial // ~48/100" row height gives 1/4" text (64/256") Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //Get application and document objects UIApplication uiapp = commandData.Application; Document doc = uiapp.ActiveUIDocument.Document; View view = doc.ActiveView; try { //User picks 2 corners Selection sel = uiapp.ActiveUIDocument.Selection; XYZ point1 = sel.PickPoint("Please pick first point to measure from"); XYZ point2 = sel.PickPoint("Please pick second point to measure to"); //calculate distance between points double distFEET = point1.DistanceTo(point2); double textHeightINCHES = distFEET * 12.0 * ScheduleRowHeightToTextSizeRatio; double textHeight256ths = textHeightINCHES * 256.0; // assume the text height will be less than 1" TaskDialog.Show("Measure Schedule Row Height", "Measured (desired) Schedule Row Height: " + distFEET + " (feet or metric)\r\n" + "\r\n" + "Arial Text Height to use for Spacer Column: " + distFEET * ScheduleRowHeightToTextSizeRatio + " (if metric)\r\n" + "\r\n" + "\r\n" + "Measured (desired) Schedule Row Height: " + distFEET * 12.0 + " (inches, if applicable)\r\n" + "\r\n" + "Arial Text Height to use for Spacer Column: \r\n" + "\t" + textHeightINCHES + " (inches)\r\n" + "\t" + textHeight256ths.ToString("0.0") + "/256\""); // gives 0.0/256" } //If the user right-clicks or presses Esc, handle the exception catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return Result.Cancelled; } //Catch other errors catch (Exception ex) { message = ex.Message; return Result.Failed; } return Result.Succeeded; } } }
Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional
Solved! Go to Solution.