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)); }
public static void WriteCrossSectionOrientation(GH_IWriter writer, CrossSectionOrientation ori) { writer.SetString("orientation", ori.ToString()); switch (ori) { case RmfOrientation rmf: return; case PlanarOrientation plan: var plane = plan.Plane; writer.SetPlane("orientation_plane", new GH_IO.Types.GH_Plane( plane.Origin.X, plane.Origin.Y, plane.Origin.Z, plane.XAxis.X, plane.XAxis.Y, plane.XAxis.Z, plane.YAxis.X, plane.YAxis.Y, plane.YAxis.Z )); return; case VectorOrientation vec: var v = (Vector3d)vec.GetDriver(); writer.SetPoint3D("orientation_vector", new GH_IO.Types.GH_Point3D(v.X, v.Y, v.Z)); return; case SurfaceOrientation srf: writer.SetByteArray("orientation_surface", GH_Convert.CommonObjectToByteArray(srf.GetDriver() as Brep)); return; case VectorListOrientation vlist: writer.SetInt32("orientation_num_vectors", vlist.Vectors.Count); writer.SetByteArray("orientation_guide", GH_Convert.CommonObjectToByteArray(vlist.GetCurve())); for (int i = 0; i < vlist.Parameters.Count; ++i) { writer.SetDouble("orientation_parameter", i, vlist.Parameters[i]); writer.SetPoint3D("orientation_vector", i, new GH_IO.Types.GH_Point3D( vlist.Vectors[i].X, vlist.Vectors[i].Y, vlist.Vectors[i].Z)); } return; default: return; } }
public override bool Read(GH_IReader reader) { if (!reader.ItemExists("guide")) { Value = null; throw new Exception("Couldn't retrieve 'guide'."); } Curve guide = GH_Convert.ByteArrayToCommonObject <Curve>(reader.GetByteArray("guide")); if (guide == null) { throw new Exception("Failed to convert 'guide'."); } CrossSectionOrientation ori = GH_Glulam.ReadCrossSectionOrientation(reader); GlulamData data = GH_GlulamData.ReadGlulamData(reader); Value = Glulam.CreateGlulam(guide, ori, data); return(base.Read(reader)); }