request for a sample python script for Blender

Hi everyone, im new to Blender as well as python, we used to design from other softwares but now we will try Blender.

We are currently designing a map and we would like to request a short script that will zoom the view. either i will try to put this on mouse or code it on zoom buttons in the GUI.

Please share us your extra knowledge as we are not familiar with python yet. we are currently reading manuals,

Its just that we would like to test something before we proceed.

thanks and more power to blender and python

btw. here is 1 of our artworks page.

Hi. I would like to help, but I am not sure what you are asking for. Do you want this to work in normal blender, or in the game engine.

In normal blender you can put menus on the GUI, here is a good example

Or you can capture mouse and keyboard input events and perform functions. here’s an example:

In game engine mode you can do most of this (zoom on pictures etc) without programming.

in a normal mode Blender script, to change the lens value (which could be zoom) you could type:

import Blender

oh thanks, so we do not need to program it already cause there are built in already? i think were using normal blender (not sure game engine mode or normal - idea pls).

so there are functions already in Blender that will allow a certain button to activate closer look?

To change the camera zoom,
select the camera - press 0 on numeric keypad,
make the camera active (right click on the solid line border - the edges of the camera - in the 3d view)
press F9 to go to edit mode buttons
change the lens value with left/right buttons or type new value in.
or with the camera selected you could move the camera type: “g” “z” “z” (grab on local z axis, then move mouse)
i assume youknow how to zoom in normally - with middle scroll wheel, or <control> middle button, or <control> <alt> left button.
I’m sure there are more ways.

If your looking for some Game Engine specific advice, then ask in the Game Engine forum.

its like this, lets say we are finished with the design, detailed as possible, and the design is a MAP.

we want to put a button where in when that button is click it will trigger and zoom in and vice versa with the other button. or by double clicking the mouse it will zoom in for closer look of the overview. so its like interactive.

help pls, do we need to program it? A button when clicked will trigger the zoom , if yes can i have a python code for it pls.

the design is finished, we just want a button that will enable thecloser look and the like

i guess my title is not catchy :frowning:

Can you please give me the basic idea on how we can make our finish artwork react from the viewers.

Let’s say, we have finish to design the MAP of a house, now we want to make it interractive in the sense that the viewers can zoom in and out to certain areas, welll maybe they can use the mouse or we can make a + button that they can click. Now the question is how to do it, do we need to program it using python scripts or blender itself has such functions?

Please help. Thank you in advance.

For an interactive application, you’ll need to use the game engine, if you want to use Blender as the app-engine, or else you’ll have to export everything to a third party 3d engine like Ogre.

The Blender game engine has built in functions for navigating the camera through a scene / switching cameras / mouse control.

Depending on the complexity you desire, you could start with just simple keyboard controls ala Quake to “walk through” the scene.

If you’re going to use the Game engine, it also requires a different process for texturing than the “normal” / render side of Blender.

You might want to take a look at :

Also look at the “sticky” threads in the game engine forum for tutorials / demos.

Look for “walkthrough” information, or start a thread stating that’s what you’re trying to create. Also “FPS” (First person shooter games … are actually similar to an architectural walkthrough … minus the shooting guns and villains and monsters :slight_smile: )


hi mike thanks.

so its all included in the game engine mode? no need to code in python to set the mouse when clicked will zoom the view on the map?

also its similar to game but i think the term is too broad for our application we just want a navigational map with functions like the zoom in though mouse click or pressing the buttons.

The game engine has tools and various functions/buttons for general object navigation, but there is no specific “click mouse / zoom view function”. There are probably a few ways of achieving that.

  • You can set up multiple cameras, then switch between them using the Mouse Sensor (click / MouseOver

  • you can move cameras either from keyboard commands or mouse control (simulating a zoom … Not sure if you can actually change the lens settings of the camera in the game engine).

I haven’t used the game engine all that much, so can’t really answer your questions on how to specifically do what you’re trying to do, that’s why I recommened the game forums and the resources there


thanks. gonna try engine mode then.