Exemple #1
0
        Stream(ArrayList data, RebarShapeDefinition rebarShapeDef)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeDefinition)));

            data.Add(new Snoop.Data.Bool("Complete", rebarShapeDef.Complete)); // TBD: should be "IsComplete?"
            data.Add(new Snoop.Data.Bool("IsPlanar", rebarShapeDef.IsPlanar));

            // Get Parameters
            data.Add(new Snoop.Data.CategorySeparator("RebarShape Definition Segments"));
            data.Add(new Snoop.Data.Enumerable("Parameters", rebarShapeDef.GetParameters()));

            RebarShapeDefinitionByArc rebarShapeDefByArc = rebarShapeDef as RebarShapeDefinitionByArc;

            if (rebarShapeDefByArc != null)
            {
                Stream(data, rebarShapeDefByArc);
                return;
            }

            RebarShapeDefinitionBySegments rebarShapeDefBySegs = rebarShapeDef as RebarShapeDefinitionBySegments;

            if (rebarShapeDefBySegs != null)
            {
                Stream(data, rebarShapeDefBySegs);
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// Move and Scale the  created Rebar to specified box.
        /// </summary>
        private void LayoutRebar()
        {
            List <Autodesk.Revit.DB.XYZ> profilePoints = m_geometryData.OffsetPoints(0.1);

            Autodesk.Revit.DB.XYZ origin = profilePoints[0];
            Autodesk.Revit.DB.XYZ yVec   = profilePoints[1] - origin;
            Autodesk.Revit.DB.XYZ xVec   = profilePoints[3] - origin;

            RebarShapeDefinitionByArc arcDef =
                (m_createdRebar.Document.GetElement(m_createdRebar.RebarShapeId) as RebarShape).GetRebarShapeDefinition() as RebarShapeDefinitionByArc;

            if (arcDef != null && arcDef.Type == RebarShapeDefinitionByArcType.Spiral)
            {
                m_createdRebar.ScaleToBoxFor3D(origin, xVec, yVec, 10.0);
                m_createdRebar.Height             = m_geometryData.DrivingLength - 0.1;
                m_createdRebar.Pitch              = 0.1;
                m_createdRebar.BaseFinishingTurns = 3;
                m_createdRebar.TopFinishingTurns  = 3;
            }
            else
            {
                m_createdRebar.ScaleToBox(origin, xVec, yVec);
                double barSpacing = 0.1;
                int    barNum     = (int)(m_geometryData.DrivingLength / barSpacing);
                m_createdRebar.SetLayoutAsNumberWithSpacing(
                    barNum, barSpacing, true, true, true);
            }
        }
Exemple #3
0
        /// <summary>
        /// Get all the constraint types supported by RebarShapeDefinitionByArc.
        /// </summary>
        /// <returns>all the constraint types supported by RebarShapeDefinitionByArc</returns>
        public override List <Type> AllowedConstraintTypes()
        {
            RebarShapeDefinitionByArc definitionByArc = RebarshapeDefinition as RebarShapeDefinitionByArc;

            List <Type> allowedTypes = base.AllowedConstraintTypes();

            allowedTypes.Add(typeof(ConstraintRadius));
            allowedTypes.Add(typeof(ConstraintDiameter));
            allowedTypes.Add(typeof(ConstraintArcLength));
            allowedTypes.Add(typeof(ConstraintCircumference));
            allowedTypes.Add(typeof(ConstraintChordLength));
            allowedTypes.Add(typeof(ConstraintSagittaLength));

            return(allowedTypes);
        }
Exemple #4
0
        Stream(ArrayList data, RebarShapeDefinition rebarShapeDef)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeDefinition)));

            data.Add(new Snoop.Data.Bool("Complete", rebarShapeDef.Complete)); // TBD: should be "IsComplete?"

            RebarShapeDefinitionByArc rebarShapeDefByArc = rebarShapeDef as RebarShapeDefinitionByArc;

            if (rebarShapeDefByArc != null)
            {
                Stream(data, rebarShapeDefByArc);
                return;
            }

            RebarShapeDefinitionBySegments rebarShapeDefBySegs = rebarShapeDef as RebarShapeDefinitionBySegments;

            if (rebarShapeDefBySegs != null)
            {
                Stream(data, rebarShapeDefBySegs);
                return;
            }
        }
Exemple #5
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;
            }
        }
        private void Stream(ArrayList data, RebarShapeDefinitionByArc rebarShapeDefByArc)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeDefinitionByArc)));

             data.Add(new Snoop.Data.Object("Type", rebarShapeDefByArc.Type));
        }
Exemple #7
0
 public RebarShapeDefByArc(RebarShapeDefinitionByArc arcShapeDef)
     : base(arcShapeDef)
 {
 }
Exemple #8
0
        Stream(ArrayList data, RebarShapeDefinitionByArc rebarShapeDefByArc)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeDefinitionByArc)));

            data.Add(new Snoop.Data.Object("Type", rebarShapeDefByArc.Type));
        }
Exemple #9
0
 public RebarShapeDefByArc(RebarShapeDefinitionByArc arcShapeDef)
     : base(arcShapeDef)
 {
 }
Exemple #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;
            }
        }