PLY (.ply)

3D geometry format.
ASCII or binary format.
Used for storage and interchange of 3D graphical objects.
Known as Stanford Triangle Format.
PLY is an acronym derived from polygon.
Stores a 3D object as a collection of line and polygon primitives and their properties.
Allows user-defined format elements.
  • Import and Export fully support the ASCII and binary PLY file formats.

Import and ExportImport and Export

  • Import["file.ply"] imports a PLY file as a Graphics3D object.
  • Export["file.ply", expr] exports a Graphics3D expression to a binary PLY file.
  • Import["file.ply"] returns an expression of the form Graphics3D[ GraphicsComplex[...]].
  • Import["file.ply", elem] imports the specified element from a PLY file.
  • Import["file.ply", {elem, suba, subb, ...}] imports a subelement.
  • Import["file.ply", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "PLY"] or Import["file", {"PLY", elem, ...}].
  • Export["file.ply", expr, elem] creates a binary PLY file by treating expr as specifying element elem.
  • Export["file.ply", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.ply", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.ply", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the PLY format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Graphics3D"PLY file represented as a Graphics3D object
    "GraphicsComplex"PLY file as a GraphicsComplex object
    "LineData"the line elements of a PLY file in indexed form, with integer indices referencing the vertices as given by
    "LineObjects"list of Line primitives given in absolute coordinates
    "PolygonData"the polygon elements in indexed form
    "PolygonObjects"list of Polygon primitives given in absolute coordinates
    "UserExtensions"user-defined data associated with polygon vertices
    "VertexColors"colors associated with each vertex, given as a list of color primitives
    "VertexData"list of vertex coordinates
    "VertexNormals"normal vectors corresponding to the vertices given by
  • Import and Export use the element by default for PLY files.
  • The element corresponds to the first argument of GraphicsComplex.
  • When rendering a PLY color model, Import automatically uses the setting Lighting->"Neutral".
  • User-defined elements:
  • "UserExtensions"names of user-defined data fields, given as a list of strings
    "UserExtensions",fielduser-defined data field as a list of values associated to each vertex as given by

OptionsOptions

  • General Import options:
  • BackgroundAutomaticwhat background color to use
    ImageSizeAutomaticoverall size of the graphics to display
    LightingAutomaticwhat simulated lighting to use in coloring 3D surfaces
  • Advanced options:
  • "BinaryFormat"Truewhether the file is in ASCII or binary format
    "DataFormat"Automaticdata types used in the binary format
    "InvertNormals"Falsewhether to invert the orientation of vertex normals
    "VerticalAxis"{0,0,1}orientation to assume for the coordinate system used in the file
    "Comments"Nonecomments to be embedded in the file
  • Binary PLY files normally store data as IEEE single-precision floating-point numbers, which correspond to the setting .
  • With the setting , vertices and normal vectors are stored as double-precision numbers.
  • The data types used for the vertex coordinates and for the normal vectors can be specified explicitly with or .
  • By default, Mathematica assumes that in the coordinate system used by the PLY format the vertical axis corresponds to the third coordinate.
  • With the setting , Mathematica will apply the transformation to all graphics coordinates when importing from PLY, and the inverse transformation when exporting to PLY.

ExamplesExamplesopen allclose all

Basic Examples (5)Basic Examples (5)

Import a PLY example file and render it as 3D graphics:

In[1]:=
Click for copyable input
Out[1]=

This imports a simple PLY file:

In[1]:=
Click for copyable input
Out[1]=

Import the vertex coordinates:

In[2]:=
Click for copyable input
Out[2]=

Calculate the number of vertices representing this dodecahedron:

In[3]:=
Click for copyable input
Out[3]=

Import the polygon information. The integer indices refer to the coordinates as given by :

In[4]:=
Click for copyable input
Out[4]=

An Export example using inline 3D graphics:

In[1]:=
Click for copyable input
Out[1]=

Create a 3D model using RegionPlot3D and export it to PLY:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Create a 3D model with comments to PLY:

In[1]:=
Click for copyable input
Out[1]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »