Blender export point cloud to vrml 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:


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.
How do I get the color of each point? The data is not in the same place as the color information for meshes.


Thanks

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
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()
bm.from_mesh(bpy.context.active_object.data)
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