This post is the latest in the series of closer looks at the new APIs in AutoCAD 2009. It dips into the InfoCenter API, a .NET API allowing you to customize and drive the InfoCenter feature inside AutoCAD.
To make use of this API you need to add Project References to two managed assemblies from the AutoCAD 2009 root folder: AcInfoCenterConn.dll and AdInfoCenter.dll.
Here's some C# code that will display a balloon notification to your users:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.AcInfoCenterConn;
namespace InfoCenterApp
{
public class Commands
{
[CommandMethod("icb")]
public void infoCenterBalloon()
{
InfoCenterManager icm =
AcInfoCenterConn.InfoCenterManager;
Autodesk.InfoCenter.PaletteMgr pm =
icm.PaletteManager;
pm.ShowBalloon(
"Custom Application Notification",
"Kean has some information for you...",
null, // Don't provide an icon
new System.Uri(
"http://blogs.autodesk.com/through-the-interface"
),
5, // Show the balloon for 5 seconds
1 // Make it relatively slow to fade in
);
}
}
}
Here's what you see when you run the ICB command:
Update:
For AutoCAD 2010 things has changed a little. It seems you now need to include project references to AcWindows.dll and AdWindows.dll, as well as making some changes to your code. Some of the required types are now in the Autodesk.Internal namespace, which leads me to believe this may be subject to further change.
Here is some code that worked well for me:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.AcInfoCenterConn;
using Autodesk.Internal.InfoCenter;
namespace InfoCenterApp
{
public class Commands
{
[CommandMethod("icb")]
public void infoCenterBalloon()
{
InfoCenterManager icm = new InfoCenterManager();
ResultItem ri = new ResultItem();
ri.Category = "Custom Application Notification";
ri.Title = "Kean has some information for you...";
ri.Uri =
new System.Uri(
"http://blogs.autodesk.com/through-the-interface"
);
ri.IsFavorite = true;
ri.IsNew = true;
icm.PaletteManager.ShowBalloon(ri);
}
}
}
There's a version of the ShowBalloon() function which takes a XAML fragment as a parameter, for those of you into WPF.
Here's the notification it creates in AutoCAD 2010: