Exemplo n.º 1
0
        private void Initialise(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            UICtrlApp.Idling -= Initialise;
            AppInstance       = sender as UIApplication;

            AppInstance.Application.DocumentOpened += CheckForStreamsAndOpenSpeckle; // Adds an event on doc open to check for streams and launch/focus speckle if any are present.
        }
Exemplo n.º 2
0
 private void App_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
     if (fastExecutionEnabled)
     {
         e.SetRaiseWithoutDelay();
     }
     if (!queue.IsEmpty)
     {
         using (Transaction t = new Transaction(this.app.ActiveUIDocument.Document))
         {
             if (t.Start("Async Idling Transaction") == TransactionStatus.Started)
             {
                 Task task;
                 while (queue.TryDequeue(out task))
                 {
                     task.ConfigureAwait(false);
                     task.RunSynchronously();
                 }
                 if (TransactionStatus.Committed != t.Commit())
                 {
                     t.RollBack();
                     throw new Exception("Something bad happened. Transaction failed. Rollbacked");
                 }
             }
         }
     }
 }
        private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            var uiApp = (UIApplication)sender;

            if (uiApp.ActiveUIDocument == null)
            {
                return;
            }

            var document = uiApp.ActiveUIDocument.Document;

            if (!document.IsWorkshared)
            {
                return;
            }

            if (!_synchronizeTimer.SynchronizeFlag)
            {
                return;
            }

            _synchronizeTimer.SynchronizeFlag = false;
            var settings = _synchronizeTimer.GetSettings();


            var centralOption = GetCentralOptions(settings);

            document.SynchronizeWithCentral(new TransactWithCentralOptions(), centralOption);
        }
Exemplo n.º 4
0
 void OnIdle(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
     while (changeQuque.Count > 0)
     {
         changeQuque.Dequeue().Apply();
     }
 }
Exemplo n.º 5
0
        private void _uiApp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            ActionEnum tmp = _action;

            _action = ActionEnum.None; // reset;

            switch (tmp)
            {
            case ActionEnum.Run:
                performRun();
                break;

            case ActionEnum.DrawRoute:
                performDrawRoute();
                break;

            case ActionEnum.Show:
                performShow();
                break;


            case ActionEnum.GetAllRoutes:
                performGetAllRoutes();
                break;

            case ActionEnum.DrawAll:
                performDrawAll();
                break;
            }
        }
Exemplo n.º 6
0
 static void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
     Thread.Sleep(1);
     while (HasPendingPromises())
     {
         promises.Dequeue()();
     }
 }
Exemplo n.º 7
0
        //Rvt导出为Ifc 事件
        private void Uiapp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            if (count != 0)
            {
                return;
            }
            if (File.Exists(rvtName))
            {
                try
                {
                    Document doc = uiapp.Application.OpenDocumentFile(rvtName);
                    using (Transaction transaction = new Transaction(doc, "ifcexporter"))
                    {
                        transaction.Start();
                        IFCExportOptions opt = null;
                        doc.Export(path, ifcName, opt);
                        transaction.Commit();
                    }
                    doc.Close();
                    return;
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("error", ex.ToString());
                }
                finally
                {
                    #region 发送生成的ifc
                    if (File.Exists(rvtName.Replace(".rvt", ".ifc")))
                    {
                        using (var fs = new FileStream(rvtName.Replace(".rvt", ".ifc"), FileMode.Open))
                        {
                            // 封包体
                            byte[] bodyBytes = new byte[fs.Length];
                            fs.Read(bodyBytes, 0, bodyBytes.Length);
                            fs.Close();
                            // 封包头
                            PkgHeader header = new PkgHeader();
                            header.Id       = ++id;
                            header.BodySize = bodyBytes.Length;
                            byte[] headerBytes = server.StructureToByte <PkgHeader>(header);


                            // 组合最终发送的封包 (封包头+封包体)
                            byte[] sendBytes = GetSendBuffer(headerBytes, bodyBytes);
                            server.Send(ID, sendBytes, sendBytes.Length);
                        }
                        delDir(path);//发送完成,删除文件
                    }
                    else
                    {
                        TaskDialog.Show("", rvtName.Replace(".rvt", ".ifc"));
                    }
                    #endregion
                }
                count++;
            }
        }
        private void uiapp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            uiapp.Idling -= uiapp_Idling;

            CadDetailConverterHandlerFinal finalHandler = new CadDetailConverterHandlerFinal(this);
            ExternalEvent exEvent = ExternalEvent.Create(finalHandler);

            exEvent.Raise();
        }
