Author Topic: "DefaultConfig" Setting from the ARG Profile File  (Read 2195 times)

0 Members and 1 Guest are viewing this topic.

autogis

  • Guest
"DefaultConfig" Setting from the ARG Profile File
« on: November 19, 2013, 11:14:44 PM »
When you extract the profile info (Options>>Profile>>Export) the "DefaultConfig" is a setting found in the ...\General] section of the arg file.    How would you programmatically change that setting in AutoCAD.  For example:

 

...DefaultConfig="Microsoft XPS Document Writer"

 

Does anyone know if this is possible in .NET/Interop?

 
Thank You

autogis

  • Guest
Re: "DefaultConfig" Setting from the ARG Profile File
« Reply #1 on: November 20, 2013, 09:59:25 AM »
All done!  :-D

Here is the code to set the Default Output Device ("DefaultConfig" in the ARG file) from .NET:

Code: [Select]
private void setupDefaultOutputDevice()
        {

            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            //Cast the current autocad application from .net to COM interop
            Autodesk.AutoCAD.Interop.AcadApplication oApp;
            oApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;

            //Get the user preferences on the current profile
            AcadPreferences profile = oApp.Preferences;

            //Configure the default preferences
            try
            {

                // Setup New Default Output Device (Must Exist)
                string proposedDefaultOutputDevice = "Microsoft XPS Document Writer";

                // Get DefaultConfig (From Autocad)
                string currentDefaultOutputDevice = profile.Output.DefaultOutputDevice;

                // Update Autocad if it does not match requested setting
                if (proposedDefaultOutputDevice != currentDefaultOutputDevice)
                {
                    // Write new Default Output Device
                    profile.Output.DefaultOutputDevice = proposedDefaultOutputDevice;
                    // Log
                    ed.WriteMessage("Default Output Device was incorrect.  Setting new ...\n");
                    ed.WriteMessage("Old Output Device: " + currentDefaultOutputDevice + "\n");
                    ed.WriteMessage("New Output Device: " + proposedDefaultOutputDevice + "\n");
                }

            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR: setupDefaultOutputDevice: " + ex.Message + "\n");
                ed.WriteMessage("ERROR: setupDefaultOutputDevice: " + ex.StackTrace + "\n");
            }
        }