Exemplo n.º 1
0
            ///<summary> This gets called when when the user runs this command.</summary>
            protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode)
            {
                if (Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem != Rhino.UnitSystem.Meters)
                {
                    System.Windows.Forms.MessageBox.Show("At this point in development, Pachyderm supports documents in meters only. Please set the document units to meters, and run the calculation again.\n(A quick way to get to the document units control is to type 'units' into the command prompt.)");
                    CommandResult = Result.Cancel;
                    return(CommandResult);
                }

                ////In order to deal with latency in memory, a thread sleep of 1 second is inserted...
                //System.Threading.Thread.Sleep(1000);
                //////////////////////////////////////////////////////////////////////////////////////
                Rhino.RhinoApp.EscapeKeyPressed += Escape;
                CancelCalc    = false;
                CommandResult = Result.Success;
                Rhino.ApplicationSettings.FileSettings.AutoSaveEnabled = false;

                if (Sim != null)
                {
                    Sim.Begin();
                    Rhino.RhinoApp.SetCommandPrompt(string.Format("Initiating {0} Calculation...", Sim.Sim_Type()));
                    do
                    {
                        if (CancelCalc)
                        {
                            Sim.Abort_Calculation();
                            CommandResult = Result.Cancel;
                            Rhino.ApplicationSettings.FileSettings.AutoSaveEnabled = true;
                            return(CommandResult);
                        }
                        if (Sim.ThreadState() != System.Threading.ThreadState.Running)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(3000);
                        Rhino.RhinoApp.SetCommandPrompt(Sim.ProgressMsg());
                    } while (true);

                    Sim.Combine_ThreadLocal_Results();
                    do
                    {
                        System.Threading.Thread.Sleep(3000);
                        if (Sim.ThreadState() != System.Threading.ThreadState.Running)
                        {
                            break;
                        }
                        Rhino.RhinoApp.SetCommandPrompt(Sim.ProgressMsg());
                    } while (true);
                }

                Rhino.ApplicationSettings.FileSettings.AutoSaveEnabled = true;
                //System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Interactive;
                Rhino.RhinoDoc.ActiveDoc.Views.RedrawEnabled = true;
                return(CommandResult);
            }