Scripting user input

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Technolithic
Posts: 9
Joined: Mon Mar 12, 2012 9:10 pm

Scripting user input

Postby Technolithic » Mon Nov 05, 2012 3:36 am

In the Blender 3D-View user interface when extruding, scaling, translating, etc., there's a handy option to use precise values entered from the keyboard rather than eyeballing things with the mouse. When entering a value via the keyboard, the value(s) appear in the lower left of the window. Is there a tutorial, scripting reference, or something to check out that would help implement this same style of user input functionality for Blender 2.6x?

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Mon Nov 05, 2012 9:42 am

you can still enter values while being in scale/rot/... mode, just start typing numbers, use tab to walk through multiple fields (x,y,z), backspace to delete input, x/y/z key to limit transform to that axis.
I'm sitting, waiting, wishing, building Blender in superstition...

Technolithic
Posts: 9
Joined: Mon Mar 12, 2012 9:10 pm

Postby Technolithic » Mon Nov 05, 2012 2:26 pm

Thanks for your reply. Perhaps my question was a bit unclear. I'm looking to implement what appears to be a standard feature with selected Blender tools that allows for precision input from the keyboard while using various tools like extruding, scaling, translating, rotating, etc. I'm attempting to create a modal operator that responds to keyboard input in the same way as the tools I've mentioned, is there any information available to describe how this can be done in Python scripting within Blender 2.6x?

Technolithic
Posts: 9
Joined: Mon Mar 12, 2012 9:10 pm

Postby Technolithic » Mon Nov 05, 2012 3:13 pm

Ok, I found this http://stackoverflow.com/questions/6006669/in-python-how-could-i-get-a-user-input-while-simultaneously-running-the-script that asks what I'm trying to accomplish; however, the follow-up links provide no Blender-specific examples and there's no help with the visual user interface of how the built-in tools like extrude, translate, scale, etc., work with the UI to display the user input in the lower left of the currently active window.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Nov 06, 2012 7:17 pm

Blender's standard mesh manipulation tools are written in C, and the live/modal operators replace the 3d view's header by information about the current transformation. You can type values and see them there, but this input method is exclusively available for C operators. Python operators can't make use of it, you can however override the header with text. With some scripting, you could fake the input method, but it will react a lot slower than you know from default C operators.

There is such a remake, but not fully working as the original:

http://blenderartists.org/forum/showthr ... t-operator
I'm sitting, waiting, wishing, building Blender in superstition...

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Nov 06, 2012 7:20 pm

btw, there are other ways to let user input precise values:

if you write a python operator, with bl_options = {'REGISTER', 'UNDO'} and give it properties, users can run the operator and type values into the redo panel (tool_props).

Furthermore, you can create custom properties and display them somewhere in a panel, and add an update function to that prop so you can perform something when user changes value.
I'm sitting, waiting, wishing, building Blender in superstition...

Technolithic
Posts: 9
Joined: Mon Mar 12, 2012 9:10 pm

Postby Technolithic » Wed Nov 07, 2012 6:11 am

Thanks for your most excellent reply! Hmm... This feature I'm thinking of adding would be used repetitively hundreds of times just for the current model I'm hoping to create, so having a direct keyboard input would probably be much more practical. It sounds like keyboard input through Python would be a bit hackish, but if it performed quick enough there would be no problem.. It is worth experimenting with. In my searching for a solution for this feature, I found a video someone made with a question about the existence of such the same feature I hope to develop while there were no comments satisfying for an answer. Perhaps I should start a new thread to discuss this feature to determine where to go from here.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Thu Nov 08, 2012 12:07 am

yeah, go ahead and start a new topic with your feature/tool in mind!
I'm sitting, waiting, wishing, building Blender in superstition...

Technolithic
Posts: 9
Joined: Mon Mar 12, 2012 9:10 pm

Postby Technolithic » Sat Nov 10, 2012 8:42 pm

Hi, CoDEmanX. I've started a new thread for the feature I'm looking to develop and here's the URL if you'd like to follow it:
http://www.blender.org/forum/viewtopic. ... 416#100416


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests