public class ToolTips
{
// Method to handle the point monitor event for tooltips
public static void ed_PointMonitor(object sender, PointMonitorEventArgs e)
{
// Check to see if there is anything under the aperature
if (e.Context == null)
{
return;
}
// Check to see if there is anytype of command in progress. If so we do not want to display a tooltip
if ((short)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CMDACTIVE") !=0 )
{
return;
}
FullSubentityPath[] fullEntPath = e.Context.GetPickedEntities();
if (fullEntPath.Length > 0)
{
Transaction trans = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction();
try
{
Entity ent = (Entity)trans.GetObject((ObjectId)fullEntPath[0].GetObjectIds()[0], OpenMode.ForRead);
// Get the Entity Object Class Name and create a string variable to hold our tooltip information
string entType = ent.Id.ObjectClass.Name;
string str1 = "";
switch (entType)
{
case "AecbDbMvPart":
// The object under the aperature is a MvPart. We need to add the MvPartToolTip Property Set
// Definition to the object and then read its values and place those values into the tooltip.
// Get the ObjectId of the PropertySet
ObjectId PropertySetId = psUtilities.GetPropertySet("MvPartToolTip");
if (PropertySetId.IsNull)
{
// If the property set does not exist then we will display a tooltip informing the user
// To create the property set and fill it with information.
str1 = String.Format("MULTI-VIEW PART{0}{0}", System.Environment.NewLine);
str1 = String.Format("{0}Please create a property set named MvPartToolTip{1}", str1, System.Environment.NewLine);
str1 = String.Format("{0}Fill it with relevant property set definitions{1}", str1, System.Environment.NewLine);
e.AppendToolTipText(str1);
return;
}
// If we are here then the property set exists but we do not know if the property
// Is attached to the object. The AttachPropertySet method will check and will
// Add the property set if needed.
if (psUtilities.AttachPropertySet(ent.ObjectId, PropertySetId))
{
str1 = String.Format("MULTI-VIEW PART{0}{0}", System.Environment.NewLine);
str1 = String.Format("{0}Property Set Attached{1}", str1, System.Environment.NewLine);
e.AppendToolTipText(str1);
}
else
{
str1 = String.Format("MULTI-VIEW PART{0}{0}", System.Environment.NewLine);
str1 = String.Format("{0}Property is not attached{1}", str1, System.Environment.NewLine);
e.AppendToolTipText(str1);
}
break;
case "AecbDbDuct":
str1 = String.Format("DUCT{0}{0}", System.Environment.NewLine);
e.AppendToolTipText(str1);
break;
case "AecbDbDuctFitting":
str1 = String.Format("DUCT FITTING{0}{0}", System.Environment.NewLine);
e.AppendToolTipText(str1);
break;
case "AecbDbPipe":
str1 = String.Format("PIPE{0}{0}", System.Environment.NewLine);
e.AppendToolTipText(str1);
break;
case "AecbDbPipeFitting":
str1 = String.Format("PIPE FITTING{0}{0}", System.Environment.NewLine);
e.AppendToolTipText(str1);
break;
default:
return;
}
trans.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
}
finally
{
trans.Dispose();
}
}
}
}