4
$\begingroup$

Is there a way to import Sketchup scenes into Blender as cameras?

I can get the geometry into Blender without any problems; my issue is that I'd also like to bring along the scene viewpoint as a camera.

The data obtained from SketchUP API is like this:

mod = Sketchup.active_model
vue = mod.active_view
cam = vue.camera

cam.eye
> Point3d(240.719, -236.069, 102.276)

cam.target
> Point3d(-285.372, 553.004, -82.0446)

cam.fov
> 35.0

What is a convenient way to convert this into a new camera?

$\endgroup$
  • $\begingroup$ Related. Import SketchUp “.skp” files $\endgroup$ – iKlsR Sep 9 '13 at 0:54
  • $\begingroup$ seems like more of a question about how to get the camera/viewport data out of SketchUp in the first place, the ruby API is quite nice. $\endgroup$ – zeffii Sep 9 '13 at 12:54
  • $\begingroup$ @zeffii I actually know how to do that (see here; What I'd like to know is if there is a way to do this without manually getting the coordinates and entering them somehow in Blender. $\endgroup$ – jkjenner Sep 9 '13 at 16:57
  • $\begingroup$ You would want the Up vector or Roll from sketchup too, otherwise you can't create the exact same camera. $\endgroup$ – ideasman42 Sep 11 '13 at 0:25
1
$\begingroup$

If that's all sketchup gives, then it's a little awkward -- but I think still doable. Maybe something like this. You will have to 'tame' the dimensions yourself.

import bpy

# Data from Sketchup.
cam = {
    "eye": (240.719, -236.069, 102.276),
    "target": (-285.372, 553.004, -82.0446),
    "fov": 35.0,
}

# Create empty to target.
bpy.ops.object.empty_add(location=cam["target"])
target = bpy.context.object

# Create camera.
bpy.ops.object.camera_add(location=cam["eye"])
bpy.context.object.data.lens = cam["fov"]

# Configure camera to track the empty.
constraint = bpy.context.object.constraints.new("TRACK_TO")
constraint.target = target
constraint.track_axis = "TRACK_NEGATIVE_Z"
constraint.up_axis = "UP_Y"
$\endgroup$
  • $\begingroup$ Then you can apply the constraint (Apply Visual Transforms) and delete both it and the empty to avoid clutter. $\endgroup$ – wchargin Oct 22 '13 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.