Esempio n. 1
0
        private void areaButton_Click(object sender, EventArgs e)
        {
            AreaProperties ap = new AreaProperties();

            int count = 0;

            var blockReferenceNotScaled = true;

            for (int i = 0; i < model1.Entities.Count && blockReferenceNotScaled; i++)
            {
                Entity ent = model1.Entities[i];

                count += AddAreaProperty(ap, ent, out blockReferenceNotScaled);
            }

            StringBuilder text = new StringBuilder();

            if (blockReferenceNotScaled)
            {
                text.AppendLine(count + " entity(ies) selected");
                text.AppendLine("---------------------");

                if (ap.Centroid != null)
                {
                    double          x, y, z;
                    double          xx, yy, zz, xy, zx, yz;
                    MomentOfInertia world, centroid;

                    ap.GetResults(ap.Area, ap.Centroid, out x, out y, out z, out xx, out yy, out zz, out xy, out zx, out yz, out world, out centroid);

                    text.AppendLine("Cumulative area: " + ap.Area + " square " + model1.Units.ToString().ToLower());
                    text.AppendLine("Cumulative centroid: " + ap.Centroid);
                    text.AppendLine("Cumulative area moments:");
                    text.AppendLine(" First moments");
                    text.AppendLine("  x: " + x.ToString("g6"));
                    text.AppendLine("  y: " + y.ToString("g6"));
                    text.AppendLine("  z: " + z.ToString("g6"));
                    text.AppendLine(" Second moments");
                    text.AppendLine("  xx: " + xx.ToString("g6"));
                    text.AppendLine("  yy: " + yy.ToString("g6"));
                    text.AppendLine("  zz: " + zz.ToString("g6"));
                    text.AppendLine(" Product moments");
                    text.AppendLine("  xy: " + xx.ToString("g6"));
                    text.AppendLine("  yz: " + yy.ToString("g6"));
                    text.AppendLine("  zx: " + zz.ToString("g6"));
                    text.AppendLine(" Area Moments of Inertia about World Coordinate Axes");
                    text.AppendLine("  Ix: " + world.Ix.ToString("g6"));
                    text.AppendLine("  Iy: " + world.Iy.ToString("g6"));
                    text.AppendLine("  Iz: " + world.Iz.ToString("g6"));
                    text.AppendLine(" Area Radii of Gyration about World Coordinate Axes");
                    text.AppendLine("  Rx: " + world.Rx.ToString("g6"));
                    text.AppendLine("  Ry: " + world.Ry.ToString("g6"));
                    text.AppendLine("  Rz: " + world.Rz.ToString("g6"));
                    text.AppendLine(" Area Moments of Inertia about Centroid Coordinate Axes:");
                    text.AppendLine("  Ix: " + centroid.Ix.ToString("g6"));
                    text.AppendLine("  Iy: " + centroid.Iy.ToString("g6"));
                    text.AppendLine("  Iz: " + centroid.Iz.ToString("g6"));
                    text.AppendLine(" Area Radii of Gyration about Centroid Coordinate Axes");
                    text.AppendLine("  Rx: " + centroid.Rx.ToString("g6"));
                    text.AppendLine("  Ry: " + centroid.Ry.ToString("g6"));
                    text.AppendLine("  Rz: " + centroid.Rz.ToString("g6"));
                }
            }
            else
            {
                text.AppendLine("Error: scaled BlockReference is not supported.");

                text.AppendLine("---------------------");
            }

            DetailsForm rf = new DetailsForm();

            rf.Text = "Area Properties";

            rf.textBox1.Text = text.ToString();

            rf.Show();
        }
Esempio n. 2
0
        private void areaButton_OnClick(object sender, RoutedEventArgs e)
        {
            AreaProperties ap = new AreaProperties();

            int count = 0;

            for (int i = 0; i < model1.Entities.Count; i++)
            {
                Entity ent = model1.Entities[i];

                if (ent.Selected)
                {
                    ICurve itfCurve = (ICurve)ent;

                    if (itfCurve.IsClosed)
                    {
                        ap.Add(ent.Vertices);
                    }

                    count++;
                }
            }

            StringBuilder text = new StringBuilder();

            text.AppendLine(count + " entity(ies) selected");
            text.AppendLine("---------------------");

            if (ap.Centroid != null)
            {
                double          x, y, z;
                double          xx, yy, zz, xy, zx, yz;
                MomentOfInertia world, centroid;

                ap.GetResults(ap.Area, ap.Centroid, out x, out y, out z, out xx, out yy, out zz, out xy, out zx, out yz, out world, out centroid);

                text.AppendLine("Cumulative area: " + ap.Area + " square " + model1.Units.ToString().ToLower());
                text.AppendLine("Cumulative centroid: " + ap.Centroid);
                text.AppendLine("Cumulative area moments:");
                text.AppendLine(" First moments");
                text.AppendLine("  x: " + x.ToString("g6"));
                text.AppendLine("  y: " + y.ToString("g6"));
                text.AppendLine("  z: " + z.ToString("g6"));
                text.AppendLine(" Second moments");
                text.AppendLine("  xx: " + xx.ToString("g6"));
                text.AppendLine("  yy: " + yy.ToString("g6"));
                text.AppendLine("  zz: " + zz.ToString("g6"));
                text.AppendLine(" Product moments");
                text.AppendLine("  xy: " + xx.ToString("g6"));
                text.AppendLine("  yz: " + yy.ToString("g6"));
                text.AppendLine("  zx: " + zz.ToString("g6"));
                text.AppendLine(" Area Moments of Inertia about World Coordinate Axes");
                text.AppendLine("  Ix: " + world.Ix.ToString("g6"));
                text.AppendLine("  Iy: " + world.Iy.ToString("g6"));
                text.AppendLine("  Iz: " + world.Iz.ToString("g6"));
                text.AppendLine(" Area Radii of Gyration about World Coordinate Axes");
                text.AppendLine("  Rx: " + world.Rx.ToString("g6"));
                text.AppendLine("  Ry: " + world.Ry.ToString("g6"));
                text.AppendLine("  Rz: " + world.Rz.ToString("g6"));
                text.AppendLine(" Area Moments of Inertia about Centroid Coordinate Axes:");
                text.AppendLine("  Ix: " + centroid.Ix.ToString("g6"));
                text.AppendLine("  Iy: " + centroid.Iy.ToString("g6"));
                text.AppendLine("  Iz: " + centroid.Iz.ToString("g6"));
                text.AppendLine(" Area Radii of Gyration about Centroid Coordinate Axes");
                text.AppendLine("  Rx: " + centroid.Rx.ToString("g6"));
                text.AppendLine("  Ry: " + centroid.Ry.ToString("g6"));
                text.AppendLine("  Rz: " + centroid.Rz.ToString("g6"));
            }

            DetailsWindow rf = new DetailsWindow();

            rf.Title = "Area Properties";

            rf.contentTextBox.Text = text.ToString();

            rf.Show();
        }