.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Workspaces/Ribbonstate

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
SENL1362
1765 Views, 8 Replies

Workspaces/Ribbonstate

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);

        }

 

 

8 REPLIES 8
Message 2 of 9

Hi,

 

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



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Message 3 of 9

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



Message 4 of 9
SENL1362
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
}
}
Message 5 of 9

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

Message 6 of 9

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.

 

 

 

 

Message 7 of 9
SENL1362
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

 

Message 8 of 9
dgorsman
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.
"I don't know" is the beginning of knowledge, not the end.


Message 9 of 9
SENL1362
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.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost