# 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 think it is related to context - try putting your panel into the 3dview - bl_space_type = "VIEW_3D" and bl_region_type = "UI". Not sure of a workaround to change the active object from a panel in the properties window. – sambler Oct 29 '14 at 11:41
• @sambler that worked, I had to change my code a little, but it is getting the context right now. I don't mind just moving the whole panel out to VIEW_3D in some ways it is better, as the modifier panel is now less cluttered. Do you mind posting that back as an answer so I can accept it? Thanks – BlendingJake Oct 29 '14 at 14:10

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