70002779 Display extended data of object with a tooltip

Article 70002779
Type HowTo
Product Engine
Date Added 10/21/2025 12:00:00 AM
Fixed 11.5.1 (10/21/2025 12:00:00 AM)
Submitted by Jacob Pitcher

Summary

How can I show some extended data of the object with a tooltip when mouse is over this object?

Solution

In a empty form add a button and a vdFramed control, and use a code like:

private void button1_Click(object sender, EventArgs e)
{
    vdDocument doc = vdDestFramed.BaseControl.ActiveDocument;
    doc.New();
 
    if (doc.CommandAction.CmdCone(new gPoint(5, 0, 0), 3.0d, 3.0d, 7.0d, 16))
    {
        // create an object for testing
        vdPolyface pf = doc.Model.Entities.Last as vdPolyface;
        pf.PenColor.FromSystemColor(Color.Red);

        // add extended data to the object
        vdXProperty xpDepth = new vdXProperty();
        xpDepth.SetUnRegisterDocument(doc);
        xpDepth.PropValue = 6.0d;
        xpDepth.Name = "Depth";
        pf.XProperties.Add(xpDepth);
        vdXProperty xpLocation = new vdXProperty();
        xpLocation.SetUnRegisterDocument(doc);
        xpLocation.PropValue = new gPoint(5, 0, 0);
        xpLocation.Name = "Location";
        pf.XProperties.Add(xpLocation);
 
        //set the tooltip of the object based on these data that you want to show
        pf.ToolTip = "Depth: " + xpDepth.PropValue.ToString() + "\r\n" + "Location: " + xpLocation.PropValue.ToString(); // set tooltip 
        doc.EnableToolTips = true; //Tooltips must be enabled
        pf.Update();
    }
    doc.CommandAction.View3D("VISE");
    doc.CommandAction.View3D("ShadeOn");
    doc.CommandAction.Zoom("E", 0, 0);
}
3D Object with tooltip

Send comments on this topic.