protected override Result RunCommand(RhinoDoc doc, RunMode mode) { using (var go = new GetObject()) { go.SetCommandPrompt("Please select planer shade surfaces"); go.GeometryFilter = ObjectType.Surface | ObjectType.Brep; go.GroupSelect = false; go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } if (go.Objects().Count() == 0) { return(Result.Failure); } var SelectedObjs = go.Objects(); //prepare BrepObjects var shades = SelectedObjs.ToList(); //add shades to model ConvertToShades(doc, shades); return(Result.Success); } }
public Result AddApertureBySurface(RhinoDoc doc, IEnumerable <ObjRef> rooms) { //Select window geometry. using (var go2 = new GetObject()) { go2.SetCommandPrompt("Please select planer window surfaces"); go2.GeometryFilter = ObjectType.Surface; go2.GroupSelect = false; go2.DisablePreSelect(); go2.EnableSelPrevious(false); go2.SubObjectSelect = false; go2.GetMultiple(1, 0); if (go2.CommandResult() != Result.Success) { return(go2.CommandResult()); } if (go2.Objects().Count() == 0) { return(Result.Failure); } var SelectedObjs = go2.Objects(); //prepare BrepObjects var WinObjs = SelectedObjs.ToList(); //var room = rooms.First(); //var roomBrep = room.Brep(); //match window to room var matchedRoomDoors = rooms.AddDoors(WinObjs); foreach (var match in matchedRoomDoors) { var doors = match.doors; if (!doors.Any()) { continue; } foreach (var door in doors) { doc.Objects.Replace(door.id, door.brep); } //Replace the rhino object in order to be able to undo/redo doc.Objects.Replace(match.roomId, match.room); RhinoApp.WriteLine($"{doors.Count} windows have been successfully added to room {match.roomId}"); } return(Result.Success); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { using (var go = new GetObject()) { go.SetCommandPrompt("Please select closed objects for converting to Honeybee Room"); go.GeometryFilter = ObjectType.Brep; go.GetMultiple(2, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } if (go.ObjectCount <= 1) { return(go.CommandResult()); } //Must be all room objects. var rooms = go.Objects().Select(_ => _.Brep()).Where(_ => _ != null).Where(_ => _.IsSolid); //if (rooms.Any(_ => !_.IsRoom())) //{ // RhinoApp.WriteLine("Not all selected objects are Honeybee room, please double check, and convert it to room first."); // return go.CommandResult(); //} var ids = go.Objects().Select(_ => _.ObjectId).ToList(); var tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance / 10; var dupRooms = rooms.Select(_ => _.DuplicateBrep()); var adjSolver = new AdjacencySolver(dupRooms); var checkedObjs = adjSolver.Execute(tol, true); var counts = rooms.Count(); var objs = checkedObjs.ToList(); for (int i = 0; i < counts; i++) { doc.Objects.Replace(ids[i], objs[i]); //doc.Objects.Add(objs[i]); } doc.Views.Redraw(); return(Result.Success); } }
public override ElementCollection EnterElements(string prompt = "Enter elements") { GetObject gO = new GetObject(); gO.SetCustomGeometryFilter(new GetObjectGeometryFilter(FilterHandles)); //gO.GeometryFilter = ObjectType.Curve; gO.SetCommandPrompt(prompt); if (gO.GetMultiple(1, 0) == GetResult.Cancel) { throw new OperationCanceledException("Operation cancelled by user"); } var result = new ElementCollection(); foreach (ObjRef rObj in gO.Objects()) { if (Host.Instance.Handles.Links.ContainsSecond(rObj.ObjectId)) { Guid guid = Host.Instance.Handles.Links.GetFirst(rObj.ObjectId); ElementTable elementTable = Core.Instance.ActiveDocument?.Model?.Elements; if (elementTable != null && elementTable.Contains(guid)) { Element element = Core.Instance.ActiveDocument?.Model?.Elements[guid]; if (element != null) { result.Add(element); } } } } return(result); }
public static Result MeshVolume(RhinoDoc doc) { var gm = new GetObject(); gm.SetCommandPrompt("Select solid meshes for volume calculation"); gm.GeometryFilter = ObjectType.Mesh; gm.GeometryAttributeFilter = GeometryAttributeFilter.ClosedMesh; gm.SubObjectSelect = false; gm.GroupSelect = true; gm.GetMultiple(1, 0); if (gm.CommandResult() != Result.Success) { return(gm.CommandResult()); } double volume = 0.0; double volume_error = 0.0; foreach (var obj_ref in gm.Objects()) { if (obj_ref.Mesh() != null) { var mass_properties = VolumeMassProperties.Compute(obj_ref.Mesh()); if (mass_properties != null) { volume += mass_properties.Volume; volume_error += mass_properties.VolumeError; } } } RhinoApp.WriteLine("Total volume = {0:f} (+/- {1:f})", volume, volume_error); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select 2, 3, or 4 open curves"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; go.GetMultiple(2, 4); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var curves = go.Objects().Select(o => o.Curve()); var brep = Brep.CreateEdgeSurface(curves); if (brep != null) { doc.Objects.AddBrep(brep); doc.Views.Redraw(); } return(Result.Success); }
public override PanelElementCollection EnterPanelElements(string prompt = "Enter panel elements") { GetObject gO = new GetObject(); gO.SetCustomGeometryFilter(new GetObjectGeometryFilter(FilterHandles)); gO.GeometryFilter = ObjectType.Surface | ObjectType.Mesh; gO.SetCommandPrompt(prompt); if (gO.GetMultiple(1, 0) == GetResult.Cancel) { throw new OperationCanceledException("Operation cancelled by user"); } foreach (ObjRef rObj in gO.Objects()) { var result = new PanelElementCollection(); if (Host.Instance.Handles.Links.ContainsSecond(rObj.ObjectId)) { Guid guid = Host.Instance.Handles.Links.GetFirst(rObj.ObjectId); Element element = Core.Instance.ActiveDocument?.Model?.Elements[guid]; if (element != null && element is PanelElement) { result.Add((PanelElement)element); } } return(result); } return(null); }
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { GetObject go = Selection.GetValidExportObjects("Select objects to export."); var dialog = GetSaveFileDialog(); var fileSelected = dialog.ShowSaveDialog(); if (!fileSelected) { return(Result.Cancel); } bool binary = GlTFUtils.IsFileGltfBinary(dialog.FileName); if (!GetExportOptions(mode, out glTFExportOptions opts)) { return(Result.Cancel); } Rhino.DocObjects.RhinoObject[] rhinoObjects = go.Objects().Select(o => o.Object()).ToArray(); if (!DoExport(dialog.FileName, opts, binary, doc, rhinoObjects, doc.RenderSettings.LinearWorkflow)) { return(Result.Failure); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select polygon meshes to unweld"); go.GeometryFilter = ObjectType.Mesh; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } foreach (var obj_ref in go.Objects()) { var old_mesh = obj_ref.Mesh(); if (null != old_mesh) { var new_mesh = UnweldMesh(old_mesh); if (null != new_mesh && new_mesh.IsValid) { doc.Objects.Replace(go.Object(0), new_mesh); } } } doc.Views.Redraw(); return(Result.Success); }
public override NodeCollection EnterNodes(string prompt = "Enter nodes") { GetObject gO = new GetObject(); gO.SetCustomGeometryFilter(new GetObjectGeometryFilter(FilterHandles)); gO.GeometryFilter = ObjectType.Point; gO.SetCommandPrompt(prompt); if (gO.GetMultiple(1, 0) == GetResult.Cancel) { throw new OperationCanceledException("Operation cancelled by user"); } var result = new NodeCollection(); foreach (ObjRef rObj in gO.Objects()) { if (Host.Instance.Handles.Links.ContainsSecond(rObj.ObjectId)) { Guid guid = Host.Instance.Handles.Links.GetFirst(rObj.ObjectId); Node node = Core.Instance.ActiveDocument?.Model?.Nodes[guid]; if (node != null && node is Node) { result.Add(node); } } } return(result); }
private UI.FrixelReferenceData MainWindow_ReferenceFromClient(double xSize, double ySize) { // Tell user to select objects from doc var go = new GetObject(); go.SetCommandPrompt("Select a closed curve"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; go.Get(); var curves = go.Objects().Select(o => o.Curve()); if (curves.Count() == 0) { return(null); } this._lastReffedCurve = curves.First(); this._xSize = xSize; this._ySize = ySize; this._spine = GetSpine(); if (this._lastReffedCurve != null && this._spine != null) { return(Regenerate()); } else { return(null); } }
public static List <Guid> Guids(ObjectType filter) { GetObject go; while (true) { go = new GetObject(); go.AcceptNothing(true); go.AcceptEnterWhenDone(true); go.SetCommandPrompt("请选择一个或多个,之后回车确认"); go.GeometryFilter = filter; if (go.GetMultiple(1, 0) != GetResult.Object) { return(null); } List <Guid> ghCurveList1 = new List <Guid>(); Array.ForEach(go.Objects(), (ObjRef obj) => ghCurveList1.Add(obj.ObjectId)); if (ghCurveList1.Count == 0) { return(null); } return(ghCurveList1); } }
public static List <Curve> Curves() { GetObject go; while (true) { go = new GetObject(); go.AcceptNothing(true); go.AcceptEnterWhenDone(true); go.SetCommandPrompt("请选择一条或多条曲线,之后回车或者右键确认"); go.GeometryFilter = ObjectType.Curve | ObjectType.EdgeFilter; if (go.GetMultiple(1, 0) != GetResult.Object) { return(null); } List <Curve> ghCurveList1 = new List <Curve>(); Array.ForEach(go.Objects(), (ObjRef obj) => ghCurveList1.Add(obj.Curve())); if (ghCurveList1.Count == 0) { return(null); } return(ghCurveList1); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // select curves to loft var gs = new GetObject(); gs.SetCommandPrompt("select curves to loft"); gs.GeometryFilter = ObjectType.Curve; gs.DisablePreSelect(); gs.SubObjectSelect = false; gs.GetMultiple(2, 0); if (gs.CommandResult() != Result.Success) { return(gs.CommandResult()); } var curves = gs.Objects().Select(obj => obj.Curve()).ToList(); var breps = Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Tight, false); foreach (var brep in breps) { doc.Objects.AddBrep(brep); } doc.Views.Redraw(); return(Result.Success); }
public static List <GH_Point> PickPoint() { GetObject go; while (true) { go = new GetObject(); go.AcceptNothing(true); go.AcceptEnterWhenDone(true); go.SetCommandPrompt("请选择一个或多个,之后回车确认"); go.GeometryFilter = ObjectType.Point; if (go.GetMultiple(1, 0) != GetResult.Object) { return(null); } List <GH_Point> ghCurveList1 = new List <GH_Point>(); Array.ForEach(go.Objects(), (ObjRef obj) => ghCurveList1.Add(new GH_Point(obj.Point().Location))); if (ghCurveList1.Count == 0) { return(null); } return(ghCurveList1); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { RhinoApp.WriteLine("안녕하세요 방만드는기계 입니다."); // Polyline outline = new Polyline(); Polyline coreLine = new Polyline(); Polyline landing = new Polyline(); GetObject getPolyline = new GetObject(); getPolyline.SetCommandPrompt("외곽선,코어,랜딩 입력해주세요"); getPolyline.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; getPolyline.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; getPolyline.SubObjectSelect = false; getPolyline.GetMultiple(3, 0); if (getPolyline.CommandResult() != Result.Success) { RhinoApp.WriteLine("달라고!"); return(getPolyline.CommandResult()); } else { RhinoApp.WriteLine("입력받았습니다."); } if (null == getPolyline.Object(0).Curve()) { RhinoApp.WriteLine("없잖아!"); return(getPolyline.CommandResult()); } List <Polyline> testPoly = new List <Polyline>(); foreach (var i in getPolyline.Objects()) { testPoly.Add(CurveTools.ToPolyline(i.Curve())); } outline = testPoly[0]; coreLine = testPoly[1]; landing = testPoly[2]; List <Polyline> rooms = Debugger.DebugRoom(outline, coreLine, landing); foreach (Polyline i in rooms) { doc.Objects.AddCurve(i.ToNurbsCurve()); } doc.Views.Redraw(); RhinoApp.WriteLine("최선을 다했습니다만..."); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { OptionDouble amountOption = new OptionDouble(amount, 0.001, 300); OptionInteger triesOption = new OptionInteger(tries, 1, 1000); GetObject go = new GetObject(); go.SetCommandPrompt("Select meshes to Randomize"); go.AddOptionDouble("Amount", ref amountOption); go.AddOptionInteger("Tries", ref triesOption); go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh; for (;;) { GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) { tries = triesOption.CurrentValue; amount = amountOption.CurrentValue; continue; } if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } break; } if (go.ObjectCount < 1) { return(Result.Failure); } foreach (var obj in go.Objects()) { var rhinoMesh = obj.Mesh(); if (rhinoMesh == null || !rhinoMesh.IsValid) { continue; } var mesh = GopherUtil.ConvertToD3Mesh(obj.Mesh()); g3.DMesh3 outputMeshRandom; GopherUtil.RandomizeMesh(mesh, out outputMeshRandom, amount, tries); var rhinoOutputMeshRandom = GopherUtil.ConvertToRhinoMesh(outputMeshRandom); doc.Objects.Replace(obj, rhinoOutputMeshRandom); } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { GetObject go = Selection.GetValidExportObjects("Select objects to export."); var dialog = GetSaveFileDialog(); var fileSelected = dialog.ShowSaveDialog(); if (!fileSelected) { return(Result.Cancel); } bool binary = GlTFUtils.IsFileGltfBinary(dialog.FileName); var opts = new glTFExportOptions() { UseDracoCompression = false, DracoCompressionLevel = 10, DracoQuantizationBitsPosition = 11, DracoQuantizationBitsNormal = 8, DracoQuantizationBitsTexture = 10, UseBinary = binary }; if (mode == RunMode.Scripted) { Rhino.Input.RhinoGet.GetBool("Compression", true, "None", "Draco", ref opts.UseDracoCompression); if (opts.UseDracoCompression) { Rhino.Input.RhinoGet.GetInteger("Draco Compression Level (max=10)", true, ref opts.DracoCompressionLevel, 1, 10); Rhino.Input.RhinoGet.GetInteger("Quantization Position", true, ref opts.DracoQuantizationBitsPosition, 8, 32); Rhino.Input.RhinoGet.GetInteger("Quantization Normal", true, ref opts.DracoQuantizationBitsNormal, 8, 32); Rhino.Input.RhinoGet.GetInteger("Quantization Texture", true, ref opts.DracoQuantizationBitsTexture, 8, 32); } Rhino.Input.RhinoGet.GetBool("Map Rhino Z to glTF Y", true, "No", "Yes", ref opts.MapRhinoZToGltfY); } else { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(opts); if (optionsDlg.ShowModal() == null) { return(Result.Cancel); } } var rhinoObjects = go .Objects() .Select(o => o.Object()) .ToArray(); if (!DoExport(dialog.FileName, opts, rhinoObjects, doc.RenderSettings.LinearWorkflow)) { return(Result.Failure); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Get curves for boolean union BooleanUnion union = null; using (var go = new GetObject()) { go.SetCommandPrompt("Select OcCurves or OcRectangles"); go.SetCustomGeometryFilter((rho, geo, ci) => (rho is CurveObject | rho is RectangleObject)); go.GetMultiple(2, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } List <RectangleData> rects = new List <RectangleData>(); List <CurveData> crvs = new List <CurveData>(); foreach (var objRef in go.Objects()) { var rect = objRef.Object().Attributes.UserData.Find(typeof(RectangleData)) as RectangleData; if (!(rect is null)) { rects.Add(rect); continue; } var crv = objRef.Object().Attributes.UserData.Find(typeof(CurveData)) as CurveData; if (!(crv is null)) { crvs.Add(crv); continue; } } union = new BooleanUnion(rects, crvs); } var unionObj = new CurveData(((CurveData)union.Calculate()).Curve) { Calculation = union }; doc.Objects.AddRhinoObject(unionObj.CreateCustomObject(), unionObj.Curve); doc.Views.Redraw(); return(Result.Success); }
public static List <T> Pick <T>(ObjectType filter, string message) { GetObject go; while (true) { go = new GetObject(); go.AcceptNothing(true); go.AcceptEnterWhenDone(true); go.SetCommandPrompt(message); go.GeometryFilter = filter; if (go.GetMultiple(1, 0) != GetResult.Object) { return(null); } List <T> list = new List <T>(); Array.ForEach(go.Objects(), (ObjRef obj) => { dynamic geo; if (typeof(T).Name == "GH_Point") { geo = obj.Point().Location; } else if (typeof(T).Name == "GH_Curve") { geo = obj.Curve(); } else { geo = null; } if (geo != null) { list.Add(geo); } }); if (list.Count == 0) { return(null); } return(list); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject getObjs = new GetObject(); getObjs.SetCommandPrompt("Select objects for schema removal"); getObjs.GroupSelect = true; getObjs.SubObjectSelect = false; getObjs.EnableClearObjectsOnEntry(false); getObjs.EnableUnselectObjectsOnExit(false); getObjs.DeselectAllBeforePostSelect = false; bool hasPreselected = false; for (; ;) { GetResult res = getObjs.GetMultiple(1, 0); if (res != GetResult.Object) { return(Result.Cancel); } if (getObjs.ObjectsWerePreselected) { hasPreselected = true; getObjs.EnablePreSelect(false, true); continue; } break; } //This chunk just makes sure objects selected during the command stay selected afterwards. Optional. if (hasPreselected) { SelectAllCommandObjs(getObjs, doc); } List <RhinoObject> objs = getObjs.Objects().Select(o => o.Object()).ToList(); foreach (RhinoObject obj in objs) { obj.Attributes.DeleteUserString(SpeckleSchemaKey); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { using (var go = new GetObject()) { go.SetCommandPrompt("Please select honeybee rooms for adding doors to"); go.GeometryFilter = ObjectType.Brep; go.GroupSelect = false; go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } if (go.ObjectCount == 0) { return(go.CommandResult()); } //Check if all selected geoes are hb rooms. var solidBreps = go.Objects().Where(_ => _.Brep() != null).Where(_ => _.Brep().IsSolid); var rooms = solidBreps.Where(_ => _.IsRoom()).ToList(); if (solidBreps.Count() != rooms.Count()) { doc.Objects.UnselectAll(); var nonRooms = solidBreps.Where(_ => !_.Brep().IsRoom()); foreach (var item in nonRooms) { doc.Objects.Select(item, true, true); } doc.Views.Redraw(); Rhino.UI.Dialogs.ShowMessage("These are not Honeybee rooms, please use MassToRoom to convert them first!", "Honeybee Rhino Plugin"); return(Result.Failure); } var rs = AddApertureBySurface(doc, rooms); doc.Views.Redraw(); return(rs); } }
public override VertexGeometryCollection EnterGeometry(string prompt = "Enter geometry", Type geometryType = null) { GetObject gO = new GetObject(); if (geometryType == typeof(Curve)) { gO.GeometryFilter = ObjectType.Curve; } else if (geometryType == typeof(Surface)) { gO.GeometryFilter = ObjectType.Surface | ObjectType.Mesh; } else if (geometryType == typeof(Point)) { gO.GeometryFilter = ObjectType.Point; } else { gO.GeometryFilter = ObjectType.Curve | ObjectType.Surface | ObjectType.Point | ObjectType.Mesh; //TODO: Support others } gO.SetCommandPrompt(prompt); if (gO.GetMultiple(1, 0) == GetResult.Cancel) { throw new OperationCanceledException("Operation cancelled by user"); } VertexGeometryCollection result = new VertexGeometryCollection(); foreach (ObjRef objRef in gO.Objects()) { try { VertexGeometry shape = FromRC.Convert(objRef); if (shape != null) { result.Add(shape); } } catch (NotImplementedException) { Core.PrintLine(objRef.Geometry()?.GetType().Name + "s not supported!"); } } return(result); }
//============================== private Curve[] GetCurves() { GetObject go = new GetObject(); go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; go.SetCommandPrompt("Hyper Split | Split All Curves With One Another:"); go.EnablePreSelect(true, true); go.EnablePostSelect(true); go.GetMultiple(1, 0); Curve[] CurveSel = new Curve[go.ObjectCount]; TempRef = go.Objects(); for (int i = 0; i < go.ObjectCount; i++) { CurveSel[i] = go.Object(i).Curve(); } return(CurveSel); }
/// <summary> /// Append objects to dynamically draw /// </summary> public void AppendObjects(GetObject go) { if (null != go) { if (null == m_objects) { m_objects = new List <RhinoObject>(); } foreach (var objRef in go.Objects()) { var obj = objRef.Object(); if (null != obj) { m_objects.Add(obj); } } } }
/// <summary> /// Adds grip objects selected by an object getter /// </summary> public int AddGripObjects(GetObject go) { if (null == go) { return(0); } var grip_count = m_grips.Count; foreach (var obj_ref in go.Objects()) { var grip_obj = obj_ref.Object() as GripObject; if (null != grip_obj) { AddGripObject(grip_obj); } } return(m_grips.Count - grip_count); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select surfaces and polysurfaces"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var gp = new GetPointOnBreps(); gp.SetCommandPrompt("Point on surface or polysurface"); foreach (var obj_ref in go.Objects()) { gp.Breps.Add(obj_ref.Brep()); } gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } var point = gp.Point(); // One final calculation var closest_point = gp.CalculateClosestPoint(point); if (closest_point.IsValid) { doc.Objects.AddPoint(closest_point); doc.Views.Redraw(); } return(Result.Success); }
/// <summary> /// Called by Rhino when the user wants to run this command. /// </summary> protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ReportSampleSharedXformTable("Before transform table operations:"); var go = new GetObject(); go.SetCommandPrompt("Select objects to add random transformations"); go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } foreach (var obj_ref in go.Objects()) { var count = Rnd.Next(50, 100); var transforms = new Transform[count]; for (var i = 0; i < count; i++) { var degrees = Rnd.Next(0, 360); var radians = RhinoMath.ToRadians(degrees); transforms[i] = Transform.Rotation(radians, Point3d.Origin); } if (SampleSharedXformTable.Contains(obj_ref.ObjectId)) { SampleSharedXformTable.Update(obj_ref.ObjectId, transforms); } else { SampleSharedXformTable.Add(obj_ref.ObjectId, transforms); } } ReportSampleSharedXformTable("After transform table operations:"); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var getObject = new GetObject(); getObject.SetCommandPrompt("Pick objects to toggle IsClippingObject status for"); var getRc = getObject.Get(); if (getObject.CommandResult() != Result.Success) { return(getObject.CommandResult()); } if (getRc == GetResult.Object) { foreach (var o in getObject.Objects()) { var roa = o.Object().Attributes; RhinoCyclesData ud = null; if (roa != null && roa.HasUserData) { ud = roa.UserData.Find(typeof(RhinoCyclesData)) as RhinoCyclesData; } if (ud == null) { ud = new RhinoCyclesData(); } else { ud.ToggleIsClippingObject(); } RhinoApp.WriteLine($"The clipping object status for {o.Object().Name} is now {ud.IsClippingObject}"); roa.UserData.Add(ud); } return(Result.Success); } return(Result.Nothing); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { using (var go = new GetObject()) { go.SetCommandPrompt("Please select Breps for converting to json"); go.GeometryFilter = ObjectType.Brep | ObjectType.Extrusion; go.GetMultiple(1, 0); //if (go.CommandResult() != Result.Success) // return go.CommandResult(); if (go.ObjectCount == 0) { string file = @"D:\Dev\honeybee-rhino-plugin\src\HoneybeeRhino.Test\TestModels\RingFiveBreps.json"; string j = System.IO.File.ReadAllText(file); var bs = JsonConvert.DeserializeObject <List <Rhino.Geometry.Brep> >(j); foreach (var b in bs) { doc.Objects.AddBrep(b); } doc.Views.Redraw(); return(Result.Success); } var breps = go.Objects().Select(_ => _.Brep()); var json = JsonConvert.SerializeObject(breps); string tempFile = Path.Combine(Path.GetTempPath(), "temp.json"); using (StreamWriter file = new StreamWriter(tempFile, true)) { file.Write(json); } RhinoApp.WriteLine($"Saved to: {tempFile}"); return(Result.Success); } }