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

How to Import and delete workspaces?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mobj
1589 Views, 3 Replies

How to Import and delete workspaces?

I've tried searching the ObjectARX dokumentation and this forum, but can't find any methods to import/transfer a workspace from one CUIx to the Mail CUIx. Also I need a method to delete an existing workspace in the main CUIx.

 

Can someone point me in the right direction?

Morten Bastue Jacobsen
Rambøll Danmark A/S
www.ramboll.dk
3 REPLIES 3
Message 2 of 4
techsoft3d
in reply to: mobj

Check out this thread, there's a sample project attached to Wayne Brill's post (CUISAMP_2010.zip) that iterates workspaces, and I think there's also sample code for add and removal of workspaces.

 

http://forums.autodesk.com/t5/NET/Creating-new-customized-menu-and-toolbar-in-Autocad-2010-using/td-...

 

 

Cheers,

Paavo

Message 3 of 4

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

Message 4 of 4
mobj
in reply to: philippe.leefsma

Thanks, this looks very promising. 🙂
Morten Bastue Jacobsen
Rambøll Danmark A/S
www.ramboll.dk

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