Beispiel #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            object raw_g = null;

            if (!DA.GetData("Glulam", ref raw_g))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Glulam input.");
                return;
            }

            GH_Glulam ghg = raw_g as GH_Glulam;

            if (ghg == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Glulam input.");
                return;
            }

            Glulam g = ghg.Value;

            double offset = 0.0;

            DA.GetData("Amount", ref offset);

            DA.SetData("Output", g.ToBrep(offset));
        }
Beispiel #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam m_glulam = null;

            if (!DA.GetData <Glulam>("Glulam", ref m_glulam))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not get Glulam.");
                return;
            }

            double x = 0.0, y = 0.0;

            DA.GetData("OffsetX", ref x);
            DA.GetData("OffsetY", ref y);

            Curve crv = m_glulam.CreateOffsetCurve(x, y);


            // GlulamData data = GlulamData.FromCurveLimits(crv,g.Data.NumWidth * g.Data.LamWidth, g.Data.NumHeight * g.Data.LamHeight, g.GetAllPlanes());

            //data.Samples = g.Data.Samples;

            Glulam offset_glulam = Glulam.CreateGlulam(crv, m_glulam.Orientation.Duplicate(), m_glulam.Data.Duplicate());

            DA.SetData("Glulam", new GH_Glulam(offset_glulam));
        }
Beispiel #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve        crv    = null;
            List <Plane> planes = new List <Plane>();

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }

            DA.GetDataList("Frames", planes);

            Lam.GlulamData data  = null;
            object         iData = null;

            DA.GetData("Data", ref iData);
            if (iData is GlulamData)
            {
                data = iData as GlulamData;
            }
            else if (iData is GH_GlulamData)
            {
                data = (iData as GH_GlulamData).Value;
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to get GlulamData.");
            }

            Glulam blank = Glulam.CreateGlulam(crv, planes.ToArray(), data);

            DA.SetData("Glulam", new GH_Glulam(blank));
        }
Beispiel #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            object raw_in = null;

            if (!DA.GetData("Glulam", ref raw_in))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Glulam specified.");
                return;
            }
            GH_Glulam ghg = raw_in as GH.GH_Glulam;

            if (ghg == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input is not valid Glulam object.");
                return;
            }
            Glulam g = ghg.Value;

            int side = 0;

            DA.GetData("Side", ref side);
            double offset = 0.0;

            DA.GetData("Offset", ref offset);
            double width = 0.0;

            DA.GetData("Width", ref width);
            double extension = 0.0;

            DA.GetData("Extension", ref extension);

            Brep b = g.GetSideSurface(side, offset, width, extension);

            DA.SetData("Brep", b);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam glulam = null;

            if (!DA.GetData("Glulam", ref glulam))
            {
                return;
            }

            string name = "GlulamBeamElement";

            DA.GetData("Name", ref name);

            Plane handle = Plane.Unset;

            DA.GetData("Plane", ref handle);

            BeamElement beam_element;

            if (handle == Plane.Unset)
            {
                beam_element = new BeamElement(glulam, name);
            }
            else
            {
                beam_element = new BeamElement(glulam, handle, name);
            }

            DA.SetData("Element", new GH_Element(beam_element));
        }
Beispiel #6
0
        public override bool Evaluate()
        {
            Glulam g = GlulamParam.Value as Glulam;

            bool is_ok_x = false, is_ok_y = false;

            Glulam gdup = g.Duplicate();

            gdup.Data.LamHeight = (double)LHParam.Value;
            gdup.Data.LamWidth  = (double)LWParam.Value;

            bool res = gdup.InKLimitsComponent(out is_ok_x, out is_ok_y);

            if (res)
            {
                return(res);
            }
            else
            {
                if (!LHParam.Locked && !LWParam.Locked)
                {
                    //GlulamData gdata = GlulamData.FromCurveLimits(g.Centreline, g.GetAllPlanes());
                    GlulamData gdata = GlulamData.Default;
                    LHParam.Value = gdata.LamHeight;
                    LWParam.Value = gdata.LamWidth;
                    return(true);
                }
                else
                {
                    // TODO: Propose new relaxed curve
                    return(false);
                }
            }
        }
