protected override Result RunCommand(RhinoDoc doc, RunMode mode) { #if DEBUG /* * setting the document as a globally accessible member, so that the converters can accsess and add * intermediate geometry to the document for examination */ RhinoV6PipeConverter.DebugUtil.Document = doc; #endif string pipeIdentifier; using (GetString getter = new GetString()) { getter.SetCommandPrompt("Enter the name/url for the pipe"); if (_prevPipeName != null) { getter.SetDefaultString(_prevPipeName); } if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input"); return(getter.CommandResult()); } pipeIdentifier = getter.StringResult(); _prevPipeName = pipeIdentifier; } if (PipeDataUtil.IsValidUrl(pipeIdentifier)) { _pipe = new MyWebPipe(pipeIdentifier); } else { _pipe = new LocalNamedPipe(pipeIdentifier); } _pipe.SetEmitter(this); try { _pipe.Update(); } catch (Exception e) { Rhino.UI.Dialogs.ShowMessage(e.Message, "Error"); } if (_objectsReceived.Count > 0) { DeletePulledObjects(pipeIdentifier, ref doc); } List <Guid> received = new List <Guid>(); foreach (var geom in _objectsReceived) { Guid id = doc.Objects.Add(geom); received.Add(id); } doc.Views.Redraw(); SavePulledObjects(pipeIdentifier, received, ref doc); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string pipeIdentifier; using (GetString getter = new GetString()) { getter.SetCommandPrompt("Enter the name/url for the pipe"); if (_prevPipeName != null) { getter.SetDefaultString(_prevPipeName); } if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input"); return(getter.CommandResult()); } pipeIdentifier = getter.StringResult(); _prevPipeName = pipeIdentifier; } if (PipeDataUtil.IsValidUrl(pipeIdentifier)) { _pipe = new MyWebPipe(pipeIdentifier); } else { _pipe = new LocalNamedPipe(pipeIdentifier); } _pipe.SetEmitter(this); try { _pipe.Update(); } catch (Exception e) { Rhino.UI.Dialogs.ShowMessageBox(e.Message, "Error"); } if (_objectsReceived.Count > 0) { DeletePulledObjects(pipeIdentifier, ref doc); } List <Guid> received = new List <Guid>(); foreach (var geom in _objectsReceived) { Guid id = doc.Objects.Add(geom); received.Add(id); } doc.Views.Redraw(); SavePulledObjects(pipeIdentifier, received, ref doc); return(Result.Success); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { string pipeId = PipeForRevit.PipeIdentifier; UIApplication uiApp = commandData.Application; _document = uiApp.ActiveUIDocument.Document; PipeForRevit.ActiveDocument = uiApp.ActiveUIDocument.Document; Selection sel = uiApp.ActiveUIDocument.Selection; Pipe pipe = null; Action callBack = () => { if (pipe != null) { pipe.ClosePipe(); } RevitPipeUtil.ShowMessage("Success", "Pushed data to the pipe."); }; if (PipeDataUtil.IsValidUrl(pipeId)) { pipe = new MyWebPipe(pipeId, callBack); } else { pipe = new LocalNamedPipe(pipeId, callBack); } pipe.SetEmitter(this); pipe.Update(); if (GeometryTypeMatch()) { bool deleteExisting; bool updateGeom = UserDecidedToUpdateGeometry(out deleteExisting); if (updateGeom) { UpdateGeometry(_receivedObjects); } else { _previousIds = AddObjectsToDocument(_receivedObjects, deleteExisting); } } else { _previousIds = AddObjectsToDocument(_receivedObjects, false); } return(Result.Succeeded); } catch (Exception e) { RevitPipeUtil.ShowMessage("Error", "The following error occured. Aborting operation.", e.Message); return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { string pipeId = PipeForRevit.PipeIdentifier; UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; PipeForRevit.ActiveDocument = uiApp.ActiveUIDocument.Document; Selection sel = uiApp.ActiveUIDocument.Selection; //List<Reference> pickedCurves = sel.PickObjects(ObjectType.Edge, "Select the curves to send through the pipe or click finish to select" + // "elements").ToList(); List <Reference> picked = sel.PickObjects(ObjectType.Element, "Select the elements to send through the pipe").ToList(); _selectedObjects = new List <GeometryObject>(); Options opt = new Options(); foreach (var objRef in picked) { GeometryElement geom = doc.GetElement(objRef).get_Geometry(opt); _selectedObjects.AddRange(geom.Where((g) => g is Solid || g is Mesh)); } //foreach (var objRef in pickedCurves) //{ // Edge edge = (Edge)doc.GetElement(objRef).GetGeometryObjectFromReference(objRef); // _selectedObjects.Add(edge); //} Pipe pipe = null; Action callBack = () => { if (pipe != null) { pipe.ClosePipe(); } RevitPipeUtil.ShowMessage("Success", "Pushed data to the pipe."); }; if (PipeDataUtil.IsValidUrl(pipeId)) { pipe = new MyWebPipe(pipeId, callBack); } else { pipe = new LocalNamedPipe(pipeId, callBack); } pipe.SetCollector(this); pipe.Update(); return(Result.Succeeded); } catch (Exception e) { RevitPipeUtil.ShowMessage("Error", "The following error occured. Aborting operation.", e.Message); return(Result.Failed); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string pipeIdentifier; using (GetString getter = new GetString()) { getter.SetCommandPrompt("Enter the name/url for the pipe"); if (_prevPipeName != null) { getter.SetDefaultString(_prevPipeName); } if (getter.Get() != GetResult.String) { RhinoApp.WriteLine("Invalid Input"); return(getter.CommandResult()); } pipeIdentifier = getter.StringResult(); _prevPipeName = pipeIdentifier; } if (_pipe != null) { _pipe.ClosePipe(); _pipe = null; } if (PipeDataUtil.IsValidUrl(pipeIdentifier)) { _pipe = new MyWebPipe(pipeIdentifier); } else { _pipe = new LocalNamedPipe(pipeIdentifier); } _pipe.SetCollector(this); _objectsToSend = new List <RhinoObject>(); using (GetObject getter = new GetObject()) { getter.EnablePreSelect(true, false); getter.SetCommandPrompt("Select all the objects to be pushed through the pipe"); getter.GroupSelect = true; getter.GetMultiple(1, 0); if (getter.CommandResult() != Result.Success) { return(getter.CommandResult()); } for (int i = 0; i < getter.ObjectCount; i++) { _objectsToSend.Add(getter.Object(i).Object()); } } try { _pipe.Update(); } catch (Exception e) { Rhino.UI.Dialogs.ShowMessageBox(e.Message, "Error"); } doc.Views.Redraw(); return(Result.Success); }