static void Main(string[] args) { WR_Structure structure = new WR_Structure(); WR_XSecRect rect = new WR_XSecRect(0.1, 0.1); WR_ReleaseBeam3d rel = new WR_ReleaseBeam3d(true, true, true, true, true, true); WR_XYZ x1 = new WR_XYZ(0, 0, 0); WR_XYZ x2 = new WR_XYZ(0, 1, 0); WR_XYZ x3 = new WR_XYZ(1, 1, 0); WR_XYZ x4 = new WR_XYZ(1, 0, 0); WR_Elem3dRcp rcp1 = new WR_Elem3dRcp(x1, x2, rel, rel, rect, 210000000000, 0.1, new WR_Vector(0, 1, 0)); WR_Elem3dRcp rcp2 = new WR_Elem3dRcp(x2, x3, rel, rel, rect, 210000000000, 0.1, new WR_Vector(0, 1, 0)); WR_Elem3dRcp rcp3 = new WR_Elem3dRcp(x3, x4, rel, rel, rect, 210000000000, 0.1, new WR_Vector(0, 1, 0)); WR_Node3d n1 = new WR_Node3d(0, 0, 0); WR_Node3d n2 = new WR_Node3d(0, 1, 0); WR_Node3d n3 = new WR_Node3d(1, 1, 0); WR_Node3d n4 = new WR_Node3d(1, 0, 0); structure.AddNode(n1); structure.AddNode(n2); structure.AddNode(n3); structure.AddNode(n4); structure.AddElementRcp(rcp1); structure.AddElementRcp(rcp2); structure.AddElementRcp(rcp3); structure.Solve(); }
static void Main(string[] args) { WR_Structure structure = new WR_Structure(); WR_XSecRect rect = new WR_XSecRect(0.1, 0.1); WR_ReleaseBeam3d rel = new WR_ReleaseBeam3d(true, true, true, true, true, true); WR_XYZ x1 = new WR_XYZ(0, 0, 0); WR_XYZ x2 = new WR_XYZ(0, 1, 0); WR_XYZ x3 = new WR_XYZ(1, 1, 0); WR_XYZ x4 = new WR_XYZ(1, 0, 0); WR_Elem3dRcp rcp1 = new WR_Elem3dRcp(x1, x2,rel,rel,rect,210000000000,0.1,new WR_Vector(0,1,0)); WR_Elem3dRcp rcp2 = new WR_Elem3dRcp(x2, x3, rel, rel, rect, 210000000000, 0.1, new WR_Vector(0, 1, 0)); WR_Elem3dRcp rcp3 = new WR_Elem3dRcp(x3, x4, rel, rel, rect, 210000000000, 0.1, new WR_Vector(0, 1, 0)); WR_Node3d n1 = new WR_Node3d(0, 0, 0); WR_Node3d n2 = new WR_Node3d(0, 1, 0); WR_Node3d n3 = new WR_Node3d(1, 1, 0); WR_Node3d n4 = new WR_Node3d(1, 0, 0); structure.AddNode(n1); structure.AddNode(n2); structure.AddNode(n3); structure.AddNode(n4); structure.AddElementRcp(rcp1); structure.AddElementRcp(rcp2); structure.AddElementRcp(rcp3); structure.Solve(); }
public static List<Brep> CreateSectionSweeps(WR_Elem3dRcp er) { List<Curve> crvs; List<Brep> eSBreps = new List<Brep>(); // Start and end caps List<Curve> sCap = new List<Curve>(); List<Curve> eCap = new List<Curve>(); if (CrossSectionCasts.GetSectionPropertyCrvs(er.GetSectionString(), out crvs)) { // Get x vector Point3d sPos = er.GetStartPos().ConvertToRhinoPoint(); Point3d ePos = er.GetEndPos().ConvertToRhinoPoint(); Vector3d elX = new Vector3d(ePos.X - sPos.X, ePos.Y - sPos.Y, ePos.Z - sPos.Z); double elLength = elX.Length; elX.Unitize(); Vector3d move = elX * elLength; // Get normal (z vector) WR_Vector elWrZ = er.GetElementNormal(); Vector3d elZ = new Vector3d(elWrZ.X, elWrZ.Y, elWrZ.Z); // Get y vector Vector3d elY = Vector3d.CrossProduct(elZ, elX); // Rotation to local coordinates Transform rotTrans = Transform.Rotation(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, elX, elY, elZ); // Add start and end point to a list List<Point3d> endPts = new List<Point3d> { sPos, ePos }; foreach (Curve crv in crvs) { // Rotate to local coordinates crv.Transform(rotTrans); crv.Translate((Vector3d)sPos); // Create and add extrusion Brep extrusion = Extrusion.CreateExtrusion(crv, move).ToBrep(); eSBreps.Add(extrusion); // Add curve to cap list sCap.Add(crv); // Move to end and add Curve eCrv = (Curve)crv.Duplicate(); eCrv.Translate(move); eCap.Add(eCrv); } // Cap sections eSBreps.Add(CapSections(sCap)); eSBreps.Add(CapSections(eCap)); } return eSBreps; }
protected override void SolveInstance(IGH_DataAccess DA) { BeamProperties prop = null; Line ln = Line.Unset; Vector3d norm = Vector3d.Unset; if (!DA.GetData(0, ref ln)) { return; } if (!DA.GetData(1, ref prop)) { return; } if (!DA.GetData(2, ref norm)) { return; } norm.Unitize(); //Check if angle between tangent and normal is less than 1 degree if (Vector3d.VectorAngle(norm, ln.UnitTangent) < 0.0174 || Vector3d.VectorAngle(-norm, ln.UnitTangent) < 0.0174) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The given normal is within 1 degree of the tangent of the centre line. Please adjust normal"); return; } double factor = Utilities.GetScalingFactorFromRhino(); WR_Vector wrNorm = new WR_Vector(norm.X, norm.Y, norm.Z); WR_XYZ st = new WR_XYZ(ln.FromX * factor, ln.FromY * factor, ln.FromZ * factor); WR_XYZ en = new WR_XYZ(ln.ToX * factor, ln.ToY * factor, ln.ToZ * factor); WR_Elem3dRcp beam = new WR_Elem3dRcp(st, en, prop.StartRelease, prop.EndRelease, prop.CrossSection, prop.Material, wrNorm, prop.OptimizationProperties); DA.SetData(0, beam); }
static public List <Brep> CreateSectionSweeps(WR_Elem3dRcp er) { List <Curve> crvs; List <Brep> eSBreps = new List <Brep>(); // Start and end caps List <Curve> sCap = new List <Curve>(); List <Curve> eCap = new List <Curve>(); if (CrossSectionCasts.GetSectionPropertyCrvs(er.GetSectionString(), out crvs)) { // Get x vector Point3d sPos = er.GetStartPos().ConvertToRhinoPoint(); Point3d ePos = er.GetEndPos().ConvertToRhinoPoint(); Vector3d elX = new Vector3d(ePos.X - sPos.X, ePos.Y - sPos.Y, ePos.Z - sPos.Z); double elLength = elX.Length; elX.Unitize(); Vector3d move = elX * elLength; // Get normal (z vector) WR_Vector elWrZ = er.GetElementNormal(); Vector3d elZ = new Vector3d(elWrZ.X, elWrZ.Y, elWrZ.Z); // Get y vector Vector3d elY = Vector3d.CrossProduct(elZ, elX); // Rotation to local coordinates Transform rotTrans = Transform.Rotation(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, elX, elY, elZ); // Add start and end point to a list List <Point3d> endPts = new List <Point3d> { sPos, ePos }; foreach (Curve crv in crvs) { // Rotate to local coordinates crv.Transform(rotTrans); crv.Translate((Vector3d)sPos); // Create and add extrusion Brep extrusion = Extrusion.CreateExtrusion(crv, move).ToBrep(); eSBreps.Add(extrusion); // Add curve to cap list sCap.Add(crv); // Move to end and add Curve eCrv = (Curve)crv.Duplicate(); eCrv.Translate(move); eCap.Add(eCrv); } // Cap sections eSBreps.Add(CapSections(sCap)); eSBreps.Add(CapSections(eCap)); } return(eSBreps); }
protected override void SolveInstance(IGH_DataAccess DA) { BeamProperties prop = null; Line ln = Line.Unset; Vector3d norm = Vector3d.Unset; if (!DA.GetData(0, ref ln)) { return; } if (!DA.GetData(1, ref prop)) { return; } if (!DA.GetData(2, ref norm)) { return; } norm.Unitize(); //Check if angle between tangent and normal is less than 1 degree if(Vector3d.VectorAngle(norm, ln.UnitTangent) < 0.0174 || Vector3d.VectorAngle(-norm, ln.UnitTangent) < 0.0174) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The given normal is within 1 degree of the tangent of the centre line. Please adjust normal"); return; } double factor = Utilities.GetScalingFactorFromRhino(); WR_Vector wrNorm = new WR_Vector(norm.X, norm.Y, norm.Z); WR_XYZ st = new WR_XYZ(ln.FromX* factor, ln.FromY* factor, ln.FromZ* factor); WR_XYZ en = new WR_XYZ(ln.ToX* factor, ln.ToY* factor, ln.ToZ* factor); WR_Elem3dRcp beam = new WR_Elem3dRcp(st, en, prop.StartRelease, prop.EndRelease, prop.CrossSection, prop.Material, wrNorm, prop.OptimizationProperties); DA.SetData(0, beam); }