Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="revit">The revit application.</param>
        public STLExportForm(Autodesk.Revit.UI.UIApplication revit)
        {
            InitializeComponent();
            m_Revit = revit;

            // get new data generator
            m_Generator = new DataGenerator(m_Revit.Application, m_Revit.ActiveUIDocument.Document, m_Revit.ActiveUIDocument.Document.ActiveView);

            // scan for categories to populate category list
            m_CategoryList = m_Generator.ScanCategories(true);

            foreach (Category category in m_CategoryList.Values)
            {
                TreeNode treeNode = GetChildNode(category, m_Revit.ActiveUIDocument.Document.ActiveView);
                if (treeNode != null)
                {
                    tvCategories.Nodes.Add(treeNode);
                }
            }

            string unitName = "Use Internal: Feet";

            m_DisplayUnits.Add(unitName, new ForgeTypeId());
            int selectedIndex = comboBox_DUT.Items.Add(unitName);

            if (m_SelectedDUT.Empty())
            {
                comboBox_DUT.SelectedIndex = selectedIndex;
            }

            Units       currentUnits = m_Revit.ActiveUIDocument.Document.GetUnits();
            ForgeTypeId currentDut   = currentUnits.GetFormatOptions(SpecTypeId.Length).GetUnitTypeId();

            unitName = "Use Current: " + LabelUtils.GetLabelForUnit(currentDut);
            m_DisplayUnits.Add(unitName, currentDut);
            selectedIndex = comboBox_DUT.Items.Add(unitName);
            if (m_SelectedDUT == currentDut)
            {
                comboBox_DUT.SelectedIndex = selectedIndex;
            }

            foreach (ForgeTypeId dut in UnitUtils.GetValidUnits(SpecTypeId.Length))
            {
                if (currentDut == dut)
                {
                    continue;
                }
                unitName = LabelUtils.GetLabelForUnit(dut);
                m_DisplayUnits.Add(unitName, dut);
                selectedIndex = comboBox_DUT.Items.Add(unitName);
                if (m_SelectedDUT == dut)
                {
                    comboBox_DUT.SelectedIndex = selectedIndex;
                }
            }

            // initialize the UI differently for Families
            if (revit.ActiveUIDocument.Document.IsFamilyDocument)
            {
                cbIncludeLinked.Enabled = false;
                tvCategories.Enabled    = false;
                btnCheckAll.Enabled     = false;
                btnCheckNone.Enabled    = false;
            }
        }