Beispiel #7
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve crv = null;

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }

            crv.Domain.MakeIncreasing();

            List <object> r_orientation = new List <object>();

            DA.GetDataList("Orientation", r_orientation);

            object r_data = null;

            DA.GetData("Data", ref r_data);

            CrossSectionOrientation orientation = ParseGlulamOrientation(r_orientation, crv);

            AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, orientation.ToString());

            GlulamData data = ParseGlulamData(r_data);

            AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, data.ToString());

            data.Samples = (int)Math.Ceiling(crv.GetLength() / GlulamData.DefaultSampleDistance);

            Glulam glulam = Glulam.CreateGlulam(crv, orientation, data);


            DA.SetData("Glulam", new GH_Glulam(glulam));
        }
Beispiel #8
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Point3d m_point = Point3d.Unset;
            bool    m_flip  = false;

            DA.GetData("Point", ref m_point);
            DA.GetData("Flip", ref m_flip);

            // Get Glulam
            Glulam m_glulam = null;

            DA.GetData <Glulam>("Glulam", ref m_glulam);
            if (m_glulam == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid glulam input.");
                return;
            }

            Plane plane = m_glulam.GetPlane(m_point);

            if (m_flip)
            {
                plane = plane.FlipAroundYAxis();
            }

            DA.SetData("Plane", plane);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam m_glulam = null;

            if (!DA.GetData("Glulam", ref m_glulam))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No glulam input.");
                return;
            }

            Mesh m = m_glulam.ToMesh();

            double m_ratio = 200.0;

            DA.GetData("Ratio", ref m_ratio);

            if (m_ratio <= 0.0)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Ratio values must be greater than 0.");
                return;
            }

            double min_rx = m_glulam.Data.LamWidth * m_ratio;
            double min_ry = m_glulam.Data.LamHeight * m_ratio;

            double max_kx = 1 / min_rx;
            double max_ky = 1 / min_ry;

            List <double> f_values = new List <double>();
            double        t;

            for (int i = 0; i < m.Vertices.Count; ++i)
            {
                m_glulam.Centreline.ClosestPoint(m.Vertices[i], out t);
                Plane frame = m_glulam.GetPlane(t);

                Vector3d offset = m.Vertices[i] - frame.Origin;

                double offset_x = offset * frame.XAxis;
                double offset_y = offset * frame.YAxis;

                Vector3d kv = m_glulam.Centreline.CurvatureAt(t);
                double   k  = kv.Length;

                kv.Unitize();

                double r = (1 / k) - offset * kv;

                k = 1 / r;

                double kx = k * (kv * frame.XAxis);
                double ky = k * (kv * frame.YAxis);

                f_values.Add(Math.Max(Math.Abs(kx / max_kx), Math.Abs(ky / max_ky)));
            }

            DA.SetData("Mesh", m);
            DA.SetDataList("Factor", f_values);
        }
Beispiel #10
0
 public EndLapJoint(Glulam glulam, int end, double length, double incline, double extension)
 {
     m_glulam    = glulam;
     m_length    = length;
     m_incline   = incline;
     m_extension = extension;
     m_end       = end.Modulus(2) == 0;
 }
Beispiel #11
0
 public CrossJoint(Glulam glulamA, Glulam glulamB, double offset1, double offset2)
 {
     m_glulamA     = glulamA;
     m_glulamB     = glulamB;
     m_offset1     = offset1;
     m_offset2     = offset2;
     offset_center = 10;
 }
