CovertToAPI() public static method

Convert a value indicated by DisplayUnitType to the value used by RevitAPI
public static CovertToAPI ( double value, DisplayUnitType from ) : double
value double Value to be converted
from DisplayUnitType DisplayUnitType indicates the unit of the value to be converted
return double
Ejemplo n.º 1
0
        /// <summary>
        /// Transfer data back into data class
        /// </summary>
        private void SetData()
        {
            m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Unit);
            m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Unit);

            if (radioButton360.Checked)
            {
                m_data.StartDegree = 0;
                m_data.EndDegree   = 2 * Values.PI;
            }
            else
            {
                m_data.StartDegree = Convert.ToDouble(textBoxStartDegree.Text) * Values.DEGTORAD;
                m_data.EndDegree   = Convert.ToDouble(textBoxEndDegree.Text) * Values.DEGTORAD;
            }

            m_data.ArcNumber  = Convert.ToUInt32(textBoxArcNumber.Text);
            m_data.LineNumber = Convert.ToUInt32(textBoxLineNumber.Text);


            if (Convert.ToUInt32(textBoxArcNumber.Text) != 0)
            {
                m_data.ArcSpacing        = Unit.CovertToAPI(Convert.ToDouble(textBoxArcSpacing.Text), m_data.Unit);
                m_data.ArcFirstRadius    = Unit.CovertToAPI(Convert.ToDouble(textBoxArcFirstRadius.Text), m_data.Unit);
                m_data.ArcFirstBubbleLoc = (BubbleLocation)comboBoxArcBubbleLocation.SelectedIndex;
                m_data.ArcFirstLabel     = textBoxArcFirstLabel.Text;
            }

            if (Convert.ToUInt32(textBoxLineNumber.Text) != 0)
            {
                m_data.LineFirstDistance  = Unit.CovertToAPI(Convert.ToDouble(textBoxLineFirstDistance.Text), m_data.Unit);
                m_data.LineFirstBubbleLoc = (BubbleLocation)comboBoxLineBubbleLocation.SelectedIndex;
                m_data.LineFirstLabel     = textBoxLineFirstLabel.Text;
            }
        }
        /// <summary>
        /// Transfer data back into data class
        /// </summary>
        private void SetData()
        {
            m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Dut);
            m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Dut);
            m_data.XNumber = Convert.ToUInt32(textBoxXNumber.Text);
            m_data.YNumber = Convert.ToUInt32(textBoxYNumber.Text);

            if (Convert.ToUInt32(textBoxXNumber.Text) != 0)
            {
                m_data.XSpacing    = Unit.CovertToAPI(Convert.ToDouble(textBoxXSpacing.Text), m_data.Dut);
                m_data.XBubbleLoc  = (BubbleLocation)comboBoxXBubbleLocation.SelectedIndex;
                m_data.XFirstLabel = textBoxXFirstLabel.Text;
            }

            if (Convert.ToUInt32(textBoxYNumber.Text) != 0)
            {
                m_data.YSpacing    = Unit.CovertToAPI(Convert.ToDouble(textBoxYSpacing.Text), m_data.Dut);
                m_data.YBubbleLoc  = (BubbleLocation)comboBoxYBubbleLocation.SelectedIndex;
                m_data.YFirstLabel = textBoxYFirstLabel.Text;
            }
        }