I've simplified my code to what can reproduce my error. Basically, I have two lines:

 spherePoint[x_] := Graphics3D[Sphere[{x, 0, 0}, 1]]; 

 Manipulate[Show[spherePoint[m]], {{m, 1}, -Pi/2, Pi/2}]

This runs perfectly fine when I evaluate it in Mathematica notebook, but when I do a CDF preview (or export), it gives me the error

Show::gtype: spherePoint is not a type of graphics. >>

What gives?! Show should accept a Graphics3D, and spherePoint is a graphics 3D object! (I'm not sure about the last part of that sentence, because it's a function that gives a graphics 3d object, but I don't know what that implies for the program)

What am I doing wrong?

  • 5
    $\begingroup$ Add the option SaveDefinitions -> True to your Manipulate command. $\endgroup$ Dec 12, 2012 at 20:27
  • $\begingroup$ Of course you want to include an option such as PlotRange->3 in the Show expression; otherwise, the sphere doesn't appear to move as you change the slider. $\endgroup$
    – murray
    Dec 13, 2012 at 16:48

1 Answer 1


The problem is that exporting Manipulate/Animate/DynamicModule only saves definitions of scoped symbols (green). Specifically, it doesn't know your definition of spherePoint and, in CDF Player, you don't have the option to execute that command.

You can get around this using the SaveDefinitions -> True or by putting those "external" definitions in the Initialization option.

My experience is that Initialization is usually a bit more cross-platform independent. Here's how to use it:

spherePoint[x_] := Graphics3D[Sphere[{x, 0, 0}, 1]];

 Show[spherePoint[m]], {{m, 1}, -Pi/2, Pi/2},
 Initialization :> (
    spherePoint[x_] := Graphics3D[Sphere[{x, 0, 0}, 1]]
  • $\begingroup$ Thank you! How would I go about intializing multiple function definitions? What comes after the :> isn't a list, and in my program I have three functions to define. It works perfectly using SaveDefinitions though. $\endgroup$
    – user273
    Dec 13, 2012 at 1:06
  • 2
    $\begingroup$ @NeuroFuzzy Note how the value of the Initialization is wrapped in parentheses. You can wrap an arbitrary block of code in those parentheses - i.e. (f1[x_] := def1; f2[x_] := def2) $\endgroup$ Dec 13, 2012 at 1:21
  • 2
    $\begingroup$ @Kuba I have no problem with edits and I think you've made a net improvement - thanks! One thing: The original question concerned CDF Player. When I originally answered the question, that seemed important to me. In particular, when you open the document in CDF Player, you don't even have the option to execute that line where spherePoint is defined. I'll add that part back in. $\endgroup$ Sep 29, 2016 at 18:40
  • $\begingroup$ @MarkMcClure Ah, now I get that. Sure. $\endgroup$
    – Kuba
    Sep 29, 2016 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.