Skip to content

Commit

Permalink
set active camera after import
Browse files Browse the repository at this point in the history
  • Loading branch information
stuffmatic committed Nov 12, 2018
1 parent 88ffa82 commit 5f6a61f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
.DS_Store
.DS_Store
dist
11 changes: 9 additions & 2 deletions src/__init__.py → fspy-blender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Import fSpy project",
"author": "Per Gantelius",
"description": "Imports the background image and camera parameters from an fSpy project.",
"version": (1, 0, 0),
"version": (0, 1, 0),
"blender": (2, 79, 0),
"location": "File > Import > fSpy",
"url": "TODO",
Expand All @@ -25,6 +25,11 @@
import mathutils
import tempfile

def show_popup(title, message, type = 'ERROR'):
def draw_popup(self, context):
self.layout.label(message)
bpy.context.window_manager.popup_menu(draw_popup, title, type)

def import_fpsy_project(context, filepath, use_some_setting):
project = fspy.Project(filepath)

Expand All @@ -40,7 +45,6 @@ def import_fpsy_project(context, filepath, use_some_setting):

camera.matrix_world = mathutils.Matrix(camera_parameters.camera_transfrom)


# Set render resolution
render_settings = bpy.context.scene.render
render_settings.resolution_x = camera_parameters.image_width
Expand All @@ -62,6 +66,8 @@ def import_fpsy_project(context, filepath, use_some_setting):

rv3d = space_data.region_3d # Reference 3D view region
space_data.show_background_images = True # Show BG images
space_data.camera = camera
space_data.region_3d.view_perspective = 'CAMERA'

bg = space_data.background_images.new()

Expand All @@ -80,6 +86,7 @@ def import_fpsy_project(context, filepath, use_some_setting):

break

show_popup("Done!", message = "", type = 'INFO')
return {'FINISHED'}


Expand Down
File renamed without changes.

0 comments on commit 5f6a61f

Please sign in to comment.