This class wraps RebarShapeDefinitionByArc.
Inheritance: RebarShapeDef
Exemplo n.º 1
0
        /// <summary>
        /// Present a dialog to customize a RebarShape.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createShapeButton_Click(object sender, EventArgs e)
        {
            // Make sure the name is not null or empty.
            if (string.IsNullOrEmpty(nameTextBox.Text.Trim()))
            {
                TaskDialog.Show("Revit", "Please give a name to create a rebar shape.");
                return;
            }

            // Make sure the input name is started with letter and
            // just contains letters, numbers and underlines.
            Regex regex = new Regex("^[a-zA-Z]\\w+$");

            if (!regex.IsMatch(nameTextBox.Text.Trim()))
            {
                TaskDialog.Show("Revit", "Please input the name starting with letter and just containing letters, numbers and underlines. String is " + nameTextBox.Text.ToString());
                nameTextBox.Focus();
                return;
            }

            // Create a RebarShapeDefinition.
            RebarShapeDef shapeDef = null;

            if (byArcradioButton.Checked)
            {
                // Create arc shape.
                RebarShapeDefinitionByArc     arcShapeDefinition = null;
                RebarShapeDefinitionByArcType arcType            = (RebarShapeDefinitionByArcType)Enum.Parse(typeof(RebarShapeDefinitionByArcType), arcTypecomboBox.Text);
                if (arcType != RebarShapeDefinitionByArcType.Spiral)
                {
                    arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, arcType);
                }
                else
                {
                    // Set default value for Spiral-Shape definition.
                    arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, 10.0, 3.0, 0, 0);
                }
                shapeDef = new RebarShapeDefByArc(arcShapeDefinition);
            }
            else if (bySegmentsradioButton.Checked)
            {
                // Create straight segments shape.
                int segmentCount = 0;
                if (int.TryParse(segmentCountTextBox.Text, out segmentCount) && segmentCount > 0)
                {
                    shapeDef = new RebarShapeDefBySegment(new RebarShapeDefinitionBySegments(m_rvtDoc, segmentCount));
                }
                else
                {
                    TaskDialog.Show("Revit", "Please input a valid positive integer as segments count.");
                    return;
                }
            }

            int startHookAngle = 0;
            int endHookAngle   = 0;
            RebarHookOrientation startHookOrientation = RebarHookOrientation.Left;
            RebarHookOrientation endHookOrientation   = RebarHookOrientation.Left;

            bool doCreate = false;

            using (NewRebarShapeForm form = new NewRebarShapeForm(m_rvtDoc, shapeDef))
            {
                // Present a form to customize the shape.
                if (DialogResult.OK == form.ShowDialog())
                {
                    doCreate = true;
                    if (form.NeedSetHooks)
                    {
                        // Set hooks for rebar shape.
                        startHookAngle       = form.StartHookAngle;
                        endHookAngle         = form.EndHookAngle;
                        startHookOrientation = form.StartHookOrientation;
                        endHookOrientation   = form.EndHookOrientation;
                    }
                }
            }

            if (doCreate)
            {
                // Create the RebarShape.
                RebarShape createdRebarShape = RebarShape.Create(m_rvtDoc, shapeDef.RebarshapeDefinition, null,
                                                                 RebarStyle.Standard, StirrupTieAttachmentType.InteriorFace,
                                                                 startHookAngle, startHookOrientation,
                                                                 endHookAngle, endHookOrientation,
                                                                 0);
                createdRebarShape.Name = nameTextBox.Text.Trim();

                // Add the created shape to the candidate list.
                m_rebarShapes.Add(createdRebarShape);
                m_shapesBinding.ResetBindings(false);
                shapesComboBox.SelectedItem = createdRebarShape;
            }
        }
