Good afternoon people. I’m new to Blender and I have a problem, which I think is a simple solution, but I can not solve. Sorry if my question is too amateur for the group, but I really need help.
I have a quote by BlenderGame, I have an object that moves the read from a CSV coordinates. Until then all Ok.
This object has the data coordinate Desirable, and coordinate it performs by a PID control.
I would like to create a line or cylinder with coordinated that the object should perform. A reference line. I do this with Python code at runtime.
When I click on “P” and the Blender Game run the application, the line is created, but does not appear in the world. But when I give “ESC” to end execution, the line is there. But still it does not appear when I run.
It seems that it is not in the correct context.
From what I saw, I need to create the BGE API, but do not know the right way.
The code that creates the line via Python is this:
import os import bpy filename = 'posRef.csv' directory = '/home/scholl/Dropbox/' # <-- if you have linux or osx fullpath = os.path.join(directory, filename) with open(fullpath, 'r', newline='') as csvfile: # split every row at the comma,, rows = (r.split(',') for r in csvfile if r) # then take the first 3 values and cast them as float #verts = [[print(type(float(i))) for i in r[:3]] for r in rows] verts = [[0,0,1],[1,0,1],[2,0,1],[3,0,1],[4,0,1],[5,0,1]] if verts: out2 =  [out2.extend(list(i)+[0.0]) for i in verts] # first coordinate is present by default, we add the (number of total verts) - 1 num_points_to_add = len(verts) - 1 curve = bpy.data.curves.new("TubesCurve", type='CURVE') curve.dimensions = '3D' curve.fill_mode = 'FULL' curve.bevel_depth = 0.1 curve.bevel_resolution = 3 polyline = curve.splines.new(type='POLY') polyline.points.add(num_points_to_add) # a flatterened list of [x1, y1, z1, x2, y2 .... y20, z20] print(out2) polyline.points.foreach_set('co', out2) obj = bpy.data.objects.new("mesh", curve) scene = bpy.context.scene scene.objects.link(obj)
I thank anyone who can guide me.