The problem seems to be the way the x3d is formed. This for instance does work
<X3D>
<Scene>
<Transform rotation="0.40 0.20 -1.00 1.025000"
translation="2.999375 1.024990 1.000000"
scale="1 1 1">
<Shape>
<Cylinder height='1.8' radius="0.200" top="true"/>
<Appearance>
<Material diffuseColor='0 1 1'/>
</Appearance>
</Shape>
</Transform>
</Scene>
</X3D>
from your comment on the removed post:
The problem is that I have tons of these cylinders (I am trying to visualize a 3d polyline), so writing all of them to meshes creates a very large file.
Blender has an Object type called 'Curve', which can be given a thickness and therefore be renderable. Curves can behave like polylines, with straight segments. If your intention is to render a polyline, instead of letting the x3d importer convert primitive-commands into mesh based primitives, you might devise a way to import a sequence of edges as a Path Curve and set its bevel thickness instead.
For example:
import bpy
from mathutils import Vector
# weight
w = 1
# we don't have to use the Vector() notation.
listOfVectors = [(0,0,0),(1,0,0),(2,0,0),(2,3,0),(0,2,1)]
def MakePolyLine(objname, curvename, cList):
curvedata = bpy.data.curves.new(name=curvename, type='CURVE')
curvedata.dimensions = '3D'
curvedata.bevel_depth = 0.3
curvedata.bevel_resolution = 4
curvedata.fill_mode = 'FULL'
object = bpy.data.objects.new(objname, curvedata)
object.location = (0,0,0) #object origin
bpy.context.scene.objects.link(object)
polyline = curvedata.splines.new('NURBS')
polyline.points.add(len(cList)-1)
for num in range(len(cList)):
polyline.points[num].co = (cList[num])+(w,)
polyline.order_u = len(polyline.points)-1
polyline.use_endpoint_u = True
polyline.order_u = 2
MakePolyLine("NameOfMyCurveObject", "NameOfMyCurve", listOfVectors)
Now, this creates one polyline, but it can easily be called again and again to make different sections if they need alternating colours.
import_x3d.py
file and it does appear to support parametric shapes.. @olamundo do you have a full .x3d to test including header tags and stuff. $\endgroup$