using Autodesk.AutoCAD.Runtime;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ProgressMeterTest
{
public class Cmds
{
[DllImport(
"acad.exe",
CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetStatusBarProgressMeter@@YAHPB_WHH@Z"
//This should work for AutoCAD 2006...
//EntryPoint = "?acedSetStatusBarProgressMeter@@YAHPBDHH@Z"
)]
private static extern int
acedSetStatusBarProgressMeter(
string label,
int minPos,
int maxPos
);
[DllImport(
"acad.exe",
CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetStatusBarProgressMeterPos@@YAHH@Z"
)]
private static extern int
acedSetStatusBarProgressMeterPos(int pos);
[DllImport(
"acad.exe",
CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedRestoreStatusBar@@YAXXZ"
)]
private static extern int acedRestoreStatusBar();
[CommandMethod("PB")]
public void ProgressBar()
{
acedSetStatusBarProgressMeter("Testing Progress Bar", 0, 100);
for (int i = 0; i <= 100; i++)
{
for (int j = 0; j <= 10; j++)
{
System.Threading.Thread.Sleep(1);
acedSetStatusBarProgressMeterPos(i);
// This allows AutoCAD to repaint
Application.DoEvents();
}
}
acedRestoreStatusBar();
}
}
}