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> 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"; } }
public void AddsBeamSet(IFrameSet bset) { bset.EnsureBeamElement(); this.frameSets.Add(bset); }