Exemplo n.º 9
0
 private void UiApp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
     if (idling < 3)
     {
         //非默认模式
         e.SetRaiseWithoutDelay();
         idling++;
     }
     ShowMessage("闲置事件:" + idling);
 }
Exemplo n.º 10
0
        private void Initialise(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            UICtrlApp.Idling -= Initialise;
            AppInstance       = sender as UIApplication;

            // Set up bindings now as they subscribe to some document events and it's better to do it now
            SpeckleRevitCommand.Bindings = new ConnectorBindingsRevit(AppInstance);
            var eventHandler = ExternalEvent.Create(new SpeckleExternalEventHandler(SpeckleRevitCommand.Bindings));

            SpeckleRevitCommand.Bindings.SetExecutorAndInit(eventHandler);
        }
Exemplo n.º 11
0
 private void OnIdling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
     if (properities.download && properities.tempCommandData != null)
     {
         CmdPlaceFamilyInstance objcmd = new CmdPlaceFamilyInstance();
         string tempMessage            = string.Empty;
         objcmd.Execute(kilargo.properities.tempCommandData, ref tempMessage, kilargo.properities.tempElementSet);
         properities.tempCommandData = null;
         properities.tempElementSet  = null;
         properities.download        = false;
     }
 }
Exemplo n.º 12
0
        private void Initialise(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            UICtrlApp.Idling -= Initialise;
            AppInstance       = sender as UIApplication;

            // Adds an event on doc open to check for streams and launch/focus speckle if any are present.
            AppInstance.Application.DocumentOpened += CheckForStreamsAndOpenSpeckle;

            // Set up bindings now as they subscribe to some document events and it's better to do it now
            SpeckleRevitCommand.Bindings = new ConnectorBindingsRevit(AppInstance);
            var eventHandler = ExternalEvent.Create(new SpeckleExternalEventHandler(SpeckleRevitCommand.Bindings));

            SpeckleRevitCommand.Bindings.SetExecutorAndInit(eventHandler);
        }
Exemplo n.º 13
0
        /// <summary>
        ///     <para>An event that revit signals repeatedly at idle time</para>
        ///     <para>Revit在空闲时间反复调用的回调方法,当做 white(true){} 无限循环使用</para>
        /// </summary>
        /// <param name="sender">The revit UI level application</param>
        /// <param name="e">Arguments to config the event</param>
        private static void App_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            var handler = TryGetEvent();

            if (null == handler)
            {
                return;
            }
            var app = sender as UIApplication;

            if (null == app)
            {
                return;
            }
            handler.Execute(app);
        }
