From: Gerry Flanagan on
As usual, I found the work around a few minutes after posting. I guess
the right way is to build all the cells first, then create the document
in one shot using CreateDocument. I was trying to create a document,
then write to it cell by cell. Should work, and I still don't understand
why it doesn't, but CreateDocument combined with ExpressionCell does
what I want.
GF

How do you send a graphic to a notebook under program control? For
example, taking the documentation example
CellPrint[Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]], "Output"]]
and changing to
NotebookWrite[nb, Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]],
"Output"]]
gives an error message (nb is a previously created notebook object).

I think I've seen this somewhere, and remember it was pretty obscure.
Surprising that anything to works inside CellPrint would not work inside
NotebookWrite.
Gerry F.


From: John Fultz on
There's nothing fundamentally wrong with your NotebookWrite[] command, and it
worked for me. If you're interested in pursuing why this didn't work, you'll
have to provide more context.

Sincerely,

John Fultz
jfultz(a)wolfram.com
User Interface Group
Wolfram Research, Inc.


On Fri, 6 Nov 2009 05:16:54 -0500 (EST), Gerry Flanagan wrote:
> As usual, I found the work around a few minutes after posting. I guess
> the right way is to build all the cells first, then create the document
> in one shot using CreateDocument. I was trying to create a document,
> then write to it cell by cell. Should work, and I still don't understand
> why it doesn't, but CreateDocument combined with ExpressionCell does
> what I want.
> GF
>
> How do you send a graphic to a notebook under program control? For
> example, taking the documentation example
> CellPrint[Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]], "Output"]]
> and changing to
> NotebookWrite[nb, Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]],
> "Output"]]
> gives an error message (nb is a previously created notebook object).
>
> I think I've seen this somewhere, and remember it was pretty obscure.
> Surprising that anything to works inside CellPrint would not work inside
> NotebookWrite.
> Gerry F.




From: Gerry Flanagan on
Weird,
Works for me now also. Something must of have happened to the open
notebook that a new morning fixed.
GF

John Fultz wrote:
There's nothing fundamentally wrong with your NotebookWrite[] command, and it
worked for me. If you're interested in pursuing why this didn't work, you'll
have to provide more context.

Sincerely,

John Fultz
User Interface Group
Wolfram Research, Inc.


On Fri, 6 Nov 2009 05:16:54 -0500 (EST), Gerry Flanagan wrote:
As usual, I found the work around a few minutes after posting. I guess
the right way is to build all the cells first, then create the document
in one shot using CreateDocument. I was trying to create a document,
then write to it cell by cell. Should work, and I still don't understand
why it doesn't, but CreateDocument combined with ExpressionCell does
what I want.
GF

How do you send a graphic to a notebook under program control? For
example, taking the documentation example
CellPrint[Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]], "Output"]]
and changing to
NotebookWrite[nb, Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]],
"Output"]]
gives an error message (nb is a previously created notebook object).

I think I've seen this somewhere, and remember it was pretty obscure.
Surprising that anything to works inside CellPrint would not work inside
NotebookWrite.
Gerry F.