.NET

Reply
Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 1 of 9 (447 Views)
Accepted Solution

Workspaces/Ribbonstate

447 Views, 8 Replies
12-10-2013 12:34 PM

For activated Classic Workspaces, the Ribbonstate=0

For activated Ribbon Workspaces, the Ribbonstate=1

 

How do we find this type of Workspace before the Workspace is activated?

I've tried the Toolbar Count and Tabs Count but that's not identifying the differences.

 

Thanks for any help.

 

        [CommandMethod("WS")]
        public void GetWorkspaces()
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            Editor ed = dwg.Editor;

            CustomizationSection custSection;
            string cuiPathname = (string)Application.GetSystemVariable("MENUNAME");
            cuiPathname += ".cuix";
            custSection = new CustomizationSection(cuiPathname);
            WorkspaceCollection workspaces = custSection.Workspaces;
            
            var workspaceNames=new List<string>();
            foreach (Workspace ws in workspaces)
                workspaceNames.Add(ws.Name);
            workspaceNames.Sort();
            workspaceNames.ForEach(n => ed.WriteMessage("\n{0}", n));

            
            PromptIntegerOptions getWsNrPrmt = new PromptIntegerOptions("\nEnter nr: ");
            getWsNrPrmt.LowerLimit=0;
            getWsNrPrmt.UpperLimit=workspaceNames.Count-1;
            PromptIntegerResult getWsNr = ed.GetInteger(getWsNrPrmt);
            if (getWsNr.Status != PromptStatus.OK)
                return;
            Workspace workspace = workspaces[getWsNr.Value];
            WSRibbonRoot workspaceRR = workspace.WorkspaceRibbonRoot;
            WorkspaceToolbarCollection tbars = workspace.WorkspaceToolbars;
            ed.WriteMessage("\n{0} Toolbars", tbars.Count);

            WorkspaceRibbonTabCollection rTabs = workspace.WorkspaceRibbonRoot.WorkspaceTabs;
            ed.WriteMessage("\n{0} Tabs", rTabs.Count);

        }

 

 

Hi,

 

Any specific reasons you want to find this state?

Even in classic workspace, users can bring the ribbon by issuing command “ribbon”. The Ribbonstate variable will be 1.

ADN Support Specialist
Virupaksha.aithal
Posts: 100
Registered: ‎06-15-2011
Message 2 of 9 (413 Views)

Re: Workspaces/Ribbonstate

12-11-2013 10:38 PM in reply to: SENL1362

Hi,

 

Try reading system variable WSCURRENT. This variable holds the name of current workspace  



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 3 of 9 (409 Views)

Re: Workspaces/Ribbonstate

12-11-2013 11:19 PM in reply to: Virupaksha.aithal
Hello Virupaksha,
Thank you for this answer but it's not the solution to my question.
I need to know the TYPE of Workspace BEFORE it's set active, i.e.
- Drafting & Annotation: Type==Ribbon
- AutoCAD Classic: Type==Classic



Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 4 of 9 (405 Views)

Re: Workspaces/Ribbonstate

12-11-2013 11:30 PM in reply to: SENL1362
Hello Virupaksha,

Thank you for this answer but it's not the solution to my question.
I need to know the TYPE of Workspace BEFORE it's set active, i.e.
- Drafting & Annotation: Type==Ribbon
- AutoCAD Classic: Type==Classic

See the RED colored Function GetWorkspaceType in the example below, which return a Enum WorkspaceTypes

Thanks for helping me to solve this problem,
Greetings
Anton van Buiten



[CommandMethod("WS")]
public void GetWorkspaces()
{
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;

CustomizationSection custSection;
string cuiPathname = (string)Application.GetSystemVariable("MENUNAME");
cuiPathname += ".cuix";
custSection = new CustomizationSection(cuiPathname);
WorkspaceCollection workspaces = custSection.Workspaces;

var workspaceNames=new List();
foreach (Workspace ws in workspaces)
workspaceNames.Add(ws.Name);
workspaceNames.Sort();
workspaceNames.ForEach(n => ed.WriteMessage("\n{0}", n));


PromptIntegerOptions getWsNrPrmt = new PromptIntegerOptions("\nEnter nr: ");
getWsNrPrmt.LowerLimit=0;
getWsNrPrmt.UpperLimit=workspaceNames.Count-1;
PromptIntegerResult getWsNr = ed.GetInteger(getWsNrPrmt);
if (getWsNr.Status != PromptStatus.OK)
return;
Workspace workspace = workspaces[getWsNr.Value];
Var wsType=GetWorkspaceType(workspace);
If (wsType==WorkspaceTypes.Ribbon)
{
///Do the required Actions for RIBBON type Workspaces
}
Else
{
///Do the required Actions for CLASSIC type Workspaces
}
}
ADN Support Specialist
Virupaksha.aithal
Posts: 100
Registered: ‎06-15-2011
Message 5 of 9 (368 Views)

Re: Workspaces/Ribbonstate

12-17-2013 02:32 AM in reply to: SENL1362

Hi,

 

Any specific reasons you want to find this state?

Even in classic workspace, users can bring the ribbon by issuing command “ribbon”. The Ribbonstate variable will be 1.



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 6 of 9 (360 Views)

Re: Workspaces/Ribbonstate

12-17-2013 04:14 AM in reply to: Virupaksha.aithal

w'll change Workspaces based on usersettings, but the ribbonstate doesn't get changed accordingly.

Changing the Ribbonstate based on the type of Workspace would solve this issue.

 

This is a Ribbon Workspace example

[General]
UserFullname=Anton van Buiten
Paraaf=AVB
LoginName=avb


[Plot]
Location=PDF

[Setvars]
WSCURRENT=Infra Ribbon
CMD_RIBBON= Enable ribbon menu
OSMODE=4647
CMD_Modelspace=(command "tilemode" 1)

 

This is a Classic Workspace example

[Setvars]

WsCurrent=INFRA
MenuBar=0
NavBarDisplay=0
;CMD_RIBBONCLOSE=Sluit het ribbon menu

 

In order to correctly display a Classic or Ribbon Worspace the lines WSCURRENT,CMD_RIBBON and MENUBAR are coupled together.

So if the program can detect the type of Workspace (Classic|Ribbon) BEFORE making it active, then the calls to CMD_RIBBON and MENUBAR can be made implicit -- no need to add them to the usersettings.

 

 

 

 

Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 7 of 9 (337 Views)

Re: Workspaces/Ribbonstate

12-18-2013 12:00 AM in reply to: SENL1362

The main question was asked because for some reason the screen update after a change of Workspace from within VBA was not performed correctly.

For instance changing from Ribbon back to Classic did not close the Ribbon.

 

The (obvious) solution is to do this in .NET:

  Application.SetCurrentWorkspace(workspace.Name);

 

Thanks for any help

 

*Expert Elite*
dgorsman
Posts: 5,513
Registered: ‎10-12-2006
Message 8 of 9 (326 Views)

Re: Workspaces/Ribbonstate

12-18-2013 08:53 AM in reply to: SENL1362

A number of verticals no longer have the "classic" workspace, same with some allied products.  Probably a good time to start leaving it behind as well.  It will simplify your development and support process to boot.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Mentor
SENL1362
Posts: 181
Registered: ‎07-20-2011
Message 9 of 9 (317 Views)

Re: Workspaces/Ribbonstate

12-18-2013 12:28 PM in reply to: SENL1362

I know and you know it, but a lot of our users disagree. 

The switch makes them less productive for a short period.

But they will, eventually.

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.