12
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ I'm also curious about how to set it back to the default value programatically (what that little green X does in your screenshot). $\endgroup$ – Szabolcs Feb 11 '13 at 18:52
11
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Spot on! Works nicely - and for the other options as well. I am looking forward to any answers topping that :-) $\endgroup$ – Yves Klett Feb 11 '13 at 18:39
  • $\begingroup$ @YvesKlett Glad to be of service. $\endgroup$ – Sjoerd C. de Vries Feb 11 '13 at 18:44
  • $\begingroup$ 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. $\endgroup$ – Szabolcs Feb 11 '13 at 18:53
  • 1
    $\begingroup$ Perhaps you can also mention $FrontEndSession for completeness... $\endgroup$ – rm -rf Feb 11 '13 at 19:14
  • 1
    $\begingroup$ @SjoerdC.deVries You might even mention the mythical $DefaulFrontEnd, taught to us by Director Futz here $\endgroup$ – Rolf Mertig Feb 11 '13 at 22:38
14
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ @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. $\endgroup$ – Rolf Mertig Feb 11 '13 at 22:40
  • 4
    $\begingroup$ But note what John Fultz has to say about problems with CurrentValue and $DefaultFrontEnd here. $\endgroup$ – Sjoerd C. de Vries Feb 11 '13 at 22:58
  • $\begingroup$ @Sjoerd Thanks for pointing that out, I didn't know. $\endgroup$ – Szabolcs Feb 11 '13 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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