Beispiel #12
0
        protected void MapObjectToGlulam(List <object> input, Glulam g, IGH_DataAccess DA)
        {
            if (input == null || input.Count < 1)
            {
                return;
            }
            if (input.Count == 1)
            {
                object single = input[0];
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, single.ToString());

                if (single is Point3d)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace((Point3d)single) });
                }
                else if (single is GH_Point)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace((single as GH_Point).Value) });
                }
                else if (single is Plane)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace((Plane)single) });
                }
                else if (single is GH_Plane)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace((single as GH_Plane).Value) });
                }
                if (single is GH_Mesh)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace((single as GH_Mesh).Value) });
                }
                if (single is Mesh)
                {
                    DA.SetDataList("Geometry", new object[] { g.ToBeamSpace(single as Mesh) });
                }

                return;
            }

            if (input.First() is GH_Plane)
            {
                DA.SetDataList("Geometry", g.ToBeamSpace(input.Select(x => (x as GH_Plane).Value).ToList()));
            }
            else if (input.First() is Plane)
            {
                DA.SetDataList("Geometry", g.ToBeamSpace(input.Select(x => (Plane)x).ToList()));
            }
            else if (input.First() is GH_Point)
            {
                DA.SetDataList("Geometry", g.ToBeamSpace(input.Select(x => (x as GH_Point).Value).ToList()));
            }
            else if (input.First() is Point3d)
            {
                DA.SetDataList("Geometry", g.ToBeamSpace(input.Select(x => (Point3d)x).ToList()));
            }
        }
Beispiel #13
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Get Glulam
            Glulam m_glulam = null;

            DA.GetData <Glulam>("Glulam", ref m_glulam);

            if (m_glulam == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid glulam input.");
                return;
            }

            List <double> m_params = new List <double>();

            DA.GetDataList("Parameter", m_params);
            if (m_params.Count < 1)
            {
                return;
            }

            double m_overlap = 0;

            DA.GetData("Overlap", ref m_overlap);

            m_params.Sort();

            List <Glulam> m_glulams = new List <Glulam>();

            //m_glulams = g.Split(m_params.ToArray(), m_overlap);

            List <Interval> domains = new List <Interval>();
            double          dmin    = m_glulam.Centreline.Domain.Min;

            domains.Add(new Interval(dmin, m_params.First()));
            for (int i = 0; i < m_params.Count - 1; ++i)
            {
                domains.Add(new Interval(m_params[i], m_params[i + 1]));
            }
            domains.Add(new Interval(m_params.Last(), m_glulam.Centreline.Domain.Max));

            //domains = domains.Where(x => m_glulam.Centreline.GetLength(x) > m_overlap).ToList();

            for (int i = 0; i < domains.Count; ++i)
            {
                Glulam temp = m_glulam.Trim(domains[i], m_overlap);
                if (temp == null)
                {
                    continue;
                }

                m_glulams.Add(temp);
            }

            DA.SetDataList("Glulams", m_glulams.Select(x => new GH_Glulam(x)));
        }
Beispiel #14
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam gA = null, gB = null;

            if (!DA.GetData <Glulam>("GlulamA", ref gA) || !DA.GetData <Glulam>("GlulamB", ref gB))
            {
                return;
            }

            //gA.Centreline.ClosestPoints(gB.Centreline, out Point3d pA, out Point3d pB);

            double search_distance = Math.Max(Math.Max(gA.Height, gB.Height), Math.Max(gA.Width, gB.Width));

            var intersections      = Rhino.Geometry.Intersect.Intersection.CurveCurve(gA.Centreline, gB.Centreline, search_distance, search_distance);

            if (intersections == null || intersections.Count < 1)
            {
                return;
            }

            var intersection = intersections[0];

            if (!intersection.IsOverlap)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Glulams are not overlapping. Might create unexpected results.");
            }

            Point3d pA = (intersection.PointA + intersection.PointA2) / 2;
            Point3d pB = (intersection.PointB + intersection.PointB2) / 2;

            gA.Centreline.ClosestPoint(pA, out double tA);
            gB.Centreline.ClosestPoint(pB, out double tB);


            //Point3d pC = (pA + pB) / 2;

            //gA.Centreline.ClosestPoint(pC, out double tA);
            //gB.Centreline.ClosestPoint(pC, out double tB);

            double m_length = 100.0, m_incline = 20.0;

            DA.GetData("Length", ref m_length);
            DA.GetData("Incline", ref m_incline);

            EndLapJoint2 scarf_joint = new EndLapJoint2(gA, gB, tA, tB, m_length, m_incline);

            scarf_joint.Compute();

            List <Brep> breps = scarf_joint.GetCuttingGeometry();

            if (breps.Count > 0)
            {
                DA.SetData("Brep", breps[0]);
            }
        }
