I have a question about Python. By the way, I'm beginner of Python and English. I wrote a script showing Toruses from an imported txt file containing center coordinates, but I got an error at
bpy.ops.mesh.primitive_torus_add(location=(int(temp[0]), int(temp[1]), int(temp[2])), rotation=(math.pi/2, math.pi/2, math.pi/2))
I would appreciate if you tell me how to solve it.
Here is my script
import bpy
import math
f=open(r"C:\Users\biostr\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\traj_pro.txt", "r")
lines=[]
for line in f:
lines.append(line.strip())
for p in lines:
temp=p.split(',')
bpy.ops.mesh.primitive_torus_add(location=(int(temp[0]), int(temp[1]), int(temp[2])), rotation=(math.pi/2, math.pi/2, math.pi/2))
bpy.ops.object.shade_smooth()
obj=bpy.context.scene.objects.active
mat=bpy.data.materials.new('Torus')
mat.diffuse_color=(1.0, 0, 0)
mat.alpha=0.8
obj.data.materials.append(mat)
f.close()
Here is some lines from my txt file. Actually, my file is Atom's coordinates, can I make Toruses from this??
CRYST1 65.961 65.961 65.961 90.00 90.00 90.00 P 1 1
ATOM 1 N GLN X 1 32.110 46.350 52.070 1.00 0.00
ATOM 2 H1 GLN X 1 32.470 45.850 52.870 1.00 0.00
ATOM 3 H2 GLN X 1 32.931 46.641 51.559 1.00 0.00
ATOM 4 H3 GLN X 1 31.568 47.112 52.451 1.00 0.00
ATOM 5 CA GLN X 1 31.200 45.480 51.230 1.00 0.00
ATOM 6 HA GLN X 1 30.402 45.041 51.829 1.00 0.00
ATOM 7 CB GLN X 1 30.390 46.250 50.180 1.00 0.00
ATOM 8 HB1 GLN X 1 30.811 46.160 49.179 1.00 0.00