.NET

Reply
Contributor
ericdaniel
Posts: 25
Registered: ‎10-14-2005
Message 1 of 8 (839 Views)
Accepted Solution

Change Drawing Editor Background color

839 Views, 7 Replies
02-09-2011 10:24 AM

HI,

 

Is it possible to change the drawing editor background color via code?

 

Thanks,

 

Eric

 

Active Contributor
dan.glassman
Posts: 43
Registered: ‎09-23-2008
Message 2 of 8 (838 Views)

Re: Change Drawing Editor Background color

02-09-2011 10:29 AM in reply to: ericdaniel

Using COM Interop, you need:

 

Application.Preferences.Display.GraphicsWinModelBackgrndColor 

 

and/or

 

Application.Preferences.Display.GraphicsWinLayoutBackgrndColor

 

-drg

Contributor
ericdaniel
Posts: 25
Registered: ‎10-14-2005
Message 3 of 8 (834 Views)

Re: Change Drawing Editor Background color

02-09-2011 10:35 AM in reply to: dan.glassman

Perfect,

 

Thanks,

 

Eric

 

Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 4 of 8 (420 Views)

Re: Change Drawing Editor Background color

11-04-2011 02:30 PM in reply to: ericdaniel

Hi,

 

is there other way to change the background, not using COM?

 

Actually I need to change the model background to different colors, to generate pictures used in a different application. If the pictures will have different colors(some black, some grey, etc) it would be easier to surf through them when finding the right one.

 

Any suggestions?

 

Thanks,

 

e.g.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 5 of 8 (408 Views)

Re: Change Drawing Editor Background color

11-04-2011 04:16 PM in reply to: e.g.

Hi,

 

>> is there other way to change the background, not using COM?

why don't you like to use COM?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 6 of 8 (383 Views)

Re: Change Drawing Editor Background color

11-06-2011 03:31 PM in reply to: ericdaniel

It is ok with COM; it is only from curiosity to know the equivalent in API

 

Thanks,

 

e.g.

Valued Mentor
fieldguy
Posts: 367
Registered: ‎03-31-2005
Message 7 of 8 (270 Views)

Re: Change Drawing Editor Background color

11-16-2012 08:26 AM in reply to: e.g.

There are several posts on this topic but no examples.  I looked in the vb forum and objectarx but could not find anything I really understand.  I have Option Strict On.

 

Why doesn't this work?  bgcolor changes from 0 to 1 but the background stays black - I want it to change to red.

 

Dim prefs As Autodesk.AutoCAD.Interop.AcadPreferences = CType(Autodesk.AutoCAD.ApplicationServices.Application.Preferences, Autodesk.AutoCAD.Interop.AcadPreferences)
Dim bgcolor As UInteger = prefs.Display.GraphicsWinModelBackgrndColor
msg += "color " & bgcolor & vbLf
prefs.Display.GraphicsWinModelBackgrndColor = CType(Autodesk.AutoCAD.Interop.Common.ACAD_COLOR.acRed, UInteger)

I am creating PNGs of all blocks in any dwg file.  I get a list of blocks, insert them into a new drawing 1 at a time, and plot using publishtowebPNG.pc3.  I want to allow the user to change the background color if they want.  The PNGs will be used in other places.

Valued Mentor
fieldguy
Posts: 367
Registered: ‎03-31-2005
Message 8 of 8 (255 Views)

Re: Change Drawing Editor Background color

11-16-2012 12:48 PM in reply to: fieldguy

I should have kept looking.  This works.  Don't forget to set it back to the original value.

 

Dim prefs As Autodesk.AutoCAD.Interop.AcadPreferences = CType(Autodesk.AutoCAD.ApplicationServices.Application.Preferences, Autodesk.AutoCAD.Interop.AcadPreferences)
Dim curbg As Color = ColorTranslator.FromOle(CInt(prefs.Display.GraphicsWinModelBackgrndColor))
msg += "color " & curbg.ToString & vbLf
prefs.Display.GraphicsWinModelBackgrndColor = CType(ColorTranslator.ToOle(Color.Red), UInteger)

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community