Beispiel #15
0
        public CrossJoint2(Glulam glulamA, Glulam glulamB, double offset1 = 10.0, double offset2 = 10.0, double extension = 5.0, double drill_depth = 100.0)
        {
            m_glulam1     = glulamA;
            m_glulam2     = glulamB;
            m_offset1     = offset1;
            m_offset2     = offset2;
            m_extension   = extension;
            offset_center = 10;

            m_drill_depth = drill_depth;
        }
Beispiel #16
0
        public EndLapJoint2(Glulam glulam1, Glulam glulam2, double t1, double t2, double length, double incline, double extension = 5.0, double drill_depth = 200.0)
        {
            m_glulam1 = glulam1;
            m_glulam2 = glulam2;
            m_t1      = t1;
            m_t2      = t2;

            m_length      = length;
            m_incline     = incline;
            m_extension   = extension;
            m_drill_depth = drill_depth;
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve crv  = null;
            Brep  brep = null;
            //double lw = 0, lh = 0;
            double       w = 0, h = 0;
            int          samples = 0;
            List <Plane> planes  = new List <Plane>();

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }
            if (!DA.GetData("Brep", ref brep))
            {
                return;
            }

            //DA.GetData("LamWidth", ref lw);
            //DA.GetData("LamHeight", ref lh);
            DA.GetData("Width", ref w);
            DA.GetData("Height", ref h);
            DA.GetData("Samples", ref samples);
            samples = Math.Max(samples, 2);

            Plane[] frames = tas.Core.Util.Misc.FramesNormalToSurface(crv, brep);

            GlulamData data = null;

            if (calculate_data)
            {
                data = Lam.GlulamData.FromCurveLimits(crv, w, h, frames);
            }
            else
            {
                data = new Lam.GlulamData(1, 1, w, h, samples);
            }
            //data.LamHeight = lh > 0.001 ? lh : 20.0;
            //data.LamWidth = lw > 0.001 ? lw : 20.0;
            //data.NumHeight = h > 0 ? (int)Math.Ceiling(h / lh) : 4;
            //data.NumWidth = w > 0 ? (int)Math.Ceiling(w / lw) : 4;

            data.InterpolationType = GlulamData.Interpolation.HERMITE;
            Glulam blank = Glulam.CreateGlulam(crv, frames, data);

            //Lam.Glulam blank = Lam.Glulam.CreateGlulamNormalToSurface(crv, brep, 20, null);
            DA.SetData("Glulam", new GH_Glulam(blank));
        }