Exemplo n.º 14
0
        private void uiapp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            if (doc.ActiveView.GetType().Name == "ViewSheet")
            {
                Autodesk.Revit.DB.ViewSheet curViewSheet = doc.ActiveView as Autodesk.Revit.DB.ViewSheet;

                if (curViewSheet != null)
                {
                    if (updatePositions(curViewSheet))
                    {
                        this.uiapp.ViewActivating -= uiapp_ViewActivating;
                        this.uiapp.ViewActivated  -= uiapp_ViewActivated;
                        this.uiapp.Idling         -= uiapp_Idling;
                    }
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 界面级别
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        // private void appChange(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
        //{
        //    TaskDialog.Show("已改", "已改动");
        //}

        ///文档级别事件
        //private void docClosing(object sender, Autodesk.Revit.DB.Events.DocumentClosedEventArgs e)
        //{
        //    TaskDialog.Show("关闭", "已关闭");
        //}

        private void IdlingTest(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            UIApplication m_uiapp = sender as UIApplication;

            Autodesk.Revit.DB.Document m_doc = m_uiapp.ActiveUIDocument.Document;
            Transaction trans = new Transaction(m_doc, "idling");

            trans.Start();
            ElementId id  = new ElementId(194987);
            TextNote  tn  = m_doc.GetElement(id) as TextNote;
            string    str = tn.Text;
            int       i   = 0;

            int.TryParse(str, out i);
            tn.Text = (i + 1).ToString();
            trans.Commit();
        }
Exemplo n.º 16
0
        private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            if (allowToCreate)
            {
                allowToCreate = false;
                IEnumerable <DesignOption> designOptions = new FilteredElementCollector(uiapp.ActiveUIDocument.Document).OfClass(typeof(DesignOption)).Cast <DesignOption>();

                if (designOptions.ToList <DesignOption>().Count > 0)
                {
                    DesignOptionsForm form   = new DesignOptionsForm(uiapp);
                    DialogResult      result = form.ShowDialog();
                }
                else
                {
                    createNewDesignOptions();
                }
            }
        }
Exemplo n.º 17
0
        private void Initialise(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            UICtrlApp.Idling -= Initialise;
            AppInstance       = sender as UIApplication;

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve);

            // Set up bindings now as they subscribe to some document events and it's better to do it now
            SpeckleRevitCommand.Bindings = new ConnectorBindingsRevit(AppInstance);
            var eventHandler = ExternalEvent.Create(new SpeckleExternalEventHandler(SpeckleRevitCommand.Bindings));

            SpeckleRevitCommand.Bindings.SetExecutorAndInit(eventHandler);

            //pre build app, so that it's faster to open up
            SpeckleRevitCommand2.InitAvalonia();
            SpeckleRevitCommand2.Bindings = new ConnectorBindingsRevit2(AppInstance);
            SpeckleRevitCommand2.Bindings.RegisterAppEvents();
        }
Exemplo n.º 18
0
        private static void RunScript(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            Revit.ApplicationUI.Idling -= RunScript;

            var runScript = Environment.GetEnvironmentVariable("RhinoInside_RunScript");

            if (string.IsNullOrEmpty(runScript))
            {
                return;
            }

            using (var modal = new ModalScope())
            {
                if (RhinoApp.RunScript(runScript, false))
                {
                    modal.Run(Addin.StartupMode == AddinStartupMode.AtStartup);
                }
            }
        }
        private void _uiApp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            ActionEnum tmp = _action;

            _action = ActionEnum.None;

            e.SetRaiseWithoutDelay();

            switch (tmp)
            {
            case ActionEnum.Show:
                performShow();
                break;

            case ActionEnum.DrawRoute:
                performCreate();
                break;
            }
        }
Exemplo n.º 20
0
        public static void IdlingHandler(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs args)
        {
            UIApplication uiapp = sender as UIApplication;

            if (uiapp != null)
            {
                Autodesk.Revit.UI.UIDocument uidoc = uiapp.ActiveUIDocument;
                Autodesk.Revit.DB.Document   doc   = uidoc.Document;
                if (uidoc != null && doc != null)
                {
                    Reference re = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "");
                    Element   e  = doc.GetElement(re);

                    System.Windows.Forms.MessageBox.Show(e.Id.ToString() + e.Name);
                    uiapp.Idling -= IdlingHandler;
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Must should Idling!");
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Main Service method. Observe the watch directory for new requests.
        /// Only one request will be processed. Write status file on every call.
        /// </summary>
        private void OnIdle(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            var process = GetRequest <ExploreRequest>(FileNames.ExploreRequestBase);

            if (process.Request == null)
            {
                process = GetRequest <RunRequest>(FileNames.RunRequestBase);
            }

            if (process.Request != null)
            {
                switch (process.Request)
                {
                case ExploreRequest exploreRequest: Explore(exploreRequest, process.Response); break;

                case RunRequest runRequest: Run(runRequest, process.Response, sender as UIApplication); break;

                default: Thread.Sleep(250); break;
                }
            }

            SetStatus();
        }
Exemplo n.º 22
0
 void a_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
 {
 }
Exemplo n.º 23
0
        /***************************************************/

        private void InitializeButtonVisibility(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
        {
            ShowInactiveButtonSet();
            UIControlledApplication.Idling -= InitializeButtonVisibility;
        }