Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize GUI with FormatData
 /// </summary>
 ///// <param name="dataBuffer">relevant data from revit</param>
 public FormatForm(Autodesk.Revit.DB.UnitType unittype, Autodesk.Revit.DB.FormatOptions formatoptions)
 {
     InitializeComponent();
     m_unittype                            = unittype;
     m_formatoptions                       = new Autodesk.Revit.DB.FormatOptions(formatoptions.DisplayUnits, formatoptions.UnitSymbol);
     m_formatoptions.UseDefault            = formatoptions.UseDefault;
     m_formatoptions.Accuracy              = formatoptions.Accuracy;
     m_formatoptions.SuppressTrailingZeros = formatoptions.SuppressTrailingZeros;
     m_formatoptions.SuppressLeadingZeros  = formatoptions.SuppressLeadingZeros;
     m_formatoptions.UsePlusPrefix         = formatoptions.UsePlusPrefix;
     m_formatoptions.UseDigitGrouping      = formatoptions.UseDigitGrouping;
     m_formatoptions.SuppressSpaces        = formatoptions.SuppressSpaces;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initialize GUI with FormatData
 /// </summary>
 ///// <param name="dataBuffer">relevant data from revit</param>
 public FormatForm(Autodesk.Revit.DB.ForgeTypeId specTypeId, Autodesk.Revit.DB.FormatOptions formatoptions)
 {
     InitializeComponent();
     m_specTypeId                          = specTypeId;
     m_formatoptions                       = new Autodesk.Revit.DB.FormatOptions(formatoptions.GetUnitTypeId(), formatoptions.GetSymbolTypeId());
     m_formatoptions.UseDefault            = formatoptions.UseDefault;
     m_formatoptions.Accuracy              = formatoptions.Accuracy;
     m_formatoptions.SuppressTrailingZeros = formatoptions.SuppressTrailingZeros;
     m_formatoptions.SuppressLeadingZeros  = formatoptions.SuppressLeadingZeros;
     m_formatoptions.UsePlusPrefix         = formatoptions.UsePlusPrefix;
     m_formatoptions.UseDigitGrouping      = formatoptions.UseDigitGrouping;
     m_formatoptions.SuppressSpaces        = formatoptions.SuppressSpaces;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initialize GUI with FormatData
 /// </summary>
 ///// <param name="dataBuffer">relevant data from revit</param>
 public FormatForm(ProjectUnitData dataBuffer, Autodesk.Revit.DB.FormatOptions formatoptions)
 {
     InitializeComponent();
     m_dataBuffer                          = dataBuffer;
     m_formatoptions                       = new Autodesk.Revit.DB.FormatOptions(formatoptions.UnitSymbol, formatoptions.DisplayUnits);
     m_formatoptions.UseDefault            = formatoptions.UseDefault;
     m_formatoptions.Accuracy              = formatoptions.Accuracy;
     m_formatoptions.SuppressTrailingZeros = formatoptions.SuppressTrailingZeros;
     m_formatoptions.SuppressLeadingZeros  = formatoptions.SuppressLeadingZeros;
     m_formatoptions.UsePlusPrefix         = formatoptions.UsePlusPrefix;
     m_formatoptions.UseGrouping           = formatoptions.UseGrouping;
     m_formatoptions.SuppressSpaces        = formatoptions.SuppressSpaces;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Add format which's discipline is the selected item of discipline combo box to the list
        /// </summary>
        /// <param name="format">the format to add</param>
        private void AddListItem(Autodesk.Revit.DB.FormatOptions format)
        {
            try
            {
                ListViewItem listitem = new ListViewItem();
                listitem.SubItems.AddRange(new String[] { format.Name,
                                                          format.Units.ToString(),
                                                          format.Unitsymbol.ToString(),
                                                          format.Rounding.ToString() });
                this.listView.Items.Add(listitem);
            }
            catch (Exception ex)
            {
                ListViewItem listitem = new ListViewItem();
                if (ex.TargetSite.Name == "get_Unitsymbol")
                {
                    try
                    {
                        listitem.SubItems.AddRange(new String[] { format.Name,
                                                                  format.Units.ToString(),
                                                                  "",
                                                                  format.Rounding.ToString() });
                    }
                    catch (System.Exception /*exx*/)
                    {
                        listitem.SubItems.AddRange(new String[] { format.Name,
                                                                  format.Units.ToString(),
                                                                  "",
                                                                  "" });
                    }
                }
                else
                {
                    listitem.SubItems.AddRange(new String[] { format.Name,
                                                              format.Units.ToString(),
                                                              format.Unitsymbol.ToString(),
                                                              "" });
                }

                this.listView.Items.Add(listitem);
            }
        }
Ejemplo n.º 6
0
        private string getDecimalSymbolAndGroupingstring()
        {
            Autodesk.Revit.DB.FormatValueOptions formatvalueoptions = new Autodesk.Revit.DB.FormatValueOptions();
            formatvalueoptions.AppendUnitSymbol = false;

            Autodesk.Revit.DB.FormatOptions formatoptions = new Autodesk.Revit.DB.FormatOptions(Autodesk.Revit.DB.UnitTypeId.Currency, new Autodesk.Revit.DB.ForgeTypeId());
            formatoptions.UseDefault = false;
            formatoptions.SetUnitTypeId(Autodesk.Revit.DB.UnitTypeId.Currency);
            formatoptions.SetSymbolTypeId(new Autodesk.Revit.DB.ForgeTypeId());
            formatoptions.Accuracy = 0.01;
            //formatoptions.SuppressLeadingZeros = true;
            formatoptions.SuppressSpaces        = false;
            formatoptions.SuppressTrailingZeros = false;
            formatoptions.UseDigitGrouping      = true;
            formatoptions.UsePlusPrefix         = false;

            formatvalueoptions.SetFormatOptions(formatoptions);

            return(Autodesk.Revit.DB.UnitFormatUtils.Format(m_units, Autodesk.Revit.DB.SpecTypeId.Number, 123456789.0, false, formatvalueoptions));
        }
Ejemplo n.º 7
0
        private string getDecimalSymbolAndGroupingstring()
        {
            Autodesk.Revit.DB.FormatValueOptions formatvalueoptions = new Autodesk.Revit.DB.FormatValueOptions();
            formatvalueoptions.AppendUnitSymbol = false;

            Autodesk.Revit.DB.FormatOptions formatoptions = new Autodesk.Revit.DB.FormatOptions(Autodesk.Revit.DB.UnitSymbolType.UST_NONE, Autodesk.Revit.DB.DisplayUnitType.DUT_CURRENCY);
            formatoptions.UseDefault   = false;
            formatoptions.DisplayUnits = Autodesk.Revit.DB.DisplayUnitType.DUT_CURRENCY;
            formatoptions.UnitSymbol   = Autodesk.Revit.DB.UnitSymbolType.UST_NONE;
            formatoptions.Accuracy     = 0.01;
            //formatoptions.SuppressLeadingZeros = true;
            formatoptions.SuppressSpaces        = false;
            formatoptions.SuppressTrailingZeros = false;
            formatoptions.UseGrouping           = true;
            formatoptions.UsePlusPrefix         = false;

            formatvalueoptions.SetFormatOptions(formatoptions);

            return(Autodesk.Revit.DB.UnitFormatUtils.FormatValueToString(this.m_dataBuffer.Units, Autodesk.Revit.DB.UnitType.UT_Number, 123456789.0, false, false, formatvalueoptions));
        }
Ejemplo n.º 8
0
 private void InternalSetFormatOptions(Autodesk.Revit.DB.FormatOptions options)
 {
     InternalFormatOptions   = options;
     InternalDisplayUnitType = options.DisplayUnits;
 }
Ejemplo n.º 9
0
        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);
        }