Beispiel #18
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam gA = null, gB = null;
            double extension  = 10.0;
            bool   normalized = false;

            if (!DA.GetData <Glulam>("Glulam A", ref gA) ||
                !DA.GetData <Glulam>("Glulam B", ref gB))
            {
                return;
            }

            Brep bi = Glulam.GetGlulamBisector(gA, gB, extension, normalized);

            DA.SetData("Brep", bi);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            object m_obj   = null;
            Mesh   m_mesh  = null;
            double m_angle = Rhino.RhinoMath.ToRadians(5);

            DA.GetData("Angle", ref m_angle);
            DA.GetData("Mesh", ref m_mesh);
            DA.GetData("Glulam", ref m_obj);

            while (true)
            {
                GH_Glulam m_ghglulam = m_obj as GH_Glulam;
                if (m_ghglulam != null)
                {
                    m_mesh = m_ghglulam.Value.MapToCurveSpace(m_mesh);
                    break;
                }

                GH_Curve m_ghcurve = m_obj as GH_Curve;
                if (m_ghcurve != null)
                {
                    m_mesh = m_ghcurve.Value.MapToCurveSpace(m_mesh);
                    break;
                }

                Glulam m_glulam = m_obj as Glulam;
                if (m_glulam != null)
                {
                    m_mesh = m_glulam.MapToCurveSpace(m_mesh);
                    break;
                }

                Curve m_curve = m_obj as Curve;
                if (m_curve != null)
                {
                    m_mesh = m_curve.MapToCurveSpace(m_mesh);
                    break;
                }
                throw new Exception("Input must be either Glulam or Curve!");
            }

            var indices = m_mesh.CheckFibreCuttingAngle(m_angle);

            DA.SetDataList("Face Indices", indices);
            DA.SetData("debug", m_mesh);
        }
Beispiel #20
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            object m_obj   = null;
            Mesh   m_mesh  = null;
            bool   m_faces = false;

            DA.GetData("Mesh", ref m_mesh);
            DA.GetData("Glulam", ref m_obj);
            DA.GetData("Faces", ref m_faces);

            Curve m_curve = null;

            while (true)
            {
                GH_Glulam m_ghglulam = m_obj as GH_Glulam;
                if (m_ghglulam != null)
                {
                    m_curve = m_ghglulam.Value.Centreline;
                    break;
                }

                GH_Curve m_ghcurve = m_obj as GH_Curve;
                if (m_ghcurve != null)
                {
                    m_curve = m_ghcurve.Value;
                    break;
                }

                Glulam m_glulam = m_obj as Glulam;
                if (m_glulam != null)
                {
                    m_curve = m_glulam.Centreline;
                    break;
                }

                m_curve = m_obj as Curve;
                if (m_curve != null)
                {
                    break;
                }
                throw new Exception("Input must be either Glulam or Curve!");
            }

            List <Vector3d> deviations = m_mesh.CalculateTangentVector(m_curve, m_faces);

            DA.SetDataList("Vectors", deviations);
        }
Beispiel #21
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam glulam = null;

            if (!DA.GetData <Glulam>("Glulam", ref glulam))
            {
                return;
            }

            int side = 0;

            DA.GetData("Side", ref side);

            Brep[] breps = glulam.GetGlulamFaces(side);

            DA.SetDataList("Faces", breps);
        }
Beispiel #22
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam m_glulam = null;

            if (!DA.GetData("Glulam", ref m_glulam))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No glulam input.");
                return;
            }

            Mesh m = m_glulam.GetBoundingMesh();

            List <double> kx_values = new List <double>();
            List <double> ky_values = new List <double>();
            double        t;

            for (int i = 0; i < m.Vertices.Count; ++i)
            {
                m_glulam.Centreline.ClosestPoint(m.Vertices[i], out t);
                Plane frame = m_glulam.GetPlane(t);

                Vector3d offset = m.Vertices[i] - frame.Origin;

                double offset_x = offset * frame.XAxis;
                double offset_y = offset * frame.YAxis;

                Vector3d kv = m_glulam.Centreline.CurvatureAt(t);
                double   k  = kv.Length;

                kv.Unitize();

                double r = (1 / k) - offset * kv;

                k = 1 / r;

                double kx = k * (kv * frame.XAxis);
                double ky = k * (kv * frame.YAxis);

                kx_values.Add(Math.Abs(kx));
                ky_values.Add(Math.Abs(ky));
            }

            DA.SetData("Mesh", m);
            DA.SetDataList("Curvature X", kx_values);
            DA.SetDataList("Curvature Y", ky_values);
        }
