0

I would like to create infobox functionality in AutoCAD. Same as you hover some feature in Google Earth, it shows you infobox with picture.

Something like this

I was thinking about using palette, but I'm not sure how to adjust it to looks like infobox.

I'm planning to create .NEt plugin.

Any suggestions?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Minja
  • 1,222
  • 1
  • 19
  • 28
  • It is fine to answer your own question, but you should do it as an answer instead of adding it to the question. That way, it can be voted on and accepted (for example). – crashmstr Jun 04 '12 at 19:55
  • I did not know, sorry, I will fix it. – Minja Jun 06 '12 at 21:55

3 Answers3

3

**Well, I found I think the best approach, using AutoCAD tooltip. Here is the code snippet:

Autodesk.Windows.ComponentManager.ToolTipOpened +=
            (s, e) =>
            {       
                Autodesk.Internal.Windows.ToolTip tooltip =
                s as Autodesk.Internal.Windows.ToolTip;
                if (tooltip != null)
                {                     
                        var image = new System.Windows.Controls.Image();
                        var bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.UriSource = new Uri(@"C:/index.jpeg");
                        bitmapImage.EndInit();
                        image.Source = bitmapImage;
                        tooltip.Height = image.Height;
                        tooltip.Width = image.Width;
                        tooltip.Content = image;
                }
            };

It looks fine to me now. :)**

As I said in comment below here is the screen shot of this solution

enter image description here

As you can maybe note, tooltip is not positioned near geometry, I selected the pink one. That is my last problem. My flow is that when I select object, I got win form listBox that offers me several image files connected to this entity. When I choose one, it opens tootltip, but it seems relatively to listbox dialog. I was not able to find solution how to manually set tooltip position. Any suggestions?

Minja
  • 1,222
  • 1
  • 19
  • 28
  • ToolTipOpened is for tooltips opened by the ribbon, the menu, the Quick Access Toolbar and the status bar. I think you can not use it for displaying info on an entity. – Maxence Jun 07 '12 at 06:58
  • This works fine, I will make screen shot and show you. I think ToolTipOpened is global event handler for tooltips. Inside it, I just recognize if tooltip that trigger event is "simple" tooltip in if statement. I could also look if it is ribbon one and do something with that type of tooltip... – Minja Jun 07 '12 at 07:17
  • OK, it's a nice thing to know. In the ObjectARX documentation, it's written that this event is raised for all tooltips which use the class Autodesk.Internal.Windows.ToolTip – Maxence Jun 07 '12 at 07:27
2

You can use a PointMonitor to detect the mouse movement: http://through-the-interface.typepad.com/through_the_interface/2009/07/providing-information-on-autocad-objects-in-a-tooltip-using-net.html

And for showing an image, you can use WPF in your palette: http://through-the-interface.typepad.com/through_the_interface/2009/08/hosting-wpf-content-inside-an-autocad-palette.html

Maxence
  • 12,868
  • 5
  • 57
  • 69
  • Good answer! Are there any good tutorials to start with ObjectARX for .Net? I've tried it for C++ couple years before, but I've gave up very soon because documentation was poor. – besworland Jun 04 '12 at 07:49
  • http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff2566ffd511ff6f8c7ca-4875.htm – Maxence Jun 04 '12 at 07:56
  • 1
    @besworland (http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=16459234). It's in VB.NET but could probably be translated to C# fairly easily. – JayP Jun 04 '12 at 11:22
  • Well, as I answered below, I think the best approach is with tooltip. I did not like palette too much after playing around with it. There is also some more questions about this, how I could connect some picture on disk with drawing object. Is it possible to set some custom property on drawing object that will keep path to image location? And is it possible to start autocad plugin from autocad interface, let's say to have toolbar icon that will trigger mine infobox plugin? Thanks – Minja Jun 06 '12 at 21:59
  • You can attach arbitrary data to an entity with extended Data (XData) or an extension dictionary. – Maxence Jun 07 '12 at 06:56
  • Are you talking about assign data to object in code? I want to let client possibility to assign image location to drawing in Autocad. If that is possible, it would not be problem for me to read it in code, I assume there are corresponding classes and methods. I will investigate your answer, and see what can be done. thanks – Minja Jun 07 '12 at 07:20
  • You can start here for XData: http://through-the-interface.typepad.com/through_the_interface/2007/04/adding_xdata_to.html – Maxence Jun 07 '12 at 07:33
  • A good documentation also: http://www.scribd.com/doc/19381092/AutoCAD-NET-Developers-Guide – Maxence Jun 07 '12 at 07:34
0

Using PointMonitor, detecting if an entity of your concern being under the cursor position, and popping up your own window when applicable holding the images in a listbox, combobox or like is more controllable and flexible. The window can be WPF or WinForm of your choice.

It's definitely doable and some applications already use these techniques quite maturely. Some coordination transforming stuffs have to be taken into account, such as from window pixels to AutoCAD display system, from DCS to WCS, back and forth.

Now, the only remaining thing may be performance. Hope the following tips are of a bit help.

  1. Caching the previous entity id. If the cursor is still hovering on it, do nothing but keeps the previous image there.
  2. If users move the cursor so quick from one entity to another, the previous window may not be necessary to be discarded and a new one created. Replacing the images should be enough and just good.
  3. Providing different resolutions of the same images, like thumbnail, preview or fine and display them at different times such as if the cursor hovering shorter than 1 second just the thumbnail and if longer than 5 sec showing the fine picture.
  4. Better give users some ways to configure these.
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
  • Thanks for the comment, I will analyze your answer and try it. BTW, what I tried was: 1. Select entity, 2. Remember current cursor position, 3. Open list box with images to select, 4. select image, 5. programaticaly open tooltip with selected image, 6. set tooltip position using "Remembered current cursor position(x, y)". Last step did not work, but maybe i missed something. – Minja Jun 19 '12 at 08:26