.NET

Reply
Member
Posts: 5
Registered: ‎05-29-2013
Message 1 of 7 (157 Views)
Accepted Solution

Monitoring If the Text Edit Ribbon Tab Is Open

157 Views, 6 Replies
01-28-2014 05:28 PM

Greetings,

 

How can I make a module that detects wether the text editing tab is open or not?

 

Best regards,

Ivan

ADN Support Specialist
Posts: 288
Registered: ‎04-30-2009
Message 2 of 7 (128 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

01-29-2014 05:35 AM in reply to: IvanShchitov

You can track whenever the Tab is activated

 

For instance, from inside Initialize event

 

void IExtensionApplication.Initialize()
{
    Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
    foreach(Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs )
    {
        if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
        {
            tab.Activated += tab_Activated;
        }
    }

}

void tab_Activated(object sender, EventArgs e)
{
    // do something here...
}
Regards,



Augusto Goncalves
Autodesk Developer Network
Member
Posts: 5
Registered: ‎05-29-2013
Message 3 of 7 (106 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

01-30-2014 12:40 AM in reply to: augusto.goncalves

Thank you very much, Augusto!

Member
Posts: 5
Registered: ‎05-29-2013
Message 4 of 7 (57 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 01:39 AM in reply to: augusto.goncalves

This code is for C++, isn't it? How to do the same in Visual Basic 2010?

ADN Support Specialist
Posts: 288
Registered: ‎04-30-2009
Message 5 of 7 (49 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 04:23 AM in reply to: IvanShchitov

Actually is a C# code, and you can convert to VB.NET at http://www.developerfusion.com/tools/convert/csharp-to-vb/

Regards,



Augusto Goncalves
Autodesk Developer Network
Member
Posts: 5
Registered: ‎05-29-2013
Message 6 of 7 (41 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 01:41 PM in reply to: augusto.goncalves

Thank you, Augusto!

Member
Posts: 5
Registered: ‎05-29-2013
Message 7 of 7 (36 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 04:17 PM in reply to: augusto.goncalves

Greetings, Augusto!

 

I've inserted your code in Microsoft Visual C# 2010 Express and it showed me three errors, particularly: 

 

01. 'CSharp_Plugin.DetectingTab.IExtensionApplication.Initialize()': containing type does not implement interface 'Autodesk.AutoCAD.Runtime.IExtensionApplication'

02. The type or namespace name 'Windows' does not exist in the namespace 'Autodesk' (are you missing an assembly reference?)

03. The type or namespace name 'Ribbon' does not exist in the namespace 'Autodesk.AutoCAD' (are you missing an assembly reference?)

 

How can I fix these errors?

 

Best regards,

Ivan

 

using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

namespace CSharp_Plugin
{
    public class DetectingTab
    {
        void IExtensionApplication.Initialize()
        {
            Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
            foreach (Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs)
            {
                if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
                {
                    tab.Activated += tab_Activated;
                }
            }

        }

        void tab_Activated(object sender, EventArgs e)
        {
            // do something here...
        }
    }
}

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community