I get an error on the path name in 2.8
and this should work only on the elected object !
import bpy
outputFile = ‘H:\Users\richa)script-218-2\Verts-save-CSV/verts.csv’
verts = [ bpy.context.object.matrix_world * v.co for v in bpy.context.object.data.vertices ]
csvLines = [ “;”.join([ str(v) for v in co ]) + “\n” for co in verts ]
f = open( outputFile, ‘w’ )
f.writelines( csvLines )
f.close()
can some one help to make this work in 2.8
note:
after changing name to just file name to save in local folder
I get another error
TypeError: Element-wise multiplication: not supported between ‘Matrix’ and ‘Vector’ types
thanks
happy bl
Secrop
(Secrop)
April 10, 2020, 6:10am
2
For matrix-vector multiplication, Python now uses the ‘@’ operator…
So instead of:
verts = [ bpy.context.object.matrix_world * v.co for v in bpy.context.object.data.vertices ]
you should use:
verts = [ bpy.context.object.matrix_world @ v.co for v in bpy.context.object.data.vertices ]
1 - when you add text in py file I get an error like this
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 573-574: truncated \UXXXXXXXX escape
do you know how to detect and correct these errors ?
2 - for verts data is it necessary to do the multiply ?
this gives the local coordinates
I guess otherwise you’d get the world values !
thanks
happy bl
Secrop
(Secrop)
April 10, 2020, 12:28pm
4
1- Your path is wrong. Fix the \
's (better to use \\
) and don’t mix them with /
it’s a Python error, so looking into the python manual will help.
2- vertex.co
for local coordinates, matrix_world @ vertex.co
for world coordinates, and if you want vertex coordinates with modifiers, animations, etc applied, you need to evaluate_get
with the depsgraph (read the blender api manual!)