Exemplo n.º 1
0
        //This method saves the useraddributes into the outlineCurve
        private static GeometryLarge DrawAndSaveUserAttr(Brep brep, RhinoDoc doc, MaterialType mType, string mName)
        {
            ObjectAttributes attr = new ObjectAttributes();

            attr.SetUserString("Name", Enum.GetName(typeof(MaterialType), mType));
            List <Layer> layers = (from layer in doc.Layers
                                   where layer.Name == Enum.GetName(typeof(MaterialType), mType)
                                   select layer).ToList <Rhino.DocObjects.Layer>();


            if (layers.Count == 0 || (layers.Count == 1 && layers[0].IsDeleted))
            {
                attr.LayerIndex = createLayer(doc, mType);
            }
            else if (layers.Count == 1)
            {
                attr.LayerIndex = layers[0].LayerIndex;
                //layers[0].IsLocked = true;
                layers[0].CommitChanges();
            }
            else
            {
                RhinoApp.WriteLine("More than one layer with name Concrete excists. Remove one of them."); return(null);
            }

            GeometryLarge seg = new GeometryLarge(mType, mName, brep);

            attr.UserData.Add(seg);

            doc.Objects.AddBrep(brep, attr);

            return(seg);
        }
Exemplo n.º 2
0
        private void buttonAddConcreteGeometry_Click(object sender, EventArgs e)
        {
            ShowStressResults(false);

            GeometryLarge temp = CreateGeometryLarge.CreateGeometry(
                (MaterialType)Enum.Parse(typeof(MaterialType), comboBoxMaterialType.SelectedItem.ToString()),
                comboBoxMaterialGeom.SelectedItem.ToString());

            //return if the geometry couldnt be created.
            if (temp == null)
            {
                return;
            }

            dataGridView_GeometryLarge.Rows.Add(temp.Id, temp.Material.GetType() == typeof(SteelMaterial)
                ? "Steel" : "Concrete");


            _projectPlugIn.CurrentBeam.CrossSec.GeometryLargeIds.Add(temp.Id);
            temp.CrosecId = _projectPlugIn.CurrentBeam.CrossSec.Id;
            MaterialType type =
                (MaterialType)Enum.Parse(typeof(MaterialType), comboBoxMaterialType.SelectedItem.ToString());

            RhinoDoc.ActiveDoc.Views.Redraw();

            labelConcreteCover.Text = Math.Round(_projectPlugIn.CurrentBeam.CrossSec.ConcreteCover, 0).ToString();
        }
        protected override void OnDuplicate(Rhino.DocObjects.Custom.UserData source)
        {
            GeometryLarge src = source as GeometryLarge;

            if (src != null)
            {
                BaseBrep = src.BaseBrep;
            }
        }
Exemplo n.º 4
0
        private void dataGridView_Geometry_KeyDown(object sender, KeyEventArgs e)
        {
            DataGridView d = (DataGridView)sender;

            if (e.KeyData == Keys.Delete)
            {
                int    row      = d.SelectedCells[0].RowIndex;
                string material = (string)d.Rows[row].Cells[1].Value;
                int    no       = (int)d.Rows[row].Cells[0].Value;
                if (material == "Reinforcement")
                {
                    RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByUserString("infType", "Reinforcement", true);
                    foreach (RhinoObject rhinoObject in objs)
                    {
                        Rhino.DocObjects.Custom.UserDataList list = rhinoObject.Attributes.UserData;
                        Reinforcement tempReinf = list.Find(typeof(Reinforcement)) as Reinforcement;
                        if (tempReinf.Id == no)
                        {
                            list.Remove(tempReinf);
                            rhinoObject.Attributes.SetUserString("infType", null);
                            _projectPlugIn.CurrentBeam.CrossSec.ReinforementIds.Remove(no);

                            d.Rows.Remove(d.Rows[row]);
                            rhinoObject.Attributes.LayerIndex = 0;
                            rhinoObject.CommitChanges();
                        }
                    }
                }
                else
                {
                    RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByUserString("infType", "GeometryLarge", true);
                    foreach (RhinoObject rhinoObject in objs)
                    {
                        Rhino.DocObjects.Custom.UserDataList list = rhinoObject.Attributes.UserData;
                        GeometryLarge tempGeom = list.Find(typeof(GeometryLarge)) as GeometryLarge;
                        if (tempGeom.Id == no)
                        {
                            Layer l = RhinoDoc.ActiveDoc.Layers[rhinoObject.Attributes.LayerIndex];

                            l.IsLocked = false;
                            l.CommitChanges();
                            RhinoDoc.ActiveDoc.Objects.Delete(rhinoObject, true);
                            l.IsLocked = true;
                            l.CommitChanges();


                            list.Remove(tempGeom);
                            _projectPlugIn.CurrentBeam.CrossSec.GeometryLargeIds.Remove(no);
                            d.Rows.Remove(d.Rows[row]);
                        }
                    }
                }
            }

            labelConcreteCover.Text = Math.Round(_projectPlugIn.CurrentBeam.CrossSec.ConcreteCover, 0).ToString();
            RhinoDoc.ActiveDoc.Views.Redraw();
        }
