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

How to add PartialCUIFile Tab to current workspace | 2012

1 REPLY 1
Reply
Message 1 of 2
matinau
771 Views, 1 Reply

How to add PartialCUIFile Tab to current workspace | 2012

I'm having difficulty accessing the CustomizationSection for a particular PartialCUI which I need to return the RibbonTabSource using AutoCAD 2012.

 

Here's the snippet

 

var cuiMain = (string)Application.GetSystemVariable("MENUNAME");

var csMain = new CustomizationSection(cuiMain);

 

//*** This line return null even when the PartialCUI exists? ****

CustomizationSection csPar = csMain.getPartialCUI("myPartialCui");

 


RibbonRoot rrPar = csPar.MenuGroup.RibbonRoot;
RibbonTabSource tabPar = rrPar.FindTab("RBNU_0001");

Workspace curWs = csMain.getWorkspace(curWorkspace);

csMain.MergeOrAddTabToWorkspace(curWs, tabPar);

 

if (csMain.IsModified)
{
    csMain.Save();
    Application.ReloadAllMenus();
}

 

Can you spot where i'm going wrong?

1 REPLY 1
Message 2 of 2
matinau
in reply to: matinau

Found a solution by ditching the GetPartialCUI method

 

var curWorkspace = (string) Application.GetSystemVariable("WSCURRENT");
var cuiMain = (string)Application.GetSystemVariable("MENUNAME");
var csMain = new CustomizationSection(cuiMain);

PartialCuiFileCollection pcfc = csMain.PartialCuiFiles;

string cuiMyPar = null;
foreach (string cui in pcfc)
{
    if (cui.ToLower().Contains("myParCui.cuix"))
    {
        cuiMyPar = cui;
    }
}

if (cuiMyPar == null || !File.Exists(cuiPar)) return;
var csMyPar = new CustomizationSection(cuiPar);

RibbonRoot rrMyPar = csMyPar.MenuGroup.RibbonRoot;
RibbonTabSource tabMyPar = rrMyPar.FindTab("RBNU_0001");

Workspace curWs = csMain.getWorkspace(curWorkspace);

csMain.MergeOrAddTabToWorkspace(curWs, tabMyPar);

if (csMain.IsModified)
{
    csMain.Save();
    Application.ReloadAllMenus();
}

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