private void HandlesUndeleteRhinoObject(object sender, RhinoObjectEventArgs e) { ModelObject mObj = LinkedModelObject(e.ObjectId); if (mObj != null) { //TEST! /*RC.GeometryBase geometry = e.TheObject.Geometry; * * if (mObj is Element) * { * Element element = (Element)mObj; * VertexGeometry vG = RCtoFB.Convert(geometry); * if (vG != null) * { * if (element is LinearElement && vG is Curve) * ((LinearElement)element).ReplaceGeometry((Curve)vG); * else if (element is PanelElement && vG is Surface) * ((PanelElement)element).ReplaceGeometry((Surface)vG); * * _ReplacedElements.Add(element); * } * }*/ //Doesn't work! // END TEST! // TODO: Add condition to prevent this being done erroneously... _Undeleting = true; mObj.Undelete(); _Undeleting = false; } }
private static void On_UndeleteRhinoObject(object sender, RhinoObjectEventArgs e) { if (UndeleteRhinoObject == null) { return; } Shared.TryCatchAction(() => UndeleteRhinoObject(sender, e), g._RhinoDoc, "exception in UndeleteRhinoObject event"); }
static void RhinoDoc_AddRhinoObject(object sender, RhinoObjectEventArgs e) { if (e.TheObject.Document == ActiveDocument && ObjectPrimitive.IsSupportedObject(e.TheObject, true)) { Revit.EnqueueReadAction((doc, canceled) => new DocumentPreviewServer(e.TheObject).Register()); Revit.RefreshActiveView(); } }
static void RhinoDoc_DeleteRhinoObject(object sender, RhinoObjectEventArgs e) { if (e.TheObject.Document == ActiveDocument && ObjectPrimitive.IsSupportedObject(e.TheObject, false)) { Revit.EnqueueReadAction((doc, canceled) => objectPreviews[e.TheObject.Id]?.Unregister()); Revit.RefreshActiveView(); } }
public void OnObjectUndelete(RhinoObjectEventArgs ea) { //Treat like object added, without the docbox. bool sendBool = utils.properties.getPushState(); if (sendBool == false) { //Do nothing. } if (sendBool == true) { //debug.alert("Undelete event!"); string G00_Path = utils.file_structure.getPathFor("G00"); if (System.IO.File.Exists(G00_Path) == false) { System.IO.File.WriteAllText(G00_Path, "3"); } //Check if the objects being undeleted is the docBox. (May mean an undone transformation.) string D12_Path = utils.file_structure.getPathFor("D12"); string prevDocBoxID = ""; if (System.IO.File.Exists(D12_Path) == false) { //Do nothing. } else if (System.IO.File.Exists(D12_Path) == true) { prevDocBoxID = System.IO.File.ReadAllText(D12_Path); } //Do some correction if undone object is docBox. if (ea.TheObject.Id.ToString() == prevDocBoxID) { //debug.alert("DocBox transformation has been undone!"); //Correct D10.NATA after it was changed by OnDelete. string D10_Path = utils.file_structure.getPathFor("D10"); System.IO.File.WriteAllText(D10_Path, prevDocBoxID); //Update illustrator artboard. outbound.push.docBoxChanges(ea.TheObject); } //Otherwise, translate like normal. else { //Verify object to parse is a curve before translating. if (ea.TheObject.Geometry.ObjectType.ToString().ToLower().Contains("curve")) { outbound.translate.curves(3, ea.TheObject); } else { //Added object is not a curve, do nothing. } } } }
private void HandlesDeleteRhinoObject(object sender, RhinoObjectEventArgs e) { if (e.ObjectId == _LastReplaced) { _LastReplaced = Guid.Empty; } else if (!RhinoOutput.Writing) { LinkedModelObject(e.ObjectId)?.Delete(); } }
private void RhinoDoc_DeleteRhinoObject(object sender, RhinoObjectEventArgs e) { if (Paused) { Context.NotifySpeckleFrame("client-expired", StreamId, ""); return; } if (e.TheObject.Attributes.GetUserString("spk_" + StreamId) == StreamId) { DataSender.Start(); } }
private void RhinoObjectAdded(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); try { // when a sphere is added from a secondary thread this line will // throw an exception because UI controls can only be accessed from // the main UI thread m_label.Content = message; } catch (InvalidOperationException ioe) { RhinoApp.WriteLine(ioe.Message); } }
private void RhinoObjectAdded(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); try { // when a sphere is added from a secondary thread this line will // throw an exception because UI controls can only be accessed from // the main UI thread m_label.Content = message; } catch (InvalidOperationException ioe) {RhinoApp.WriteLine(ioe.Message);} }
public void ImplicitSelectionDecrease(object sender, RhinoObjectEventArgs ea, bool sendBool) { sendBool = utils.properties.getSelPushState(); if (sendBool == false) { //Do nothing. } else if (sendBool == true) { Rhino.DocObjects.RhinoObject[] newObj = new Rhino.DocObjects.RhinoObject[1]; newObj[0] = ea.TheObject; outbound.push.selectionDecrease(newObj); } }
public void OnObjectAdded(RhinoObjectEventArgs ea) { bool sendBool = utils.properties.getPushState(); if (sendBool == false) { //Do nothing. } else if (sendBool == true) { //debug.alert("Addition event!"); //Check if change being processed is the docbox. string docBoxID = utils.properties.tryGetDocBox(); if (ea.ObjectId.ToString() == docBoxID) { //Cache reference point. Rhino.Geometry.Point3d refPoint = utils.properties.getRefPoint(); string D20_Path = utils.file_structure.getPathFor("D20"); System.IO.File.WriteAllText(D20_Path, refPoint.X.ToString() + "," + refPoint.Y.ToString()); outbound.push.docBoxChanges(ea.TheObject); } else { string G00_Path = utils.file_structure.getPathFor("G00"); if (System.IO.File.Exists(G00_Path) == false) { System.IO.File.WriteAllText(G00_Path, "1"); } //Verify object to parse is a curve before translating. if (ea.TheObject.Geometry.ObjectType.ToString().ToLower().Contains("curve")) { outbound.translate.curves(1, ea.TheObject); } else { //Added object is not a curve, do nothing. } } } }
private void RhinoObjectAddedSafe(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); // checks if the calling thread is the thread the dispatcher is associated with. // In other words, checks if the calling thread is the UI thread if (m_label.Dispatcher.CheckAccess()) // if we're on the UI thread then just update the component m_label.Content = message; else { // invoke the setLabelTextDelegate on the thread the dispatcher is associated with, i.e., the UI thread var set_label_text_delegate = new Action<string>(txt => m_label.Content = txt); m_label.Dispatcher.BeginInvoke(set_label_text_delegate, new String[] { message }); } }
private void RhinoObjectAddedSafe(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); // checks if the calling thread is the thread the dispatcher is associated with. // In other words, checks if the calling thread is the UI thread if (m_label.Dispatcher.CheckAccess()) { // if we're on the UI thread then just update the component m_label.Content = message; } else { // invoke the setLabelTextDelegate on the thread the dispatcher is associated with, i.e., the UI thread var set_label_text_delegate = new Action <string>(txt => m_label.Content = txt); m_label.Dispatcher.BeginInvoke(set_label_text_delegate, new String[] { message }); } }
void DeleteObjects(object sender, RhinoObjectEventArgs args) { TimePanel.Instance.PropertiesGroupHide(); }
/// <summary> /// Called if an object is undeleted (e.g. Undo) /// </summary> void OnUndeleteRhinoObject(object sender, RhinoObjectEventArgs e) { SampleCsMobilePlaneUserData.Refresh(e.TheObject, false); }
public void OnObjectRemoved(RhinoObjectEventArgs ea) { bool sendBool = utils.properties.getPushState(); if (sendBool == false) { //Do nothing. } if (sendBool == true) { //debug.alert("Removal event!"); // string D10_Path = utils.file_structure.getPathFor("D10"); if (System.IO.File.Exists(D10_Path) == false) { //Do nothing. //debug.alert("D10 does not exist."); } //If objects being removed is the docbox: else if (System.IO.File.ReadAllText(D10_Path) == ea.TheObject.Id.ToString()) { //utils.debug.alert("DocBox was deleted!"); //Remove temporary label. string D30_Path = utils.file_structure.getPathFor("D30"); if (System.IO.File.Exists(D30_Path) == true) { Guid labelID = new Guid(System.IO.File.ReadAllText(D30_Path)); RhinoDoc.ActiveDoc.Objects.Delete(labelID, true); } //Record its GUID under D11, previous docBox information. string D11_Path = utils.file_structure.getPathFor("D11"); if (System.IO.File.Exists(D11_Path) == true) { //If D11 exists, cache it for UnDelete check. string D12_Path = utils.file_structure.getPathFor("D12"); System.IO.File.WriteAllText(D12_Path, System.IO.File.ReadAllText(D11_Path)); } System.IO.File.WriteAllText(D11_Path, ea.TheObject.Id.ToString()); //Recreate the box. utils.properties.tryGetDocBox(); } //If not, record removal event: else { string G00_Path = utils.file_structure.getPathFor("G00"); if (System.IO.File.Exists(G00_Path) == false) { System.IO.File.WriteAllText(G00_Path, "2"); } //Verify object to parse is a curve before translating. if (ea.TheObject.Geometry.ObjectType.ToString().ToLower().Contains("curve")) { outbound.translate.removals(2, ea.TheObject); } else { //Added object is not a curve, do nothing. } } } }
private void HandlesAddRhinoObject(object sender, RhinoObjectEventArgs e) { if (!RhinoOutput.Writing && !_Replacing) { if (e.TheObject.Attributes.HasUserData) { string data = e.TheObject.Attributes.GetUserString("SAL_ORIGINAL"); if (!string.IsNullOrEmpty(data) && data != e.ObjectId.ToString()) { Guid storedGuid = new Guid(data); if (this.Links.ContainsSecond(storedGuid)) { ModelObject mO = LinkedModelObject(storedGuid); //Create copy of object: if (mO is Element) { VertexGeometry geometry = FromRC.Convert(e.TheObject.Geometry); Element element = null; if (mO is LinearElement) { LinearElement lElement = ((LinearElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry); bool split = false; if (geometry is Curve) { Curve newCrv = (Curve)geometry; if (lElement.Geometry != null) { Curve oldCrv = lElement.Geometry; if (newCrv.Length < oldCrv.Length) { //TODO: Check end point distance to curve double maxDist = 0; foreach (Vertex v in newCrv.Vertices) { double dist = oldCrv.DistanceToSquared(v.Position); if (dist > maxDist) { maxDist = dist; } } if (maxDist < Tolerance.Distance) { split = true; } } } lElement.ReplaceGeometry(newCrv, split); } lElement.GenerateNodes(new NodeGenerationParameters()); element = lElement; } if (mO is PanelElement) { PanelElement pElement = ((PanelElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry); if (geometry is Surface) { pElement.ReplaceGeometry((Surface)geometry); } element = pElement; } RhinoOutput.SetOriginalIDUserString(e.ObjectId); if (element != null) { Links.Set(element.GUID, e.ObjectId); Core.Instance.ActiveDocument.Model.Add(element); } } else if (mO is Node) { if (e.TheObject.Geometry is RC.Point) { Node node = ((Node)mO).Duplicate(); RC.Point pt = (RC.Point)e.TheObject.Geometry; node.Position = FromRC.Convert(pt).Position; RhinoOutput.SetOriginalIDUserString(e.ObjectId); Links.Set(node.GUID, e.ObjectId); Core.Instance.ActiveDocument.Model.Add(node); } } } } } } }