private void InitFormatOptions(Autodesk.Revit.DB.DisplayUnitType dut) { var doc = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(doc); var fo = new Autodesk.Revit.DB.FormatOptions(dut); InternalSetFormatOptions(fo); TransactionManager.Instance.TransactionTaskDone(); }
private void InternalSetFormatOptions(Autodesk.Revit.DB.FormatOptions options) { InternalFormatOptions = options; InternalDisplayUnitType = options.DisplayUnits; }
public FormatOptions(Autodesk.Revit.DB.DisplayUnitType dut) { InitFormatOptions(dut); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Autodesk.Revit.DB.DisplayUnitType type = (Autodesk.Revit.DB.DisplayUnitType)value; return(type.ToString()); }
public System.Collections.IList GetDataSource(string key, Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.DisplayUnitType unitType) { return(null); }
internal static double GetRevitUnitScale() { // Default units is assumed to be meters unless double scale = 1.0; // Check the assemblies for the RevitAPI library Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); if (assemblies.Any(x => x.FullName.Contains("RevitServices"))) { // Get the RevitAPI assembly foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name == "RevitServices") { Autodesk.Revit.DB.Document doc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument; Autodesk.Revit.DB.Units units = doc.GetUnits(); Autodesk.Revit.DB.FormatOptions fo = units.GetFormatOptions(Autodesk.Revit.DB.UnitType.UT_Length); Autodesk.Revit.DB.DisplayUnitType dut = fo.DisplayUnits; switch (dut) { case Autodesk.Revit.DB.DisplayUnitType.DUT_CENTIMETERS: scale = 100; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_DECIMAL_FEET: scale = 3.28084; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_DECIMAL_INCHES: scale = 39.3701; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_DECIMETERS: scale = 10; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES: scale = 3.28084; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_FRACTIONAL_INCHES: scale = 39.3701; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_MILLIMETERS: scale = 1000; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_METERS: scale = 1.0; break; case Autodesk.Revit.DB.DisplayUnitType.DUT_METERS_CENTIMETERS: scale = 1.0; break; default: scale = 1.0; break; } } } } else { scale = 3.14; } return(scale); }