I need to write e blender plugin that exports objects in VRML2 from .ply. The problem is that my objects can be either meshes, either point clouds. Exporting meshes works with the already existing plugin, but it does not correctly export point clouds: creates IndexedFaceSet in stead of PointSet node, adds some extra fields which don't apply to PointSet, etc. So I have 2 questions:

  1. How can I check automatically if I have a mesh or a point cloud? This is part of a bigger web service and I need to check via the code, not by ticking a box.
  2. How do I get the color of each point? The data is not in the same place as the color information for meshes.


EDIT Actually after a short investigation of the .ply importer, it seems that it does not properly import. It does not read the point colors in the case of point clouds


1 Answer 1


The vrml export addon is an official addon that is developed as part of blender. You could either discuss with the blender devs on irc about improving it or submit a patch yourself to be considered for addition. Or use it as a starting point for your own script.

For 1. A mesh object that has a number of vertices and zero faces could be considered a point cloud.

import bpy
import bmesh
bm = bmesh.new()
numberOfVerts = len(bm.verts)
numberOfFaces = len(bm.faces)

Incorporate that into the export script as it loops through objects and export as PointSet instead of IndexedFaceSet when you have verts without faces.

For 2. blender has vertex colours, without faces that would be the only place for colour info. You will find that data in bpy.context.active_object.data.vertex_colors

  • $\begingroup$ I haven't gotten around to test it in a complete thing but it seems to to the job. :) Thanks for the reply. $\endgroup$
    – adi
    Dec 2, 2013 at 11:53

You must log in to answer this question.