I have two questions both related to python scripting:
1) I want to set the units to mm, for that, I change the scale to 0.001 in both Scene and Display in the properties panel. When I copy the commands and run it as a script I get an AttributeError saying:
"AttributeError: 'SpaceTextEditor' object has no attribute 'context'"
In one of the answers, I understood that this just clicks the button in the properties editor and since we are running it from a script the line can be removed. But the next line, where you set the scale length, also throws an error saying:
"AttributeError: 'Scene' object has no attribute 'system'"
2) I want to scale an Ico sphere along the three axes, I change it in the properties panel but the code generated does not take into effect the changes in these values. Please find the code below:
import bpy
bpy.ops.object.delete(use_global=False)
bpy.data.objects["Camera"].hide = True
bpy.data.objects["Lamp"].hide = True
bpy.context.space_data.context = 'SCENE'
bpy.context.scene.system = 'METRIC'
bpy.context.scene.scale_length = 0.001
bpy.context.space_data.grid_scale = 0.001
bpy.ops.mesh.primitive_ico_sphere_add(size=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=3, size=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.location[0] = 20
bpy.context.object.location[1] = 50
bpy.context.object.location[2] = -14
bpy.context.object.dimensions[0] = 2 # changes not taken into effect (40 on UI)
bpy.context.object.dimensions[1] = 2 # (20 on UI)
bpy.context.object.dimensions[2] = 2 # (35 on UI)
I am new to blender and any suggestions would be greatly appreciated.