Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ISystem sghSystem = null;
            double  du        = 0.0;
            double  the       = -1.0;

            if (!DA.GetData(0, ref sghSystem))
            {
                return;
            }
            if (!DA.GetData(1, ref du))
            {
                return;
            }
            if (!DA.GetData(2, ref the))
            {
                return;
            }

            Mesh   m   = new Mesh();
            string mss = "";

            string          modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon     = new sRhinoConverter("Meters", modelUnit);

            if (sghSystem != null)
            {
                ISystem sys = sghSystem as ISystem;

                sRange th = null;
                if (the > 0.0)
                {
                    if (colMode.ToString().Contains("Stress"))
                    {
                        the *= 1.0E6;
                    }
                    th = new sRange(0.0, rhcon.EnsureUnit(the, colMode));
                }

                List <sMesh> mms = new List <sMesh>();
                sRange       resultRange;
                sys.ConstructBeamResultMesh(colMode, ref mms, out resultRange, th, du);
                mss += "Color Mode\n" + colMode.ToString();


                Interval reRangeRh = rhcon.EnsureUnit_DataRange(rhcon.ToRhinoInterval(resultRange), colMode, true); //true means Pa > MPa
                mss += "\nData Range: " + Math.Round(reRangeRh.Min, 2) + " to " + Math.Round(reRangeRh.Max, 2);

                foreach (sMesh sm in mms)
                {
                    Mesh rm = rhcon.ToRhinoMesh(sm);
                    m.Append(rhcon.EnsureUnit(rm) as Mesh);
                }
            }
            this.Message = mss;

            DA.SetData(0, m);
        }
        public MomentAxis ToKodeStructMomentAxis(eColorMode dataType)
        {
            string ax = "";

            if (dataType.ToString().Contains("_Y"))
            {
                ax = "XAxis";
            }
            else if (dataType.ToString().Contains("_Z"))
            {
                ax = "YAxis";
            }

            MomentAxis Axis;
            bool       IsValidStringAxis = Enum.TryParse(ax, true, out Axis);

            if (IsValidStringAxis == false)
            {
                throw new Exception("Axis selection not recognized. Check input string.");
            }

            return(Axis);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            sFrame sb = null;

            if (!DA.GetData(0, ref sb))
            {
                return;
            }

            string          modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon     = new sRhinoConverter("Meters", modelUnit);

            this.Message = "Beam Result\n" + colMode.ToString();

            sRange ran = sb.GetBeamResultRange(colMode);

            Point3d  cp = rhcon.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.5)));
            Vector3d x  = rhcon.ToRhinoVector3d(sb.localPlane.Xaxis);
            Vector3d y  = rhcon.ToRhinoVector3d(sb.localPlane.Yaxis);

            Plane pl = new Plane(cp, x, -y);


            double max  = 0.0;
            double min  = 0.0;
            string unit = "";

            if (colMode == eColorMode.Deflection)
            {
                max = rhcon.EnsureUnit_Deflection(ran.max);
                min = rhcon.EnsureUnit_Deflection(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "mm";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "in";
                }
            }
            else if (colMode.ToString().Contains("Stress"))
            {
                max = rhcon.EnsureUnit_Stress(ran.max);
                min = rhcon.EnsureUnit_Stress(ran.min);
                if (modelUnit == "Meters")
                {
                    max *= 1.0E-6;
                    min *= 1.0E-6;
                    unit = "MPa";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "ksi";
                }
            }
            else if (colMode.ToString().Contains("Force"))
            {
                max = rhcon.EnsureUnit_Force(ran.max);
                min = rhcon.EnsureUnit_Force(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "N";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "lbf";
                }
            }
            else if (colMode.ToString().Contains("Moment"))
            {
                max = rhcon.EnsureUnit_Moment(ran.max);
                min = rhcon.EnsureUnit_Moment(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "N.m";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "lbf.ft";
                }
            }

            DA.SetData(0, pl);
            DA.SetData(1, "(" + Math.Round(min, 2) + ") - (" + Math.Round(max, 2) + ") " + unit);
            DA.SetData(2, max);
            DA.SetData(3, min);
        }