Exemplo n.º 1
0
        }//eof

        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            DA.GetData(1, ref this.isAutoUpdate);

            if (this.ghDocument == null)
            {
                this.ghDocument = OnPingDocument();
                if (this.ghDocument == null)
                {
                    return;
                }

                GH_Document.SolutionEndEventHandler handle = delegate(Object sender, GH_SolutionEventArgs e)
                {
                };

                ghDocument.SolutionEnd += handle;
            }

            if (!this.onMessageTriggered)
            {
                WsObject wscObj = new WsObject();

                if (DA.GetData(0, ref wscObj))
                {
                    if (this.wscObj != wscObj)
                    {
                        this.unsubscribeEventHandlers();
                        this.wscObj = wscObj;
                        this.subscribeEventHandlers();
                    }
                }
                else
                {
                    this.unsubscribeEventHandlers();
                    this.wscObj             = null;
                    this.onMessageTriggered = false;
                    return;
                }
            }

            DA.SetData(0, this.wscObj.message);
            DA.SetData(1, WsObjectStatus.GetStatusName(this.wscObj.status));
            this.onMessageTriggered = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            dataAccess.SetData(1, false);

            bool run = false;

            if (!dataAccess.GetData(1, ref run))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }
            if (!run)
            {
                return;
            }

            string path_T3D = null;

            if (!dataAccess.GetData(0, ref path_T3D) || string.IsNullOrWhiteSpace(path_T3D))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                return;
            }

            Core.Tas.SAMT3DDocument sAMT3DDocument = new Core.Tas.SAMT3DDocument(path_T3D);

            GH_Document.SolutionEndEventHandler endHandler = null;

            OnPingDocument().SolutionEnd += endHandler = (sender, args) =>
            {
                (sender as GH_Document).SolutionEnd -= endHandler;
                sAMT3DDocument.Dispose();
                this.Phase = GH_SolutionPhase.Blank;
            };

            dataAccess.SetData(0, new GooSAMT3DDocument(sAMT3DDocument));
            dataAccess.SetData(1, true);
        }
        public static ConvertSettings UpdateSolutionEndEventHandler(this GH_Component gHComponent, ConvertSettings convertSettings = null)
        {
            if (gHComponent == null)
            {
                return(null);
            }

            if (convertSettings == null)
            {
                return(Core.Revit.Query.ConvertSettings());
            }

            GH_Document.SolutionEndEventHandler solutionEndEventHandler = null;

            gHComponent.OnPingDocument().SolutionEnd += solutionEndEventHandler = (sender, args) =>
            {
                (sender as GH_Document).SolutionEnd -= solutionEndEventHandler;
                convertSettings.ClearObjects();
                //gHComponent.Phase = GH_SolutionPhase.Blank;
            };

            return(convertSettings);
        }