Exemplo n.º 5
0
        private void dataGridView_Geometry_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView d = (DataGridView)sender;

            if (d.SelectedCells.Count == 0)
            {
                return;
            }
            int    row      = d.SelectedCells[0].RowIndex;
            string material = (string)d.Rows[row].Cells[1].Value;
            int    no       = (int)d.Rows[row].Cells[0].Value;

            if (material == "Reinforcement")
            {
                RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByUserString("infType", "Reinforcement", true);
                foreach (RhinoObject rhinoObject in objs)
                {
                    Rhino.DocObjects.Custom.UserDataList list = rhinoObject.Attributes.UserData;
                    Reinforcement tempReinf = list.Find(typeof(Reinforcement)) as Reinforcement;
                    if (tempReinf.Id == no)
                    {
                        tempReinf.Selected = true;
                        RhinoDoc.ActiveDoc.Views.Redraw();
                        return;
                    }
                }
            }
            else
            {
                RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByUserString("infType", "GeometryLarge", true);
                foreach (RhinoObject rhinoObject in objs)
                {
                    Rhino.DocObjects.Custom.UserDataList list = rhinoObject.Attributes.UserData;
                    GeometryLarge tempGeom = list.Find(typeof(GeometryLarge)) as GeometryLarge;
                    if (tempGeom.Id == no)
                    {
                        tempGeom.Selected = true;
                        RhinoDoc.ActiveDoc.Views.Redraw();
                        return;
                    }
                }
            }
            RhinoDoc.ActiveDoc.Views.Redraw();
        }
Exemplo n.º 6
0
        //this method draws the curves and saves the useraddributes into them
        private void DrawAndSaveUserAttr(List <Brep> breps, RhinoDoc doc, RhinoObject obj)
        {
            //TODO not a fully correctly implemented geometry large initialization
            GeometryLarge seg = new GeometryLarge(MaterialType.Concrete, "C30/37", breps[0]);

            foreach (Brep brep in breps)
            {
                seg.GeometrySegments.Add(new GeometrySegment(brep, seg.Material));
            }
            ObjectAttributes attr = new ObjectAttributes();

            attr.SetUserString("Name", "Concrete");
            List <Layer> layers = (from layer in doc.Layers
                                   where layer.Name == "Concrete"
                                   select layer).ToList <Rhino.DocObjects.Layer>();;


            if (layers.Count == 0 || (layers.Count == 1 && layers[0].IsDeleted))
            {
                Color color = Color.FromArgb(170, 170, 170);

                doc.Layers.Add("Concrete", color);
                int   index = doc.Layers.Find("Concrete", true);
                Layer layer = doc.Layers[index];
                //layer.IsLocked = true;
                attr.LayerIndex = index;
                layer.CommitChanges();
            }
            else if (layers.Count == 1)
            {
                attr.LayerIndex = layers[0].LayerIndex;
                //layers[0].IsLocked = true;
                layers[0].CommitChanges();
            }
            else
            {
                RhinoApp.WriteLine("More than one layer with name Concrete excists. Remove one of them."); return;
            }
            attr.UserData.Add(seg);

            doc.Objects.ModifyAttributes(obj, attr, true);
        }