Beispiel #23
0
        public static void CreateElementOrientations(this Glulam g, List <Node> nodes, List <Element> elements, out List <ElementOrientation> orientations)
        {
            orientations = new List <ElementOrientation>(elements.Count);

            foreach (Element ele in elements)
            {
                Point3d centre = new Point3d(
                    ele.Data.Select(x => nodes[x - 1].X).ToArray().Sum() / 8,
                    ele.Data.Select(x => nodes[x - 1].Y).ToArray().Sum() / 8,
                    ele.Data.Select(x => nodes[x - 1].Z).ToArray().Sum() / 8
                    );

                //Plane ori = Plane.Unset;
                GetOrientation(g, centre, out Plane ori);

                orientations.Add(new ElementOrientation(ori, ele.Id));
            }
        }
Beispiel #24
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam g = null;

            if (!DA.GetData <Glulam>("Glulam", ref g))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No glulam blank connected.");
                return;
            }

            List <object> m_objects = new List <object>();

            if (!DA.GetDataList("Geo", m_objects))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Invalid geometry specified.");
                return;
            }

            MapObjectToGlulam(m_objects, g, DA);
        }
Beispiel #25
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam gA = null, gB = null;

            if (!DA.GetData <Glulam>("GlulamA", ref gA) || !DA.GetData <Glulam>("GlulamB", ref gB))
            {
                return;
            }

            CrossJoint2 cross_joint = new CrossJoint2(gA, gB);

            cross_joint.Compute();

            List <Brep> breps       = cross_joint.GetCuttingGeometry();

            if (breps.Count > 0)
            {
                DA.SetData("Brep", breps[0]);
            }
        }
Beispiel #26
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam m_glulam = null;

            if (!DA.GetData <Glulam>("Glulam", ref m_glulam))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Invalid glulam input.");
                return;
            }

            List <double> m_parameters = new List <double>();

            DA.GetDataList("Parameters", m_parameters);


            //double[] tt = g.Centreline.DivideByCount(N, true);

            Plane[] planes = m_parameters.Select(x => m_glulam.GetPlane(x)).ToArray();

            DA.SetDataList("Planes", planes);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Mesh   mesh_input = null;
            Curve  c          = null;
            double extra      = 0.0;

            GeometryBase geo = null;

            if (!DA.GetData("Geo", ref geo))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No input geometry.");
            }
            if (!DA.GetData("Curve", ref c))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No guide curve.");
            }
            DA.GetData("Extra", ref extra);

            if (geo is Brep)
            {
                mesh_input = Mesh.CreateFromBrep(geo as Brep, MeshingParameters.QualityRenderMesh).Amalgamate();
            }
            else if (geo is Mesh)
            {
                mesh_input = geo as Mesh;
            }
            else
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to parse geometry.");
            }

            double w, h, l;

            Glulam g = Glulam.CreateGlulamFromBeamGeometry2(c, mesh_input, out w, out h, out l, extra);

            DA.SetData("Glulam", new GH_Glulam(g));
            DA.SetDataList("Dimensions", new double[] { w, h, l });
        }
Beispiel #28
0
        public ArchivableDictionary GlulamPropertiesToArchivableDictionary(Glulam g)
        {
            ArchivableDictionary ad = new ArchivableDictionary();

            var gd = g.GetProperties();

            //ad.Set("id", g.ID);
            ad.Set("centreline", g.Centreline);
            ad.Set("width", g.Width);
            ad.Set("height", g.Height);
            ad.Set("lamella_width", g.Data.LamWidth);
            ad.Set("lamella_height", g.Data.LamHeight);
            ad.Set("lamella_count_width", g.Data.NumWidth);
            ad.Set("lamella_count_height", g.Data.NumHeight);
            ad.Set("volume", g.GetVolume());
            ad.Set("samples", g.Data.Samples);

            /*
             * var planes = g.GetAllPlanes();
             * ArchivableDictionary pd = new ArchivableDictionary();
             *
             * for (int i = 0; i < planes.Length; ++i)
             * {
             *  pd.Set(string.Format("Frame_{0}", i), planes[i]);
             * }
             * ad.Set("frames", pd);
             *
             */
            double max_kw = 0.0, max_kh = 0.0;

            ad.Set("max_curvature", g.GetMaxCurvature(ref max_kw, ref max_kh));
            ad.Set("max_curvature_width", max_kw);
            ad.Set("max_curvature_height", max_kh);
            ad.Set("type", g.ToString());
            ad.Set("type_id", (int)g.Type());

            return(ad);
        }
