protected override void SolveInstance(IGH_DataAccess DA) { Lam.Glulam g = null; Plane p = Plane.WorldXY; if (!DA.GetData("Glulam", ref g)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Couldn't get Glulam."); return; } DA.GetData("Plane", ref p); BasicAssembly ba = new BasicAssembly(g, p); DA.SetData("BasicAssembly", new GH.GH_Assembly(ba)); }
protected override void SolveInstance(IGH_DataAccess DA) { Curve crv = null; //double lw = 0, lh = 0; double w = 0, h = 0; int flags = 0; List <Plane> planes = new List <Plane>(); Plane[] plane_array = null; if (!DA.GetData("Curve", ref crv)) { 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); DA.GetData("Flags", ref flags); if (!DA.GetDataList("Frames", planes)) { //Plane p; //crv.PerpendicularFrameAt(crv.Domain.Min, out p); //plane_array = new Plane[] { p }; } else { plane_array = planes.ToArray(); } /* * Lam.GlulamData data = new Lam.GlulamData(); * data.LamHeight = lh > 0.1 ? lh : 20.0; * data.LamWidth = lw > 0.1 ? lw : 20.0; * data.NumHeight = h > 0 ? (int)Math.Ceiling(h / lh) : 4; * data.NumWidth = w > 0 ? (int)Math.Ceiling(w / lw) : 4; * data.Samples = samples > 1 ? samples : 2; */ Lam.GlulamData data = null; data = new GlulamData(crv, w, h, plane_array, (int)Math.Ceiling(crv.GetLength() / GlulamData.DefaultSampleDistance)); /* * if (calculate_data) * data = Lam.GlulamData.FromCurveLimits(crv, w, h, plane_array); * else * data = new Lam.GlulamData(1, 1, w, h); */ Lam.Glulam blank = Lam.Glulam.CreateGlulam(crv, plane_array, data); //blank.CalculateLamellaSizes(w, h); List <object> output = new List <object>(); if ((flags & 1) > 0) { output.Add(blank.GetBoundingMesh(0, blank.Data.InterpolationType)); } if ((flags & (1 << 1)) > 0) { output.Add(blank.GetBoundingBrep()); } if ((flags & (1 << 2)) > 0) { output.AddRange(blank.GetLamellaCurves()); } if ((flags & (1 << 3)) > 0) { output.AddRange(blank.GetLamellaMeshes()); } if ((flags & (1 << 4)) > 0) { output.AddRange(blank.GetLamellaBreps()); } DA.SetDataList("Geometry", output); DA.SetData("Glulam", new GH.GH_Glulam(blank)); }
protected override void SolveInstance(IGH_DataAccess DA) { Curve crv = null; List <Curve> guides = new List <Curve>(); //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.GetDataList("Guides", guides)) { return; } for (int i = 0; i < guides.Count; ++i) { Point3d pt = guides[i].PointAtStart; Vector3d vec = guides[i].TangentAtStart; double t; crv.ClosestPoint(pt, out t); //Plane nor_plane = new Plane(crv.PointAt(t), crv.TangentAt(t)); //vec = vec.ProjectToPlane(nor_plane); //Plane frame = new Plane(nor_plane.Origin, Vector3d.CrossProduct(crv.TangentAt(t), vec), vec); var origin = crv.PointAt(t); var x_axis = Vector3d.CrossProduct(vec, crv.TangentAt(t)); var y_axis = Vector3d.CrossProduct(crv.TangentAt(t), x_axis); Plane frame = new Plane(origin, x_axis, y_axis); planes.Add(frame); } //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); Lam.GlulamData data = null; data = new GlulamData(crv, w, h, planes.ToArray(), (int)Math.Ceiling(crv.GetLength() / GlulamData.DefaultSampleDistance)); /* * if (calculate_data) * data = Lam.GlulamData.FromCurveLimits(crv, w, h); * else * data = new Lam.GlulamData(1, 1, w, h); * //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.Samples = samples > 1 ? samples : 2; Lam.Glulam blank = Lam.Glulam.CreateGlulam(crv, planes.ToArray(), data); //blank.RemoveDuplicateFrames(); DA.SetData("Glulam", new GH.GH_Glulam(blank)); }