Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this code in C# where the code compiles perfectly but i do not see progress meter on ACAD UI.
[CommandMethod("PilePlacement")]
public static void Main()
{
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
db = doc.Database;
try
{
// Show progress bar window on a separate thread
//progressBarThread = new Thread(() =>
//{
// progressBarWindow = new ProgressBarWindow();
// progressBarWindow.Show();
// System.Windows.Threading.Dispatcher.Run();
//});
//progressBarThread.SetApartmentState(ApartmentState.STA);
//progressBarThread.Start();
List<string> tableNames = MMSData.tables;
MMSData.tablePiling = true;
Dictionary <string, List < BlockReference >> allBlockReferences = MMSData.mmsTablesDict;
Log.Logger.Log("Get list of table names and dictionary of table name and blocks from MMSData");
//iterate through all the tables selected by user
//string[] tableNames = { "MMS Table (32.2920 x 4.5760)", "MMS Table (128.58 x 2.278)" };
Log.Logger.Log("iterate through all the tables selected by user");
// Start the progress meter
// Start the progress meter
ProgressMeter progressMeter = new ProgressMeter();
progressMeter.Start("Placing piles...");
progressMeter.SetLimit(tableNames.Count);
foreach (string tableName in tableNames)
{
string currTable = tableName;
if(currTable.Contains("(Ext)")) currTable = currTable.Replace("(Ext)", "");
AddPileDrawingToDB(tableName, allBlockReferences[currTable][0]);
// Update the progress meter
progressMeter.MeterProgress();
// This allows AutoCAD to repaint
System.Windows.Forms.Application.DoEvents();
}
ChangeVisibility();
// Close the progress bar window on the UI thread
//if (progressBarWindow != null && progressBarWindow.Dispatcher != null)
//{
// progressBarWindow.Dispatcher.Invoke(() => progressBarWindow.Close());
//};
// Stop the progress meter
progressMeter.Stop();
MessageBox.Show("Piles placed successfully !!", "Piling Automation", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
Log.Logger.LogException(ex);
}
catch (System.Exception ex)
{
Log.Logger.LogException(ex);
}
//finally
//{
// // Ensure the progress bar thread is closed
// if (progressBarThread != null && progressBarThread.IsAlive)
// {
// progressBarThread.Join();
// }
//}
}
Solved! Go to Solution.