MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Writing Lists to files

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Writing Lists to files
  • From: twj (Tom Wickham-Jones)
  • Date: Sun, 13 Mar 1994 09:43:21 -0600

Robert Love writes

>How do I write a graphics object to a file and later read it back in?

..

>I now have a function to process the raw data, make Graphics3D lists  

>and write it to a file, and a function to read it back in and render  

>it.  It works only as long as I have the same MMA session going.  If  

>I come back another day, I can't just use the file produced by the  

>write function.  I have to execute it in this session and then read  

>it.  The error when I try to show what I've read in is "Symbol is a  

>type of graphics".  Yet if I look at the file that was written it  

>looks like:
>{Graphics3D[Line[{{-0.1074786999302791, 0.0001500686726859751, 

>
>      -0.994207376024082}, {-0.0987432588630104,  

>-0.003310157494793516, 



Without seeing the EXACT input it is difficult to comment on
why this is not working.   However it is possible to make
a Graphics3D object and save it in a file to be restored later.
The same can be done for any other Mathematica expression.


coringa [40] twj> math
Mathematica 2.2 for NeXT
Copyright 1988-93 Wolfram Research, Inc.
 -- NeXT graphics initialized -- 


In[1]:= a = ParametricPlot3D[ {Sin[t], Cos[t], z},
                {t,0,2Pi}, {z,0,2}]

Out[1]= -Graphics3D-

In[2]:= a >> file.dat 		(* save the object *)

In[3]:= Exit

In[2] is shorthand for Save[ "file.dat", a]


coringa [41] twj> math
Using porting image.
Mathematica 2.2 for NeXT
Copyright 1988-93 Wolfram Research, Inc.
 -- NeXT graphics initialized -- 


In[1]:= a = << file.dat		(* get the object keep as value of symbol a*)

Out[1]= -Graphics3D-

In[2]:= Show[ a]

Out[2]= -Graphics3D-


In[1] is shorthand for a = Get[ "file.dat"]



Save will write the definitions of a symbol into a file.
Get will input the file and turn the contents into Mathematica expressions. 





I hope this is useful.


Tom Wickham-Jones
WRI







  • Prev by Date: same options for 30 functions?
  • Next by Date: Mathematica World - Education Today
  • Previous by thread: Writing Lists to files
  • Next by thread: Re: Writing Lists to files