示例#1
0
    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 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'}
示例#3
0
    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 invoke(self, context, event):
     bp = bpy.data.objects[self.object_name]
     self.assembly = fd_types.Assembly(bp)
     utils.set_wireframe(self.assembly.obj_bp,True)
     context.window.cursor_set('PAINT_BRUSH')
     context.scene.update() # THE SCENE MUST BE UPDATED FOR RAY CAST TO WORK
     context.window_manager.modal_handler_add(self)
     return {'RUNNING_MODAL'}
 def invoke(self, context, event):
     bp = bpy.data.objects[self.object_name]
     self.assembly = fd_types.Assembly(bp)
     utils.set_wireframe(self.assembly.obj_bp,True)
     context.window.cursor_set('PAINT_BRUSH')
     context.scene.update() # THE SCENE MUST BE UPDATED FOR RAY CAST TO WORK
     context.window_manager.modal_handler_add(self)
     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'}