How can I override SpaceView3D.lens 250 mm limit?

How can I override SpaceView3D.lens 250 mm limit?

Why do you suppose the developers have imposed that limit?

I read http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface
but It seems like I should be able to poke the value in through the python console rather than replacing the view panel.

Background:

In order to match a mesh in the 3D perspective view port to a photograph taken with a 400 mm lens I change the opacity of the blender window and line it up with the photo in another window behind it. I know I can accomplish this with the camera view and easily change to the 400mm and beyond but I find it a little cumbersome.

mmmmm… Open the console and run this:

import bpy

for area in bpy.data.screens[‘Default’].areas[:]:
if area.type == “VIEW_3D”:
print(area.spaces.active.lens)
area.spaces.active.lens=75

The script check all areas. If this is “VIEW_3D” type, the script set the value to 75!!

I hope you help!

whwat the difference between camera lens and spaceview lens ?

thanks

@oscuart Thanks! I’ll try it immediately!

@RickyBlender
THe SpaceView3D.lens in the “view” panel on the right side of the 3D window is limited to 250mm while the camera setting is I suppose --for all practical purposes-- infinitely variable. Plus the camera setting can be described in Field Of View degrees as well as mm focal length.

@oscuart,
That script did work as advertised to change the lens. However it could not overcome the 250mm limit. Somehow, I guess I have to change this:
<excerpt from the source code rna_space.c>

prop= RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_ui_text(prop, "Lens", "Lens angle (mm) in perspective view");
RNA_def_property_range(prop, 1.0f, 250.0f);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);

Any ideas?:confused:

Hi

Change the 250 and build

If you look at the property in the console


&gt;&gt;&gt; p = C.screen.areas[4].spaces.active.bl_rna.properties.get('lens')
&gt;&gt;&gt; p.
      array_length
      as_pointer(
      bl_rna
      callback_add(
      callback_remove(
      default
      default_array
      description
      driver_add(
      driver_remove(
      get(
      hard_max
      hard_min
      id_data
      identifier
      is_animatable
      is_enum_flag
      is_hidden
      is_never_none
      is_output
      is_property_hidden(
      is_property_set(
      is_readonly
      is_registered
      is_registered_optional
      is_required
      is_runtime
      is_skip_save
      items(
      keyframe_delete(
      keyframe_insert(
      keys(
      name
      path_from_id(
      path_resolve(
      precision
      rna_type
      soft_max
      soft_min
      srna
      step
      subtype
      translation_context
      type
      type_recast(
      unit
      values(

You’ll see that it’s a floatproperty with soft_min = hard_min = 1.0 and the maxes 250. The range you have in the code.

in which panel do you see this SpaceView3D.lens 250 mm limit?

i mean is it the render or scene sub panel ?

thanks

In the 3d editor properties View Panel… lens, lock to object etc.

Thanks batFINGER,
I see:

>>> myprop.soft_max = 400
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
AttributeError: bpy_struct: attribute “soft_max” from “FloatProperty” is read-only

that the property is read-only. So that’s the final word is it. I thank you all for your input.

<edit>
I managed to build it with the limit set to 800:


prop= RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_ui_text(prop, "Lens", "Lens angle (mm) in perspective view");
RNA_def_property_range(prop, 1.0f, 800.0f);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);

</edit>

@RickyBlender
In the 3D viewport the small “+” sign on the right. Click it to expose some panels and you should see one captioned “View”. Expand that one and you should find the lens property I’m fretting over.

Thanks again