static void Main(string[] args) { Stopwatch st; ConsoleKey userInput; st = new Stopwatch(); try { model = new StaadModel(OpenStaadGetter.InstantiateOpenSTAAD()); } catch (STAADRunningInstanceNotFoundException) { Console.WriteLine("Could not get hold of STAAD"); Console.ReadKey(); return; } catch { Console.WriteLine("An unknown error occurred"); Console.ReadKey(); return; } model.ModelBuildStatusUpdate += Model_ModelBuildStatusUpdate; st.Start(); model.Build(); st.Stop(); Console.WriteLine(); Console.WriteLine("Model built in {0:0.000}s", st.Elapsed.TotalMilliseconds / 1000); // Console.WriteLine("Press s to select beams by type, y to generate members, press any other key to quit..."); userInput = Console.ReadKey().Key; if (userInput == ConsoleKey.S) { SelectBeamsByType(); } else if (userInput != ConsoleKey.Y) { return; } Console.WriteLine(); Console.WriteLine("Starting member generation..."); st.Reset(); st.Start(); model.GenerateMembers(); st.Stop(); Console.WriteLine("Member generation completed in {0:0.000}s", st.Elapsed.TotalMilliseconds / 1000); Console.WriteLine("Press s to select members by type, press any other key to quit..."); userInput = Console.ReadKey().Key; if (userInput == ConsoleKey.S) { SelectMembersByType(); } else { return; } //BucklingLengthGenerator blg = new BucklingLengthGenerator(model) { SelectMembersDuringAnalysis = true }; Console.WriteLine("Press any key to quit"); Console.ReadKey(); }
static void Main(string[] args) { string savePath; StringBuilder output; List <Member> members; var s = new Stopwatch(); // Get the first available OpenSTAADModel if (!GetSTAADModel()) { Console.WriteLine("Could not get hold of OpenSTAAD."); Console.WriteLine("Is a STAAD model open? Is OpenSTAAD installed on this computer?"); Console.WriteLine("Press any key or close the console manually."); Console.ReadKey(); return; } Console.WriteLine("Acquired model {0}", staadModel.ModelName); Console.WriteLine("Proceed with model build? y/n"); if (Console.ReadKey().Key == ConsoleKey.N) { return; } else { Console.WriteLine(); } // Start model build Console.WriteLine("Starting model build..."); s.Start(); staadModel.Build(); s.Stop(); Console.WriteLine("Build completed in {0:0.00}s.", s.Elapsed.TotalSeconds); Console.WriteLine("Performing model checks..."); var test = ModelChecks.CheckBeamDirections(staadModel); if (test.Any()) { Console.WriteLine("The following beams are going in the wrong direction:"); test.ForEach(o => Console.WriteLine(o.Id)); Console.WriteLine("Beams going in the wrong direction will make it more difficul to generate members and parameters accurately."); Console.WriteLine("Do you want to continue anyway? y/n"); if (Console.ReadKey().Key == ConsoleKey.N) { return; } } else { Console.WriteLine("All checks successfully completed..."); } // Generate members s.Reset(); staadModel.MemberGenerator.SelectIndividualMembersDuringCreation = true; Console.WriteLine("Generating members..."); s.Start(); //staadModel.MemberGenerator.SelectIndividualMembersDuringCreation = true; members = staadModel.GenerateMembers().ToList(); s.Stop(); Console.WriteLine(); Console.WriteLine("Member generation completed..."); Console.WriteLine("Generated {0} members in {1:0.00}s.", new object[] { members.Count, s.Elapsed.TotalSeconds }); Console.WriteLine("Proceed with parameter output? y/n"); if (Console.ReadKey().Key == ConsoleKey.N) { return; } else { Console.WriteLine(); } // Order Members and output parameters savePath = Path.Combine(Path.GetDirectoryName(staadModel.FileName), Path.GetFileNameWithoutExtension(staadModel.FileName) + "_PARAMETERS.txt"); output = new StringBuilder(); s.Reset(); s.Start(); output.Append(GatherDeflectionLengths(staadModel)); output.AppendLine(GatherBucklingLengths(staadModel)); // Deflection paramaters using (var sw = new StreamWriter(savePath)) { sw.Write(output); } s.Stop(); Console.WriteLine("Parameter calculations completed in {0:0.00}s.", s.Elapsed.TotalSeconds); Console.WriteLine("Data output to {0}.", savePath); Console.WriteLine("Press any key to close."); Console.ReadKey(); }