Beispiel #29
0
        protected override void BeforeSolveInstance()
        {
            if (valueList == null)
            {
                if (parameter.Sources.Count == 0)
                {
                    valueList = new GH_ValueList();
                }
                else
                {
                    foreach (var source in parameter.Sources)
                    {
                        if (source is GH_ValueList)
                        {
                            valueList = source as GH_ValueList;
                        }
                        return;
                    }
                }

                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - 200, this.Attributes.Pivot.Y - 1);
                valueList.ListItems.Clear();

                var glulamParameters = Glulam.ListProperties();

                foreach (string param in glulamParameters)
                {
                    valueList.ListItems.Add(new GH_ValueListItem(param, $"\"{param}\""));
                }

                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
            }
        }
Beispiel #30
0
        public static void CreateGlulamNodesAndElements(this Glulam g, out List <Node> nodes, out List <Element> elements, int Nx = 4, int Ny = 4, int Nz = 50)
        {
            double hWidth  = g.Width / 2;
            double hHeight = g.Height / 2;

            double stepX = g.Width / Nx;
            double stepY = g.Height / Ny;

            List <Point3d> xPts = new List <Point3d>();

            for (int y = 0; y <= Ny; ++y)
            {
                for (int x = 0; x <= Nx; ++x)
                {
                    Point3d pt = new Point3d(
                        -hWidth + x * stepX,
                        -hHeight + y * stepY,
                        0);
                    xPts.Add(pt);
                }
            }

            Plane[]  xplanes;
            double[] xt;

            int N = Nz + 1;

            g.GenerateCrossSectionPlanes(N, out xplanes, out xt, GlulamData.Interpolation.LINEAR);

            nodes = new List <Node>();

            int i = 0;

            for (int z = 0; z < N; ++z)
            {
                Transform xform = Transform.PlaneToPlane(Plane.WorldXY, xplanes[z]);
                for (int j = 0; j < xPts.Count; ++j)
                {
                    Point3d pt = new Point3d(xPts[j]);
                    pt.Transform(xform);
                    nodes.Add(new Node(pt.X, pt.Y, pt.Z, i + 1));
                    i++;
                }
            }

            elements = new List <Element>();

            int sz = (Nx + 1) * (Ny + 1);
            int sy = (Nx + 1);

            i = 0;
            for (int z = 0; z < Nz; ++z)
            {
                int cz = z * sz;
                for (int y = 0; y < Ny; ++y)
                {
                    int cy = y * sy;
                    for (int x = 0; x < Nx; ++x)
                    {
                        int[] indices = new int[] {
                            cz + cy + x,
                            cz + cy + x + 1,
                            cz + cy + x + sy + 1,
                            cz + cy + x + sy,
                            cz + sz + cy + x,
                            cz + sz + cy + x + 1,
                            cz + sz + cy + x + sy + 1,
                            cz + sz + cy + x + sy
                        };

                        for (int ii = 0; ii < 8; ++ii)
                        {
                            indices[ii] = nodes[indices[ii]].Id;
                        }

                        Element ele = new C3D8 {
                            Data = indices, Id = i + 1
                        };

                        elements.Add(ele);
                        ++i;
                    }
                }
            }
        }