Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Can I set global preferences that are accessible via "Edit"->"Preferences" programmatically from within a notebook?

As learned from this question, turning off anti-aliasing can make a huge difference in the maximum allowable ImageSize. This can be done via menu:

Mathematica graphics

The slider is setting the value of HardwareAntialiasingQuality that can be found with the option inspector:

Mathematica graphics

Question: Is there a way to set/reset the value of HardwareAntialiasing (and others) programmatically? I´d like to set this with a line only in those notebooks that benefit from this setting and have proper antialiasing for the rest.

Footnote: this answer does help with setting the rendering method directly within a Graphics3D expression, and as @Sjoerd's answer shows this also works in more global way.

share|improve this question
1  
I'm also curious about how to set it back to the default value programatically (what that little green X does in your screenshot). –  Szabolcs Feb 11 '13 at 18:52
add comment

2 Answers 2

up vote 9 down vote accepted

I believe the following should work:

SetOptions[$FrontEnd, RenderingOptions -> {"HardwareAntialiasingQuality" -> 1}]

for a permanent global setting,

SetOptions[$FrontEndSession, RenderingOptions -> {"HardwareAntialiasingQuality" -> 1}]

for a temporary (session duration) global setting, and

SetOptions[EvaluationNotebook[], RenderingOptions -> {"HardwareAntialiasingQuality" -> 1}]

in each notebook for which you want an individualized setting.

share|improve this answer
    
Spot on! Works nicely - and for the other options as well. I am looking forward to any answers topping that :-) –  Yves Klett Feb 11 '13 at 18:39
    
@YvesKlett Glad to be of service. –  Sjoerd C. de Vries Feb 11 '13 at 18:44
    
Maybe it's good to note that CurrentValue works as well. It is advantageous to use CurrentValue when there are sub options to an option (like a -> {b -> 1, c -> 2}) because it makes it easy to set one sub option without touching the rest. –  Szabolcs Feb 11 '13 at 18:53
1  
Perhaps you can also mention $FrontEndSession for completeness... –  rm -rf Feb 11 '13 at 19:14
1  
@SjoerdC.deVries You might even mention the mythical $DefaulFrontEnd, taught to us by Director Futz here –  Rolf Mertig Feb 11 '13 at 22:38
show 3 more comments

Instead of SetOptions, it is also possible to use CurrentValue. In this particular case the syntax is

CurrentValue[$FrontEnd, {RenderingOptions, "HardwareAntialiasingQuality"}] = 1.0

CurrentValue is easier to use than SetOptions in the situation when a single option has multiple sub options. If we have an option of the form opt -> {a -> 1, b -> 2}, then SetOptions[..., opt -> {a -> 1}] would remove the sub-option b. (This is not the case with RenderingOptions, but it is with others, e.g. "PalettesMenuSettings" or TaggingRules, which can have completely arbitrary sub options.) The simplest solution in this situation is CurrentValue[object, {opt, a}] = .... This will not touch the suboption b.

share|improve this answer
1  
@Scabolcs +1 Also: sometimes SetOptions just does not work. E.g. SetOptions[Cell,CellEpilog->somefun] gives a strange message, while CurrentValue is acting just fine. –  Rolf Mertig Feb 11 '13 at 22:40
4  
But note what John Fultz has to say about problems with CurrentValue and $DefaultFrontEnd here. –  Sjoerd C. de Vries Feb 11 '13 at 22:58
    
@Sjoerd Thanks for pointing that out, I didn't know. –  Szabolcs Feb 11 '13 at 23:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.