Results 1 to 2 of 2

Thread: Change Paperspace Background Color with .NET

Hybrid View

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2008-09
    Posts
    1

    Default Change Paperspace Background Color with .NET

    I try to migrate the following VBA program to .NET but witout success.

    Could help me?

    Code:
    Public Sub DEU_MDCNE_SwapLayoutBackgrnd()
    
        'Initialize
        '----------------------------------------------------------------
        Dim preferences As AcadPreferences
        Dim currGraphicsWinLayoutBackgrndColor As OLE_COLOR
        Dim StdGrey As OLE_COLOR
        
        On Error GoTo Error
        
        Set preferences = ThisDrawing.Application.preferences
        StdGrey = 12632256
        
        ' Retrieve the current GraphicsWinLayoutBackgrndColor value
        currGraphicsWinLayoutBackgrndColor = preferences.Display.GraphicsWinLayoutBackgrndColor
            
        ' Change the value for GraphicsWinLayoutBackgrndColor
        If currGraphicsWinLayoutBackgrndColor <> vbWhite Then
            preferences.Display.GraphicsWinLayoutBackgrndColor = vbWhite
            Else: preferences.Display.GraphicsWinLayoutBackgrndColor = StdGrey
        End If
        
        Exit Sub
        
    Error:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure 'DEU_MDCNE_SwapLayoutBackgrnd'"
    End Sub
    Last edited by Opie; 2008-09-16 at 04:31 PM. Reason: [CODE] tags added, see Moderator Note

  2. #2
    Member dmarcotte4's Avatar
    Join Date
    2003-10
    Posts
    43

    Default Re: Change Paperspace Background Color with .NET

    Here is a sample in C#

    Daniel

    Code:
    using Autodesk.AutoCAD.EditorInput;
    using Autodesk.AutoCAD.Runtime;
    
    // A reference to COM
    using Autodesk.AutoCAD.Interop;
    using AcAp = Autodesk.AutoCAD.ApplicationServices;
    
    
    [assembly: CommandClass(typeof(ExecMethod.Commands))]
    
    namespace ExecMethod
    {
      public class Commands
      {
        [CommandMethod("doit")]
        public static void PaneButton()
        {
          Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
          try
          {
            AcadPreferences pref = AcAp.Application.Preferences as AcadPreferences;
            pref.Display.GraphicsWinLayoutBackgrndColor = 12632256;
          }
          catch (System.Exception ex)
          {
            ed.WriteMessage(ex.Message);
          }
        }
      }
    }

Similar Threads

  1. 2011 paperspace background color
    By Spectrefish in forum AutoCAD LT - General
    Replies: 25
    Last Post: 2013-03-14, 03:43 PM
  2. Change Background Color for outside layout
    By Capt. Computer Crasher in forum AutoCAD General
    Replies: 2
    Last Post: 2009-11-17, 08:48 PM
  3. Change Background color of Cells
    By Jack Cheong in forum AutoCAD Tables
    Replies: 1
    Last Post: 2008-05-22, 11:33 AM
  4. Why would MS background change color?
    By kleenhippie in forum CAD Management - General
    Replies: 1
    Last Post: 2008-01-25, 02:06 PM
  5. Change Field background color
    By ccowgill in forum AutoCAD Fields
    Replies: 3
    Last Post: 2006-02-09, 12:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •