示例#1
0
 private void OnDocumentClose(GH_DocumentServer sender, GH_Document doc)
 {
     CloseLocalPipe();
     if (_webPipe != null)
     {
         _webPipe.ClosePipe();
         _webPipe = null;
     }
 }
示例#2
0
 private void PullFromWebPipe(string pipeUrl)
 {
     if (_webPipe == null || (_webPipe != null && _webPipe.Url != pipeUrl))
     {
         _webPipe = new MyWebPipe(pipeUrl);
         _webPipe.SetEmitter(this);
     }
     _webPipe.Update();
 }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        private void SendViaWebPipe(string pipeUrl)
        {
            CloseLocalPipe();
            Action finishingDelegate = () =>
            {
                ClearRuntimeMessages();
                if (_webPipe.DataPostedToUrlSuccessful)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Data posted to the url");
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "failed to post the data to url");
                }
            };

            //now send the data to the webpipe
            if (_webPipe == null || (_webPipe != null && _webPipe.Url != pipeUrl))
            {
                _webPipe = new MyWebPipe(pipeUrl, finishingDelegate);
                _webPipe.SetCollector(this);
            }
            _webPipe.Update();
        }