Post #4694: I write the code like this, it’s normal to call with PME, but it’s a problem to
📋 Metadata
- Author: lee_blues
- Date: 2023-04-20 14:00:44
- Type:
question - Quality Score: 5/10
- Reply to: post_04693
- Replies (1): post_04695
🏷️ Tags
macro scripting intermediate unsolved
⚙️ Related PME Features
- Macro Editor
- Python Scripting
💬 Content
I write the code like this, it’s normal to call with PME, but it’s a problem to call after make as an addon, Although this may not be related to PME,but can you help me to see how to modify the line of code above,My code is just this one line away from being perfect 
import bpy
C = bpy.context
bpy.context.space_data.camera = bpy.data.objects["C_0V0"]
#Select Active Cam
for area in C.screen.areas:
if area.type == 'VIEW_3D':
A=C.area.spaces.active.camera
bpy.context.scene.camera = bpy.data.objects[A.name]
bpy.context.space_data.shading.color_type = 'OBJECT'
bpy.context.space_data.region_3d.view_perspective = 'CAMERA'
bpy.data.objects[A.name].lock_scale[0] = True
bpy.data.objects[A.name].lock_scale[1] = True
bpy.data.objects[A.name].lock_scale[2] = True
bpy.data.objects[A.name].lock_location[0] = True
bpy.data.objects[A.name].lock_location[1] = True
bpy.data.objects[A.name].lock_location[2] = True
bpy.data.objects[A.name].lock_rotation[0] = True
bpy.data.objects[A.name].lock_rotation[1] = True
bpy.data.objects[A.name].lock_rotation[2] = True
bpy.data.objects[A.name].scale[0] = 1
bpy.data.objects[A.name].scale[1] = 1
bpy.data.objects[A.name].scale[2] = 1
bpy.data.cameras[A.name].display_size = 0.05
bpy.data.cameras[A.name].background_images[0].alpha =0
bpy.data.cameras[A.name].dof.use_dof = False
bpy.data.cameras[A.name].clip_start = 25
bpy.data.cameras[A.name].clip_end = 100000
bpy.data.cameras[A.name].background_images[0].scale = 1
bpy.data.cameras[A.name].background_images[1].scale = 1
bpy.data.cameras[A.name].background_images[2].scale = 1
bpy.ops.view3d.view_center_camera()
bpy.ops.image.reload()
if bpy.context.object.mode=='OBJECT':
bpy.ops.object.select_all(action='DESELECT')
objectToSelect = bpy.data.objects[A.name]
objectToSelect.select_set(True)
bpy.context.view_layer.objects.active = objectToSelect