def sink_drop(self,context,event): selected_point, selected_obj = utils.get_selection_point(context,event) bpy.ops.object.select_all(action='DESELECT') sel_product_bp = utils.get_bp(selected_obj,'PRODUCT') sel_assembly_bp = utils.get_assembly_bp(selected_obj) if sel_product_bp and sel_assembly_bp: product = fd_types.Assembly(sel_product_bp) if product: product_depth = math.fabs(product.obj_y.location.y) assembly_depth = math.fabs(self.assembly.obj_y.location.y) self.assembly.obj_bp.parent = product.obj_bp self.assembly.obj_bp.location.z = product.obj_z.location.z + unit.inch(1.5) self.assembly.obj_bp.location.y = -math.fabs(product_depth-assembly_depth)/2 self.assembly.obj_bp.location.x = product.obj_x.location.x/2 - self.assembly.obj_x.location.x/2 if event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.assign_boolean(selected_obj) utils.set_wireframe(self.assembly.obj_bp,False) bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') context.scene.objects.active = self.assembly.obj_bp self.assembly.obj_bp.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
def modal(self, context, event): self.set_type_value(event) wall_length_text = str(unit.meter_to_active_unit(round(self.wall.obj_x.location.x,4))) wall_length_unit = '"' if context.scene.unit_settings.system == 'IMPERIAL' else 'mm' context.area.header_text_set(text=self.header_text + ' (Current Wall Length = ' + wall_length_text + wall_length_unit + ')') context.window.cursor_set('PAINT_BRUSH') context.area.tag_redraw() selected_point, selected_obj = utils.get_selection_point(context,event,objects=[self.drawing_plane]) #Pass in Drawing Plane bpy.ops.object.select_all(action='DESELECT') self.wall.obj_y.location.y = bpy.context.scene.mv.default_wall_depth if selected_obj: if event.ctrl: self.is_disconnected = True self.wall.obj_bp.constraints.clear() self.wall.obj_bp.location.x = selected_point[0] self.wall.obj_bp.location.y = selected_point[1] self.wall.obj_bp.location.z = 0 self.wall.obj_y.location.y = 0 self.wall.obj_x.location.x = 0 self.starting_point = (self.wall.obj_bp.location.x, self.wall.obj_bp.location.y, 0) else: selected_obj.select = True self.position_wall(selected_point) if self.event_is_place_wall(event): self.place_wall() if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}: return {'PASS_THROUGH'} if self.event_is_cancel(event): return self.cancel_drop(context,event) return {'RUNNING_MODAL'}
def sink_drop(self, context, event): selected_point, selected_obj = utils.get_selection_point( context, event) bpy.ops.object.select_all(action='DESELECT') sel_product_bp = utils.get_bp(selected_obj, 'PRODUCT') sel_assembly_bp = utils.get_assembly_bp(selected_obj) if sel_product_bp and sel_assembly_bp: product = fd_types.Assembly(sel_product_bp) if product: product_depth = math.fabs(product.obj_y.location.y) assembly_depth = math.fabs(self.assembly.obj_y.location.y) self.assembly.obj_bp.parent = product.obj_bp if product.obj_z.location.z < 0: self.assembly.obj_bp.location.z = unit.inch( 1.5) #SUSPENDED CABINETS else: self.assembly.obj_bp.location.z = product.obj_z.location.z + unit.inch( 1.5) #BASE CABINETS self.assembly.obj_bp.location.y = -math.fabs( product_depth - assembly_depth) / 2 self.assembly.obj_bp.location.x = product.obj_x.location.x / 2 - self.assembly.obj_x.location.x / 2 if event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.assign_boolean(selected_obj) utils.set_wireframe(self.assembly.obj_bp, False) bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') context.scene.objects.active = self.assembly.obj_bp self.assembly.obj_bp.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
def appliance_drop(self, context, event): selected_point, selected_obj = utils.get_selection_point( context, event) bpy.ops.object.select_all(action='DESELECT') sel_assembly_bp = utils.get_assembly_bp(selected_obj) if sel_assembly_bp: selected_assembly = fd_types.Assembly(sel_assembly_bp) self.assembly.obj_bp.parent = selected_assembly.obj_bp.parent self.assembly.obj_bp.location = selected_assembly.obj_bp.location self.assembly.obj_z.location.z = selected_assembly.obj_z.location.z self.assembly.obj_y.location.y = selected_assembly.obj_y.location.y self.assembly.obj_x.location.x = selected_assembly.obj_x.location.x else: self.assembly.obj_bp.parent = None self.assembly.obj_bp.location = selected_point if event.type == 'LEFTMOUSE' and event.value == 'PRESS': if sel_assembly_bp: selected_assembly = fd_types.Assembly(sel_assembly_bp) selected_assembly.replace(self.assembly) utils.set_wireframe(self.assembly.obj_bp, False) bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') context.scene.objects.active = self.assembly.obj_bp self.assembly.obj_bp.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
def faucet_drop(self,context,event): selected_point, selected_obj = utils.get_selection_point(context,event) bpy.ops.object.select_all(action='DESELECT') if selected_obj: wall_bp = utils.get_wall_bp(selected_obj) if wall_bp: self.object.rotation_euler.z = wall_bp.rotation_euler.z self.object.location = selected_point if event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.object.draw_type = 'TEXTURED' bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') utils.set_wireframe(self.object,False) context.scene.objects.active = self.object self.object.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
def faucet_drop(self,context,event): selected_point, selected_obj = utils.get_selection_point(context,event) bpy.ops.object.select_all(action='DESELECT') if selected_obj: wall_bp = utils.get_wall_bp(selected_obj) if wall_bp: self.object.rotation_euler.z = wall_bp.rotation_euler.z self.object.location = selected_point if event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.object.draw_type = 'TEXTURED' bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') utils.set_wireframe(self.object,False) context.scene.objects.active = self.object self.object.select = True return {'FINISHED'} return {'RUNNING_MODAL'}