If I import an SVG curve by python, always is working except of assign material. Manually I can assign any material, but by python nothing works. There is part of my code:
mat = bpy.data.materials.get("Z")
for emboss in embosses:
emb_name = emboss[:-4]
loadedSVG = bpy.ops.import_curve.svg(filepath = embossDir + emboss, filter_glob=".svg")
for obj in bpy.data.objects:
if obj.tag == False:
obj.name = emb_name
obj.tag = True
x, y, z = obj.dimensions
if x >= y:
needRatio = maxSize / x
if y > x:
needRatio = maxSize / y
bpy.ops.object.select_pattern(pattern = emb_name)
bpy.data.objects[emb_name].scale = (needRatio, needRatio, needRatio)
#two from my attempts, nothing works, material is correct
bpy.data.objects[emb_name].materials = [mat]
bpy.data.objects[emb_name].setMaterials([mat])
#end of not-working code
bpy.data.objects[emb_name].rotation_euler = (0, 0, math.radians(90))
bpy.data.objects[emb_name].location = (-0.06864 + (maxSize - y * needRatio)/2, 1.18165 + (maxSize - x * needRatio)/2, 0.02419)
bpy.ops.object.select_all(action='DESELECT')
Only message "AttributeError: 'Object' object has no attribute 'materials'" in the system console.
I know that I'm doing some mistake, but I can't find anything three days in code but through the web too. Thanks for correcting my code.