Paavo is correct, this link will show you how to work with Workspaces and CUI elements.
This API is only available in .Net.
Regards,
Philippe.
[CommandMethod("CloneWorkSpace")]
public void CloneWorkSpace()
{
try
{
string sourceCuiFileName = @"C:\TEST.CUIX";
if (!System.IO.File.Exists(sourceCuiFileName))
return;
string curCuiFileName = Application.GetSystemVariable("MENUNAME").ToString() + ".cuix";
CustomizationSection curCui = new CustomizationSection(curCuiFileName);
CustomizationSection sourceCui = new CustomizationSection(sourceCuiFileName);
string workspaceName = "Acme Workspace";
WorkspaceCollection curWorkspaces = curCui.Workspaces;
int curWsIdx = curWorkspaces.IndexOfWorkspaceName(workspaceName);
// Acme Workspace already exists, so just return
// cloning overwrites the existing Workspace
if (curWsIdx != -1)
return;
Workspace newWs = sourceCui.getWorkspace(workspaceName);
ContainerCloneAction containerClnAction = new ContainerCloneAction();
Workspace ws = curWorkspaces[0];
curWorkspaces.Clone(newWs, ws, ref containerClnAction);
if (curCui.IsModified)
{
curCui.Save();
}
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
Application.ShowAlertDialog("AutoCAD exception:\n" + e.Message);
return;
}
}
// Command: remws
// This command removes a workspace. The name of the workspace to remove is
// obtained from the command line.
[CommandMethod("remws")]
public void remws()
{
String wsName;
PromptResult prs = ed.GetString("Enter name of workspace to remove: ");
if (PromptStatus.OK == prs.Status)
{
wsName = prs.StringResult;
// If the workspace exist
if (-1 != cs.Workspaces.IndexOfWorkspaceName(wsName))
{
cs.deleteWorkspace(wsName); // Remove the workspace
saveCui(); // Save and reload the CUI file
}
else
{
ed.WriteMessage("No workspace exists with this name");
}
}
}
Philippe Leefsma
Developer Technical Services
Autodesk Developer Network