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

WSSAVE equivalent in .NET

2 REPLIES 2
Reply
Message 1 of 3
DualShock
540 Views, 2 Replies

WSSAVE equivalent in .NET

Hi,

 

Is there an equivalent .NET API call for the "wssave" command? (Other than using a SendStringToExecute()).

 

I am attempting to save the user's current workspace as a new one, by cloning the current one and saving it with a new name:

 

 

string mainCuiFile = (string)Application.GetSystemVariable("MENUNAME");
CustomizationSection cs = new CustomizationSection(mainCuiFile + ".cui");

string entCuiFile = (string)Application.GetSystemVariable("ENTERPRISEMENU");
CustomizationSection entCs = new CustomizationSection(entCuiFile + ".cui");

string currentWorkspace = (string)Application.GetSystemVariable("WSCURRENT");

Workspace current = null;

if (currentWorkspace == "OurDefaultWorkspace")
current = entCs.getWorkspace(currentWorkspace);
else
current = cs.getWorkspace(currentWorkspace);

ContainerCloneAction cca = ContainerCloneAction.Replace;

Workspace user = cs.Workspaces.Clone(current, null, ref cca);

user.Name = "UserWorkspace";

cs.Save();

(For various reasons our enterprise cui was made read-only by the CAD Admin, which includes the stock AutoCAD menu structure as a partial cui to it. So the main cui file is the one that is editable by the user.)

 

However, if I do this, the new workspace called "UserWorkspace" does not contain the current layout of the user's toolbars, palettes, etc. Rather, it contains the layout defined in "OurDefaultWorkspace", which was created by our CAD Admin.

 

If I run "wssave" and give it a name of "UserWorkspace", toolbar/palette/whatever positioning gets saved correctly.

 

In addition, I am still trying to figure out where the current layout of the user's toolbars/palettes/whatever is saved, since in my scenario, there is no workspace defined to save it in. But when I close and reopen AutoCAD, everything is where I left it previously, which happens to be different from "OurDefaultWorkspace" because I moved stuff around.

 

Any help would be greatly appreciated!

 

2 REPLIES 2
Message 2 of 3
masc419
in reply to: DualShock

Hi DualShcok,

 

Did you happen to come across the solution for this?

Message 3 of 3
masc419
in reply to: masc419

I ended up handling it this way...

 

string _workspaceName = (string)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("WSCURRENT");

 

int _oldAutoSave = System.Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("WSAUTOSAVE"));

Autodesk.AutoCAD.ApplicationServices.

Application.SetSystemVariable("WSAUTOSAVE", 1);

Autodesk.AutoCAD.ApplicationServices.

Application.SetSystemVariable("WSCURRENT", _workspaceName);

Autodesk.AutoCAD.ApplicationServices.

Application.SetSystemVariable("WSAUTOSAVE", _oldAutoSave);

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