Exemplo n.º 2
0
 public ConstraintOnArcShape(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 3
0
 public ConstraintArcLength(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 4
0
 public ConstraintRadius(RebarShapeDefByArc def)
     : base(def)
 {
     m_arcReferenceType = RebarShapeArcReferenceType.External;
 }
Exemplo n.º 5
0
 public ConstraintSagittaLength(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 6
0
 public ConstraintChordLength(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 7
0
 public ConstraintSagittaLength(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 8
0
 public ConstraintRadius(RebarShapeDefByArc def)
     : base(def)
 {
     m_arcReferenceType = RebarShapeArcReferenceType.External;
 }
Exemplo n.º 9
0
 public ConstraintOnArcShape(RebarShapeDefByArc def)
     : base(def)
 {
 }
Exemplo n.º 10
0
        /// <summary>
        /// Present a dialog to customize a RebarShape.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createShapeButton_Click(object sender, EventArgs e)
        {
            // Make sure the name is not null or empty.
            if(string.IsNullOrEmpty(nameTextBox.Text.Trim()))
            {
                MessageBox.Show("Please give a name to create a rebar shape.");
                return;
            }

            // Make sure the input name is started with letter and
            // just contains letters, numbers and underlines.
            Regex regex = new Regex("^[a-zA-Z]\\w+$");
            if(!regex.IsMatch(nameTextBox.Text.Trim()))
            {
                MessageBox.Show("Please input the name starting with letter and just containing letters, numbers and underlines. String is " + nameTextBox.Text.ToString());

                nameTextBox.Focus();
                return;
            }

            // Create a RebarShapeDefinition.
            RebarShapeDef shapeDef = null;

            if (byArcradioButton.Checked)
            {
                // Create arc shape.
                RebarShapeDefinitionByArc arcShapeDefinition = null;
                RebarShapeDefinitionByArcType arcType = (RebarShapeDefinitionByArcType)Enum.Parse(typeof(RebarShapeDefinitionByArcType), arcTypecomboBox.Text);
                if (arcType != RebarShapeDefinitionByArcType.Spiral)
                {
                    arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, arcType);
                }
                else
                {
                    // Set default value for Spiral-Shape definition.
                    arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, 10.0, 3.0, 0, 0);
                }
                shapeDef = new RebarShapeDefByArc(arcShapeDefinition);
            }
            else if (bySegmentsradioButton.Checked)
            {
                // Create straight segments shape.
                int segmentCount = 0;
                if (int.TryParse(segmentCountTextBox.Text, out segmentCount) && segmentCount > 0)
                {
                    shapeDef = new RebarShapeDefBySegment(new RebarShapeDefinitionBySegments(m_rvtDoc, segmentCount));
                }
                else
                {
                    MessageBox.Show("Please input a valid positive integer as segments count.");
                    return;
                }
            }

            int startHookAngle = 0;
            int endHookAngle = 0;
            RebarHookOrientation startHookOrientation = RebarHookOrientation.Left;
            RebarHookOrientation endHookOrientation = RebarHookOrientation.Left;

            bool doCreate = false;

            using (NewRebarShapeForm form = new NewRebarShapeForm(m_rvtDoc, shapeDef))
            {
                // Present a form to customize the shape.
                if (DialogResult.OK == form.ShowDialog())
                {
                    doCreate = true;
                    if (form.NeedSetHooks)
                    {
                        // Set hooks for rebar shape.
                        startHookAngle = form.StartHookAngle;
                        endHookAngle = form.EndHookAngle;
                        startHookOrientation = form.StartHookOrientation;
                        endHookOrientation = form.EndHookOrientation;
                    }
                }
            }

            if (doCreate)
            {
                // Create the RebarShape.
                RebarShape createdRebarShape = RebarShape.Create(m_rvtDoc, shapeDef.RebarshapeDefinition, null,
                    RebarStyle.Standard, StirrupTieAttachmentType.InteriorFace,
                    startHookAngle, startHookOrientation,
                    endHookAngle, endHookOrientation,
                    0);
                createdRebarShape.Name = nameTextBox.Text.Trim();

                // Add the created shape to the candidate list.
                m_rebarShapes.Add(createdRebarShape);
                m_shapesBinding.ResetBindings(false);
                shapesComboBox.SelectedItem = createdRebarShape;
            }
        }