Setting active object through python issues I am working on an addon that creates siding, it also allows you to cut out rectangles in it for windows and doors. It uses Boolean modifiers for this. When you select bricks it cuts the brick then it cuts the mortar then it joins the two, but currently I am having trouble getting it to cut the mortar properly. 

Run the code from the Text Editor, go to Add Mesh > JARCH Vis > Add Siding, then once the object is added go to Properties > Modifiers > JARCH Vis, then change the Material to bricks, click Cutouts and enter something like 5, 2, 2, 2. 

You will notice how it does cut through the brick, but not through the mortar. The code for all this starts at line 1,524. It is like

bpy.context.scene.objects.active = mortar


isn't switching right, but if you check active object it is correct. So I don't know why the modifier is being applied to o but not mortar. Here is the python file
I have seen this issue when using a panel in the properties window to alter the active object. It would be related to the context.

The easy fix is to place your panel in the 3dview. This is just a matter of changing the panel's bl_space_type to VIEW_3D and bl_region_type to UI

It is possible that you can override the context to get it working, this answer explains that and links to more information.