def modal(self, context, event):
        self.set_type_value(event)
        wall_length_text = str(fd.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 = fd.get_selection_point(context,event,objects=[self.drawing_plane]) #Pass in Drawing Plane
        bpy.ops.object.select_all(action='DESELECT')
        if selected_obj:
            if event.ctrl:
                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.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'}
Esempio n. 2
0
    def modal(self, context, event):
        self.header_text = "Place Group: (Left Click = Place Group) (Hold Shift = Place Multiple) (Esc = Cancel)"
        context.area.tag_redraw()
        selected_point, selected_obj = fd.get_selection_point(context,event)
        obj_wall_bp = fd.get_wall_bp(selected_obj)
        for obj_bp in self.obj_bps:
            if obj_wall_bp:
                obj_bp.location.x = selected_point[0]
                obj_bp.location.y = selected_point[1]
                obj_bp.location.z = self.grp_z_loc
                obj_bp.rotation_euler = obj_wall_bp.rotation_euler
            else:
                obj_bp.location = selected_point

        if event.type == 'LEFTMOUSE' and event.value == 'PRESS':
            self.place_group(context,selected_obj)
            if event.shift:
                self.get_group(context)
            else:
                return self.cancel_drop(context,event)

        if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
            return {'PASS_THROUGH'}
         
        if event.type == 'ESC':
            obj_list = []
            for obj in self.grp.objects:
                obj_list.append(obj)
            fd.delete_obj_list(obj_list)
            return self.cancel_drop(context,event)
         
        return {'RUNNING_MODAL'}
Esempio n. 3
0
 def modal(self, context, event):
     self.header_text = "Place Object: (Left Click = Place Object) (Hold Shift = Place Multiple) (Esc = Cancel)"
     context.area.tag_redraw()
     selected_point, selected_obj = fd.get_selection_point(context,event)
     self.obj.location = selected_point
     rotation = object_utils.get_z_rotation(selected_obj, 0)
     self.obj.rotation_euler.z = rotation
     if event.type == 'LEFTMOUSE' and event.value == 'PRESS':
         self.obj.draw_type = 'TEXTURED'
         item = context.scene.objectlib.scene_objects.add()
         item.name = self.obj.name
         if event.shift:
             self.get_object(context)
         else:
             return self.cancel_drop(context,event)
     
     if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
         return {'PASS_THROUGH'}
     
     if event.type == 'ESC':
         obj_list = []
         obj_list.append(self.obj)
         fd.delete_obj_list(obj_list)
         return self.cancel_drop(context,event)
     
     return {'RUNNING_MODAL'}
Esempio n. 4
0
    def modal(self, context, event):
        self.header_text = "Place Material: (Left Click = Assign Material) (Hold Shift = Assign Multiple) (Esc = Cancel)"
        context.window.cursor_set('PAINT_BRUSH')
        context.area.tag_redraw()
        selected_point, selected_obj = fd.get_selection_point(context, event)
        bpy.ops.object.select_all(action='DESELECT')
        if selected_obj:
            selected_obj.select = True

        if event.type == 'LEFTMOUSE' and event.value == 'PRESS':
            if selected_obj and selected_obj.type == 'MESH':

                if len(selected_obj.data.uv_textures) == 0:
                    bpy.ops.fd_object.unwrap_mesh(
                        object_name=selected_obj.name)
                if len(selected_obj.material_slots) > 1:
                    bpy.ops.materiallib.assign_material(
                        'INVOKE_DEFAULT',
                        material_name=self.material.name,
                        object_name=selected_obj.name)
                    return self.cancel_drop(context, event)
                else:
                    if len(selected_obj.material_slots) == 0:
                        bpy.ops.fd_object.add_material_slot(
                            object_name=selected_obj.name)

                    for i, mat in enumerate(selected_obj.material_slots):
                        mat.material = self.material

                    if self.material.name not in context.scene.materiallib.scene_materials:
                        material = context.scene.materiallib.scene_materials.add(
                        )
                        material.name = mat.name

                if event.shift:
                    self.get_material(context)
                    context.window.cursor_set('PAINT_BRUSH')
                else:
                    return self.cancel_drop(context, event)

        if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
            return {'PASS_THROUGH'}

        if event.type == 'ESC':
            return self.cancel_drop(context, event)

        return {'RUNNING_MODAL'}
Esempio n. 5
0
 def modal(self, context, event):
     self.header_text = "Place Material: (Left Click = Assign Material) (Hold Shift = Assign Multiple) (Esc = Cancel)"
     context.window.cursor_set('PAINT_BRUSH')
     context.area.tag_redraw()
     selected_point, selected_obj = fd.get_selection_point(context,event)
     bpy.ops.object.select_all(action='DESELECT')
     if selected_obj:
         selected_obj.select = True
         
     if event.type == 'LEFTMOUSE' and event.value == 'PRESS':
         if selected_obj and selected_obj.type == 'MESH':
             
             if len(selected_obj.data.uv_textures) == 0:
                 bpy.ops.fd_object.unwrap_mesh(object_name=selected_obj.name)
             if len(selected_obj.material_slots) > 1:
                 bpy.ops.materiallib.assign_material('INVOKE_DEFAULT',material_name = self.material.name, object_name = selected_obj.name)
                 return self.cancel_drop(context,event)
             else:
                 if len(selected_obj.material_slots) == 0:
                     bpy.ops.fd_object.add_material_slot(object_name=selected_obj.name)
                 
                 for i, mat in enumerate(selected_obj.material_slots):
                     mat.material = self.material
                     
                 if self.material.name not in context.scene.materiallib.scene_materials:
                     material = context.scene.materiallib.scene_materials.add()
                     material.name = mat.name
             
             if event.shift:
                 self.get_material(context)
                 context.window.cursor_set('PAINT_BRUSH')
             else:
                 return self.cancel_drop(context,event)
             
     if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
         return {'PASS_THROUGH'}
         
     if event.type == 'ESC':
         return self.cancel_drop(context,event)
         
     return {'RUNNING_MODAL'}