protected override void SolveInstance(IGH_DataAccess DA) { sMaterial material = null; double diameter = 0.0; double thickness = 0.0; if (!DA.GetData(0, ref material)) { return; } if (!DA.GetData(1, ref diameter)) { return; } if (!DA.GetData(2, ref thickness)) { return; } sCrossSection cs = new sCrossSection(); eSectionType stype = eSectionType.ROUND; string mss = "Round: Dia " + diameter; string shapeN = "Round_" + diameter; if (thickness > 0.0) { mss += ", Th " + thickness; shapeN += "x" + thickness; } cs.shapeName = shapeN; this.Message = mss; cs.sectionType = stype; string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); if (modelUnit == "Feet") { diameter /= 12.0; thickness /= 12.0; } diameter = Math.Round(diameter, 3); thickness = Math.Round(thickness, 3); cs.dimensions = new List <double>(); cs.dimensions.Add(rhcon.EnsureUnit(diameter)); if (thickness > 0.0) { cs.dimensions.Add(rhcon.EnsureUnit(thickness)); } cs.material = material; DA.SetData(0, cs); }
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); List <sFixity> fixs = new List <sFixity>(); fixs.Add(sb.fixityAtStart); fixs.Add(sb.fixityAtEnd); List <sLineLoad> lls = new List <sLineLoad>(); if (sb.lineLoads != null && sb.lineLoads.Count > 0) { lls = rhcon.EnsureUnit(sb.lineLoads).ToList(); } DA.SetData(0, sb.frameName); DA.SetData(1, sb.frameID); DA.SetData(2, (Line)rhcon.EnsureUnit(rhcon.ToRhinoLine(sb.axis))); DA.SetData(3, sb.crossSection); DA.SetData(4, rhcon.ToRhinoVector3d(sb.upVector)); DA.SetDataList(5, lls); DA.SetDataList(6, fixs); }
protected override void SolveInstance(IGH_DataAccess DA) { IFrameSet bs = null; if (!DA.GetData(0, ref bs)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter("Meters", modelUnit); List <sFixity> fixs = new List <sFixity>(); //fixs.Add(bs.fixityAtStart); //fixs.Add(bs.fixityAtEnd); List <sLineLoad> lls = new List <sLineLoad>(); if (bs.lineLoads != null && bs.lineLoads.Count > 0) { lls = rhcon.EnsureUnit(bs.lineLoads).ToList(); } DA.SetData(0, bs.frameSetName); DA.SetData(1, rhcon.EnsureUnit(rhcon.ToRhinoCurve(bs.parentCrv))); DA.SetData(2, bs.crossSection); DA.SetDataList(3, bs.frames); DA.SetDataList(4, lls); DA.SetDataList(5, fixs); }
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); }
protected override void SolveInstance(IGH_DataAccess DA) { Point3d point = Point3d.Unset; string pattern = ""; Vector3d force = Vector3d.Unset; Vector3d moment = Vector3d.Unset; if (!DA.GetData(0, ref point)) { return; } if (!DA.GetData(1, ref pattern)) { return; } DA.GetData(2, ref force); DA.GetData(3, ref moment); string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); int count = 0; sPointLoad pl = new sPointLoad(); pl.location = rhcon.TosXYZ(rhcon.EnsureUnit(point)); pl.loadPatternName = pattern; if (force != Vector3d.Unset) { pl.forceVector = rhcon.TosXYZ(force); count++; } if (moment != Vector3d.Unset) { pl.momentVector = rhcon.TosXYZ(moment); count++; } if (count > 0) { DA.SetData(0, rhcon.EnsureUnit(pl)); } else { DA.SetData(0, null); } }
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); Brep bb = rhcon.EnsureUnit(rhcon.ToRhinoBeamPreview(sb)) as Brep; DA.SetData(0, sb.frameName); DA.SetData(1, sb.frameID); DA.SetData(2, bb); }
protected override void SolveInstance(IGH_DataAccess DA) { sPointSupport sn = null; if (!DA.GetData(0, ref sn)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter("Meters", modelUnit); DA.SetData(0, rhcon.EnsureUnit(rhcon.ToRhinoPoint3d(sn.location))); DA.SetData(1, sn.supportType.ToString()); if (sn.constraints != null) { DA.SetDataList(2, sn.constraints.ToList()); } else { DA.SetDataList(2, null); } if (sn.reaction_force != null) { DA.SetData(3, rhcon.EnsureUnit_Force(rhcon.ToRhinoVector3d(sn.reaction_force))); } else { DA.SetData(3, null); } if (sn.reaction_moment != null) { DA.SetData(4, rhcon.EnsureUnit_Moment(rhcon.ToRhinoVector3d(sn.reaction_moment))); } else { DA.SetData(4, null); } }
protected override void SolveInstance(IGH_DataAccess DA) { string patternName = ""; List <Vector3d> forceVectors = new List <Vector3d>(); if (!DA.GetData(0, ref patternName)) { return; } if (!DA.GetDataList(1, forceVectors)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); object outobj = null; if (forceVectors.Count == 1) { sLineLoad l_before = new sLineLoad(patternName, eLoadType.DistributedLoad, true, rhcon.TosXYZ(forceVectors[0])); outobj = rhcon.EnsureUnit(l_before); } else if (forceVectors.Count > 1) { sLineLoadGroup lg = new sLineLoadGroup(); lg.loads = new List <sLineLoad>(); foreach (Vector3d lv in forceVectors) { sLineLoad sl = new sLineLoad(patternName, eLoadType.DistributedLoad, true, rhcon.TosXYZ(lv)); lg.loads.Add(rhcon.EnsureUnit(sl)); } outobj = lg; } DA.SetData(0, outobj); }
protected override void SolveInstance(IGH_DataAccess DA) { ISystem sghSystem = null; if (!DA.GetData(0, ref sghSystem)) { return; } List <Mesh> ms = new List <Mesh>(); string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter("Meters", modelUnit); if (sghSystem != null) { foreach (sMesh sm in sghSystem.meshes) { Mesh rm = rhcon.ToRhinoMesh(sm); ms.Add(rhcon.EnsureUnit(rm) as Mesh); } } DA.SetDataList(0, ms); }
protected override void SolveInstance(IGH_DataAccess DA) { sPointLoad sn = null; if (!DA.GetData(0, ref sn)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter("Meters", modelUnit); DA.SetData(0, rhcon.EnsureUnit(rhcon.ToRhinoPoint3d(sn.location))); DA.SetData(1, sn.loadPatternName); if (sn.forceVector != null) { DA.SetData(2, rhcon.EnsureUnit_Force(rhcon.ToRhinoVector3d(sn.forceVector))); } if (sn.momentVector != null) { DA.SetData(3, rhcon.EnsureUnit_Moment(rhcon.ToRhinoVector3d(sn.momentVector))); } }
protected override void SolveInstance(IGH_DataAccess DA) { sSystem ssys = null; string meshName = ""; List <Mesh> ms = new List <Mesh>(); System.Drawing.Color col = System.Drawing.Color.Empty; if (!DA.GetData(0, ref ssys)) { return; } if (!DA.GetData(1, ref meshName)) { return; } if (!DA.GetDataList(2, ms)) { return; } if (!DA.GetData(3, ref col)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); Mesh bm = new Mesh(); foreach (Mesh m in ms) { Mesh ensuredM = rhcon.EnsureUnit(m) as Mesh; bm.Append(ensuredM); } bm.Vertices.CombineIdentical(false, false); for (int i = 0; i < bm.Vertices.Count; ++i) { bm.VertexColors.SetColor(i, col); } int count = 0; List <string> meshNames = new List <string>(); foreach (sMesh sm in ssys.meshes) { if (sm.meshName == meshName) { count++; } meshNames.Add(sm.meshName); } string mms = "Appended Meshes"; if (count == 0) { sMesh sm = rhcon.TosMesh(bm); sm.opacity = (double)(col.A) / (255.0); sm.meshName = meshName; ssys.meshes.Add(sm); } foreach (string mn in meshNames) { mms += "\n" + mn; } this.Message = mms; DA.SetData(0, ssys); }
protected override void SolveInstance(IGH_DataAccess DA) { sSystemSetting sysSetting = null; List <object> sElement = new List <object>(); DA.GetData(0, ref sysSetting); if (!DA.GetDataList(1, sElement)) { return; } sRhinoConverter rhcon = new sRhinoConverter(); string currentUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); if (sysSetting == null) { sysSetting = new sSystemSetting(); sysSetting.systemOriUnit = currentUnit; sysSetting.systemName = "DefaultSetting"; sysSetting.currentCase = "DEAD"; sysSetting.currentCheckType = eSystemCheckType.StrengthCheck; sysSetting.currentStressThreshold_pascal = 25 * 6894757.28; sysSetting.currentDeflectionThreshold_mm = 100; sysSetting.mergeTolerance_m = 0.005; sysSetting.meshDensity_m = 0.5; } if (currentUnit == "Meters" || currentUnit == "Feet") { ISystem jsys = InitiateISystem(sElement); jsys.systemSettings = sysSetting; List <IsObject> sObjs = new List <IsObject>(); jsys.loadPatterns.Add("DEAD"); int supCount = 0; int nodeID = 0; try { foreach (object so in sElement) { GH_ObjectWrapper wap = new GH_ObjectWrapper(so); IFrameSet bs = wap.Value as IFrameSet; if (bs != null) { //jsys.beamSets.Add(bs); jsys.AddsBeamSet(bs); //?? sObjs.Add(bs); if (bs.lineLoads != null) { foreach (sLineLoad ll in bs.lineLoads) { jsys.AwarePatternNames(ll.loadPatternName); } } } sPointLoad pl = wap.Value as sPointLoad; if (pl != null) { if (jsys.UpdateNodeFromPointElement(pl, nodeID)) { nodeID++; jsys.AwarePatternNames(pl.loadPatternName); } } sLoadCombination com = wap.Value as sLoadCombination; if (com != null) { jsys.SetLoadCombination(com); } } foreach (object so in sElement) { GH_ObjectWrapper wap = new GH_ObjectWrapper(so); sPointSupport psup = wap.Value as sPointSupport; if (psup != null) { if (jsys.UpdateNodeFromPointElement(psup, nodeID)) { nodeID++; } supCount++; } } foreach (sMesh am in jsys.meshes) { // sObjs.Add(am); } if (supCount > 0) { this.Message = "System : " + sysSetting.systemName + "\nis instantiated"; jsys.systemSettings.systemBoundingBox = rhcon.TosBoundingBox(sObjs); //jsys.SystemName = sysSetting.systemName; DA.SetData(0, jsys); } else { this.Message = "System : " + sysSetting.systemName + "\nneeds supports"; //jsys.SystemName = sysSetting.systemName; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, this.Message); DA.SetData(0, null); } } catch (Exception e) { this.Message = "System : " + sysSetting.systemName + "\ninstantiation failed"; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); DA.SetData(0, null); } } else { this.Message = "ASKSGH.Bridgify only works in\n Meters or Feet"; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, this.Message); DA.SetData(0, null); } }
protected override void SolveInstance(IGH_DataAccess DA) { string beamSetName = ""; List <Curve> beamSetCurves = new List <Curve>(); List <sCrossSection> crossSections = new List <sCrossSection>(); List <object> lineLoadObjs = new List <object>(); if (!DA.GetData(0, ref beamSetName)) { return; } if (!DA.GetDataList(1, beamSetCurves)) { return; } if (!DA.GetDataList(2, crossSections)) { return; } DA.GetDataList(3, lineLoadObjs); List <IFrameSet> sets = new List <IFrameSet>(); string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); int minuteCount = 0; for (int i = 0; i < beamSetCurves.Count; ++i) { if (beamSetCurves[i].GetLength() > 0.005) { Curve rc = rhcon.EnsureUnit(beamSetCurves[i]); sCurve setCrv = rhcon.TosCurve(rc); IFrameSet bset = new sFrameSet(setCrv); bset.frameSetName = beamSetName; bset.setId = i; if (crossSections.Count == 1) { bset.crossSection = crossSections[0] as sCrossSection; } else if (crossSections.Count == beamSetCurves.Count) { bset.crossSection = crossSections[i] as sCrossSection; } if (lineLoadObjs.Count > 0) { foreach (object lo in lineLoadObjs) { GH_ObjectWrapper wap = new GH_ObjectWrapper(lo); sLineLoad sl = wap.Value as sLineLoad; if (sl != null) { bset.UpdateLineLoad(sl); } sLineLoadGroup sg = wap.Value as sLineLoadGroup; if (sg != null) { if (sg.loads.Count == beamSetCurves.Count) { bset.UpdateLineLoad(sg.loads[i]); } else { return; } } } } sets.Add(bset); } else { minuteCount++; } } if (minuteCount > 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, minuteCount + "Beams are too short"); } DA.SetDataList(0, sets); }
protected override void SolveInstance(IGH_DataAccess DA) { List <IFrameSet> beamsets = new List <IFrameSet>(); List <Vector3d> upvectors = new List <Vector3d>(); if (!DA.GetDataList(0, beamsets)) { return; } if (!DA.GetDataList(1, upvectors)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); sRhinoConverter rhcon_ToRhinoModel = new sRhinoConverter("Meters", modelUnit); List <IFrameSet> duplicated = new List <IFrameSet>(); List <Point3d> pts = new List <Point3d>(); List <Vector3d> vecs = new List <Vector3d>(); this.Message = ""; int nonSegCount = 0; if (upvectors.Count == beamsets.Count) { for (int i = 0; i < beamsets.Count; ++i) { if (beamsets[i].frames.Count > 0) { sXYZ upvecThis = rhcon.TosXYZ(upvectors[i]); IFrameSet dubs = beamsets[i].DuplicatesFrameSet(); dubs.EnsureBeamElement(); foreach (sFrame sb in dubs.frames) { sb.AwareLocalPlane(upvecThis); pts.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.5)))); vecs.Add(rhcon.ToRhinoVector3d(sb.upVector)); } duplicated.Add(dubs); } else { nonSegCount++; } } } else if (upvectors.Count == 1) { foreach (IFrameSet bs in beamsets) { if (bs.frames.Count > 0) { IFrameSet dubs = bs.DuplicatesFrameSet(); dubs.EnsureBeamElement(); foreach (sFrame sb in dubs.frames) { sb.AwareLocalPlane(rhcon.TosXYZ(upvectors[0])); pts.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.5)))); vecs.Add(rhcon.ToRhinoVector3d(sb.upVector)); } duplicated.Add(dubs); } else { nonSegCount++; } } } else { this.Message = ""; return; } if (nonSegCount == 0) { DA.SetDataList(0, duplicated); DA.SetDataList(1, pts); DA.SetDataList(2, vecs); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Segmentize Beam Set First To Assign Upvectors"); //this.Message = "Segmentize Beam Set First To Assign Upvectors"; } }
protected override void SolveInstance(IGH_DataAccess DA) { Brep b = null; List <Point3d> lpts = new List <Point3d>(); Vector3d projection = Vector3d.Unset; if (!DA.GetData(0, ref b)) { return; } if (!DA.GetDataList(1, lpts)) { return; } if (!DA.GetData(2, ref projection)) { return; } List <Curve> voronoi = new List <Curve>(); List <Point3d> lpps = new List <Point3d>(); List <double> areas = new List <double>(); projection.Unitize(); sRhinoConverter rhcon = new sRhinoConverter(); Vector3d loadDirection = Vector3d.ZAxis * -1; if (b.Faces.Count == 1) { Surface srf = b.Faces[0].ToNurbsSurface(); Vector3d orinv = srf.NormalAt(srf.Domain(0).Mid, srf.Domain(1).Mid); if (srf.IsPlanar()) { List <Grasshopper.Kernel.Geometry.Voronoi.Cell2> cells = rhcon.GetVoronoiCells(lpts, b); for (int i = 0; i < cells.Count; ++i) { if (cells[i] == null) { continue; } Curve cellcrv = cells[i].ToPolyline().ToNurbsCurve(); Curve pushed = srf.Pushup(cellcrv, 0.001); Point3d selected = Point3d.Unset; //Brep cb = Brep.CreatePlanarBreps(pushed)[0]; foreach (Point3d lp in lpts) { Plane ppl = new Plane(lp, orinv); if (pushed.Contains(lp, ppl) == PointContainment.Inside || pushed.Contains(lp, ppl) == PointContainment.Coincident) //if (cb.ClosestPoint(lp).DistanceTo(lp) < 0.005) { selected = lp; break; } } if (selected != Point3d.Unset) { lpps.Add(selected); AreaMassProperties ampOri = AreaMassProperties.Compute(pushed); if (projection != Vector3d.Unset) { Plane plTo = new Plane(ampOri.Centroid, projection); Curve projected = pushed.DuplicateCurve(); projected.Transform(Transform.PlanarProjection(plTo)); areas.Add(AreaMassProperties.Compute(projected).Area); voronoi.Add(projected); loadDirection = projection; } else { areas.Add(ampOri.Area); voronoi.Add(pushed); loadDirection = orinv; } } } this.Message = ""; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please use a planar brep"); this.Message = "Please use a planar brep"; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please use a single face brep"); this.Message = "Please use a single face brep"; } DA.SetDataList(0, lpps); DA.SetDataList(1, voronoi); DA.SetDataList(2, areas); DA.SetData(3, loadDirection); }
protected override void SolveInstance(IGH_DataAccess DA) { Brep b = null; List <Line> lns = new List <Line>(); double segLength = -1.0; Vector3d projection = Vector3d.Unset; if (!DA.GetData(0, ref b)) { return; } if (!DA.GetDataList(1, lns)) { return; } if (!DA.GetData(2, ref segLength)) { return; } if (!DA.GetData(3, ref projection)) { return; } projection.Unitize(); sRhinoConverter rhcon = new sRhinoConverter(); Vector3d loadDirection = Vector3d.ZAxis * -1; List <Line> beamlns = new List <Line>(); DataTree <Curve> voronois = new DataTree <Curve>(); DataTree <double> triAreas = new DataTree <double>(); DataTree <Interval> parameters = new DataTree <Interval>(); if (b.Faces.Count == 1) { Surface srf = b.Faces[0].ToNurbsSurface(); Vector3d orinv = srf.NormalAt(srf.Domain(0).Mid, srf.Domain(1).Mid); if (srf.IsPlanar()) { List <Point3d> lpts = new List <Point3d>(); foreach (Line l in lns) { int den = 0; Curve bc = l.ToNurbsCurve(); if (segLength > 0.0) { den = (int)(bc.GetLength() / segLength); } if (den < 3) { den = 3; } Point3d[] segPts; bc.DivideByCount(den, false, out segPts); for (int i = 0; i < segPts.Length; ++i) { lpts.Add(segPts[i]); } lpts.Add(bc.PointAtLength(0.05)); lpts.Add(bc.PointAtLength(bc.GetLength() - 0.05)); } List <Grasshopper.Kernel.Geometry.Voronoi.Cell2> cells = rhcon.GetVoronoiCells(lpts, b); int branchID = 0; foreach (Line ll in lns) { GH_Path bpth = new GH_Path(branchID); beamlns.Add(ll); Curve checkCrv = GetShortenBeamAxis(ll, 0.05).ToNurbsCurve(); checkCrv.Domain = new Interval(0.0, 1.0); for (int i = 0; i < cells.Count; ++i) { if (cells[i] == null) { continue; } Curve cellcrv = cells[i].ToPolyline().ToNurbsCurve(); Curve pushedCell = srf.Pushup(cellcrv, 0.001); Rhino.Geometry.Intersect.CurveIntersections cin = Rhino.Geometry.Intersect.Intersection.CurveCurve(checkCrv, pushedCell, 0.005, 0.005); if (cin != null && cin.Count > 0) { AreaMassProperties amp = AreaMassProperties.Compute(pushedCell); double areaThis = amp.Area; if (projection != Vector3d.Unset) { Plane plTo = new Plane(amp.Centroid, projection); Curve projected = pushedCell.DuplicateCurve(); projected.Transform(Transform.PlanarProjection(plTo)); AreaMassProperties ampProjected = AreaMassProperties.Compute(projected); voronois.Add(projected, bpth); triAreas.Add(ampProjected.Area, bpth); loadDirection = projection; } else { voronois.Add(pushedCell, bpth); triAreas.Add(areaThis, bpth); loadDirection = orinv; } Interval inv = Interval.Unset; if (cin.Count == 1) { if (cin[0].ParameterA < 0.5) { inv = new Interval(0.0, cin[0].ParameterA); } else { inv = new Interval(cin[0].ParameterA, 1.0); } } else if (cin.Count == 2) { inv = new Interval(cin[0].ParameterA, cin[1].ParameterA); } parameters.Add(inv, bpth); } } branchID++; } this.Message = ""; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please use a planar brep"); this.Message = "Please use a planar brep"; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please use a single face brep"); this.Message = "Please use a single face brep"; } DA.SetDataList(0, beamlns); DA.SetDataTree(1, voronois); DA.SetDataTree(2, triAreas); DA.SetDataTree(3, parameters); DA.SetData(4, loadDirection); }
protected override void SolveInstance(IGH_DataAccess DA) { sMaterial material = null; double width = 0.0; double depth = 0.0; double thickness = 0.0; if (!DA.GetData(0, ref material)) { return; } if (!DA.GetData(1, ref width)) { return; } if (!DA.GetData(2, ref depth)) { return; } if (!DA.GetData(3, ref thickness)) { return; } sCrossSection cs = new sCrossSection(); string mss = ""; string shapeN = ""; if (Math.Abs(width - depth) < 0.0001) { cs.sectionType = eSectionType.SQUARE; mss = "Square: W" + width + ", D" + depth; shapeN += "Square_" + width + "x" + depth; } else { cs.sectionType = eSectionType.RECTANGLAR; mss = "Rectangular: W" + width + ", D" + depth; shapeN += "Rectangular_" + width + "x" + depth; } if (thickness > 0.0) { mss += ", Th " + thickness; shapeN += "x" + thickness; } cs.shapeName = shapeN; string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); if (modelUnit == "Feet") { width /= 12.0; depth /= 12.0; thickness /= 12.0; } width = Math.Round(width, 3); depth = Math.Round(depth, 3); thickness = Math.Round(thickness, 3); cs.dimensions = new List <double>(); cs.dimensions.Add(rhcon.EnsureUnit(width)); cs.dimensions.Add(rhcon.EnsureUnit(depth)); if (thickness > 0.0) { cs.dimensions.Add(rhcon.EnsureUnit(thickness)); } cs.material = material; this.Message = mss; DA.SetData(0, cs); }
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); }
protected override void SolveInstance(IGH_DataAccess DA) { List <object> seles = new List <object>(); double intTol = 0.005; double segTol = 0.5; if (!DA.GetDataList(0, seles)) { return; } if (!DA.GetData(1, ref intTol)) { return; } if (!DA.GetData(2, ref segTol)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); if (modelUnit == "Feet") { intTol = 0.015; segTol = 1.5; } List <object> pelements = new List <object>(); List <IFrameSet> beamelements = new List <IFrameSet>(); foreach (object o in seles) { GH_ObjectWrapper wap = new GH_ObjectWrapper(o); IFrameSet bsori = wap.Value as IFrameSet; if (bsori != null) { beamelements.Add(bsori.DuplicatesFrameSet()); } sPointLoad pl = wap.Value as sPointLoad; if (pl != null) { pelements.Add(pl); } sPointSupport ps = wap.Value as sPointSupport; if (ps != null) { pelements.Add(ps); } } rhcon.SplitSegmentizesBeamSet(ref beamelements, intTol, segTol, pelements); /* * string groupInfo = ""; * DataTree<sBeamSet> beamTree = new DataTree<sBeamSet>(); * var grouped = beamelements.GroupBy(b => b.beamSetName); * int groupID = 0; * foreach (var bgroup in grouped) * { * GH_Path bpth = new GH_Path(groupID); * groupInfo += "BeamSet" + groupID + ": " + bgroup.ElementAt(0).beamSetName + "\n"; * foreach (sBeamSet sb in bgroup) * { * beamTree.Add(sb, bpth); * } * groupID++; * } * * this.Message = groupInfo; */ DA.SetDataList(0, beamelements); DA.SetDataList(1, pelements); }
protected override void SolveInstance(IGH_DataAccess DA) { List <object> sBeamObjs = new List <object>(); Brep b = null; double tol = 0.05; if (!DA.GetDataList(0, sBeamObjs)) { return; } if (!DA.GetData(1, ref b)) { return; } if (!DA.GetData(2, ref tol)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); sRhinoConverter rhcon_ToRhinoModel = new sRhinoConverter("Meters", modelUnit); Brep scaleB = rhcon.EnsureUnit(b); List <Point3d> pts = new List <Point3d>(); List <Vector3d> vecs = new List <Vector3d>(); List <object> duplicated = new List <object>(); int nonSegmentizedCount = 0; this.Message = ""; foreach (object ob in sBeamObjs) { GH_ObjectWrapper wap = new GH_ObjectWrapper(ob); IFrameSet bs = wap.Value as IFrameSet; if (bs != null) { IFrameSet dubs = bs.DuplicatesFrameSet(); if (dubs.frames.Count > 0) { dubs.EnsureBeamElement(); rhcon.AwareBeamUpVectorsOnBrep(ref dubs, scaleB, tol); foreach (sFrame ssb in dubs.frames) { pts.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(ssb.axis.PointAt(0.5)))); vecs.Add(rhcon.ToRhinoVector3d(ssb.upVector)); } duplicated.Add(dubs); } else { nonSegmentizedCount++; } } /* * sBeam sb = wap.Value as sBeam; * if(sb != null) * { * sBeam dusb = sb.DuplicatesBeam(); * Vector3d nv = rhcon.GetNormalVectorAtPointOnBrep(rhcon.ToRhinoPoint3d(dusb.axis.PointAt(0.5)), scaleB, tol); * dusb.AwareLocalPlane(rhcon.TosXYZ(nv)); * duplicated.Add(dusb); * } */ } if (nonSegmentizedCount == 0) { DA.SetDataList(0, duplicated); DA.SetDataList(1, pts); DA.SetDataList(2, vecs); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Segmentize Beam Set First To Assign Upvectors"); //this.Message = "Segmentize Beam Set First To Assign Upvectors"; } }
protected override void SolveInstance(IGH_DataAccess DA) { List <IFrameSet> bsets = new List <IFrameSet>(); double tol = 0.005; if (!DA.GetDataList(0, bsets)) { return; } if (!DA.GetData(1, ref tol)) { return; } sFixity fxS = null; sFixity fxE = null; if (fixType == eFixityType.MOMENTREALESED_START) { fxS = new sFixity(); fxS.release = new bool[6] { true, true, true, false, false, false }; } else if (fixType == eFixityType.MOMENTREALESED_END) { fxE = new sFixity(); fxE.release = new bool[6] { true, true, true, false, false, false }; } else if (fixType == eFixityType.MOMENTREALESED_BOTH) { fxS = new sFixity(); fxS.release = new bool[6] { true, true, true, false, false, false }; fxE = new sFixity(); fxE.release = new bool[6] { true, true, true, true, false, false }; } else if (fixType == eFixityType.FIXITIES_BY_DOF) { List <bool> sss = new List <bool>(); List <bool> eee = new List <bool>(); if (!DA.GetDataList(2, sss)) { return; } if (!DA.GetDataList(3, eee)) { return; } bool[] fixedSet = new bool[6] { true, true, true, true, true, true }; if (sss.Count != 6) { sss = fixedSet.ToList(); } if (eee.Count != 6) { eee = fixedSet.ToList(); } fxS = new sFixity(); fxS.release = sss.ToArray(); fxE = new sFixity(); fxE.release = eee.ToArray(); } else if (fixType == eFixityType.FULLY_FIXED) { fxS = null; fxE = null; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); sRhinoConverter rhcon_ToRhinoModel = new sRhinoConverter("Meters", modelUnit); if (modelUnit == "Feet") { tol = 0.015; } List <IFrameSet> duplicated = new List <IFrameSet>(); List <Point3d> locsStart = new List <Point3d>(); List <Point3d> locsEnd = new List <Point3d>(); foreach (IFrameSet bso in bsets) { IFrameSet bs = bso.DuplicatesFrameSet(); bs.ResetFixities(); if (bs.parentSegments.Count > 0) { if (fxS != null) { bs.segmentFixitiesAtStart = new List <sFixity>(); } if (fxE != null) { bs.segmentFixitiesAtEnd = new List <sFixity>(); } foreach (sCurve segc in bs.parentSegments) { Curve segrc = rhcon.ToRhinoCurve(segc); if (fxS != null) { fxS.location = rhcon.TosXYZ(segrc.PointAtStart); if (fxS.IsOnLocation(bs.associatedLocations, tol) == false) { bs.segmentFixitiesAtStart.Add(fxS.DuplicatesFixity()); } } if (fxE != null) { fxE.location = rhcon.TosXYZ(segrc.PointAtEnd); if (fxE.IsOnLocation(bs.associatedLocations, tol) == false) { bs.segmentFixitiesAtEnd.Add(fxE.DuplicatesFixity()); } } } bs.AwareElementFixitiesBySegementFixities(tol); } else { Curve rc = rhcon.ToRhinoCurve(bs.parentCrv); if (fxS != null && bs.parentFixityAtStart == null) { fxS.location = rhcon.TosXYZ(rc.PointAtStart); if (fxS.IsOnLocation(bs.associatedLocations, tol) == false) { bs.parentFixityAtStart = fxS.DuplicatesFixity(); } } if (fxE != null && bs.parentFixityAtEnd == null) { fxE.location = rhcon.TosXYZ(rc.PointAtEnd); if (fxE.IsOnLocation(bs.associatedLocations, tol) == false) { bs.parentFixityAtEnd = fxE.DuplicatesFixity(); } } bs.AwareElementsFixitiesByParentFixity(tol); } duplicated.Add(bs); } foreach (IFrameSet bs in duplicated) { if (bs.frames.Count == 0) { Curve rc = rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoCurve(bs.parentCrv)); if (bs.parentFixityAtStart != null) { locsStart.Add(rc.PointAtNormalizedLength(0.025)); } if (bs.parentFixityAtEnd != null) { locsEnd.Add(rc.PointAtNormalizedLength(0.975)); } } else { foreach (sFrame sb in bs.frames) { if (sb.fixityAtStart != null) { locsStart.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.1)))); } if (sb.fixityAtEnd != null) { locsEnd.Add(rhcon_ToRhinoModel.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.9)))); } } } } this.Message = fixType.ToString(); DA.SetDataList(0, duplicated); DA.SetDataList(1, locsStart); DA.SetDataList(2, locsEnd); }
protected override void SolveInstance(IGH_DataAccess DA) { List <Point3d> points = new List <Point3d>(); if (!DA.GetDataList(0, points)) { return; } List <sPointSupport> nodes = new List <sPointSupport>(); string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); if (supType == eSupportType.FIXED || supType == eSupportType.PINNED) { for (int i = 0; i < points.Count; ++i) { sXYZ sp = rhcon.TosXYZ((Point3d)rhcon.EnsureUnit(points[i])); sPointSupport n = new sPointSupport(); n.location = sp; n.supportType = supType; nodes.Add(n); } } else { bool xx = true; bool yy = true; bool zz = true; bool rxx = true; bool ryy = true; bool rzz = true; if (!DA.GetData(1, ref xx)) { return; } if (!DA.GetData(2, ref yy)) { return; } if (!DA.GetData(3, ref zz)) { return; } if (!DA.GetData(4, ref rxx)) { return; } if (!DA.GetData(5, ref ryy)) { return; } if (!DA.GetData(6, ref rzz)) { return; } foreach (Point3d p in points) { sXYZ sp = rhcon.TosXYZ((Point3d)rhcon.EnsureUnit(p)); sPointSupport n = new sPointSupport(); n.location = sp; n.supportType = supType; n.constraints = new bool[6] { xx, yy, zz, rxx, ryy, rzz }; nodes.Add(n); } } if (supType == eSupportType.FIXED) { this.Message = "ALL FIXED"; } else if (supType == eSupportType.PINNED) { this.Message = "ALL PINNED"; } else { this.Message = "By Constraints"; } DA.SetDataList(0, nodes); }