Tablet support: PyTablet v1.0a (Win)

Hi all!

I wrote a small plugin for Blender to give python access to graphic tablets: PyTablet.
It’s meant to be integrated into “sculpt_mesh” - a modelling tool developed by Tom Musgrove and myself. PyTablet comes as dll-file to be copied into your blender directory (Windows only - sorry)
You can get a preliminary version here.

Caution: functions are not documented yet and i’ll add more functions soon - so names might change. But for a quick impression try the bundled testscript…

Comments please!

Michael Schardt

great! i test it with my Wacom Graphire 1 (USB) and it works verry good, when i can test it with sculpt_mesh script?

Cool - Thanks for the info!

I’ll keep a list of which tablets seem to work.

So we have:

  • Wacom Intuos 1 A4 Oversize (USB)
  • Wacom Graphire 1 (USB)

:smiley:

Michael

For sculpt_mesh just look down a few posts in this forum (Tom posted as LetterRip)
There’s no version with tablet support yet. As i said - i’ll have to do some work on this module first. Also the sculpt_mesh script is still in an early stage of development. There are a lot of things to be straightened out and bugs to fix. So far we’ve concentrated mainly on getting everything fast enough to show that it’s working - in principle at least. :wink:

Michael

wow this sounds cool, it works also for me with wacom graphire

Yeah ! this script rocks !
sculpt mesh is really useful, but with your script it will be a lot more precise !
thanks a lot :slight_smile:

I know some users already use the script with a tablet without the plugin, I’m not sure how they are using it though…

LetterRip

what are the features for this script ?

wow this is so cool, i thought to myself. then went to try it out and D’oh… my tablet is in my brothers room, and hes asleep :expressionless:

well tommorow ill try it then
i got a graphire 3 so it should work fine

I know some users already use the script with a tablet without the plugin, I’m not sure how they are using it though…

LetterRip

Sure you can use your tablet without my plugin inside Blender - it works just like with an ordinary mouse then.
But if you do so you won’t have access to the extended functionality of the tablet and it’s input devices like pens. For example pens usually have a pressure sensitive tip and can report their orientation relative to the tablet’s surface.
With my plugin you get access to these extended features. The pressure value could be used to set the “selection size” in sculpt_mesh. The higher the pressure the bigger the selection size - very much like in real painting. The orientation might be used to set the displacement direction…
Possibilities are (almost) endless :smiley:

what are the features for this script ?

Well, not too many - the testscript is just for displaying some numbers.
The dll is (more or less) just a test to see whether the communication between the tablet’s driver and my dll works correctly.
So far we have the following functions:

Connect(): establish connection between dll and tablet driver
return: int (sucess/failure)

Disconnect(): close connection
return: int (success/failure)

GetNormalPressure(): pressure value perpendicular to tablet surface
return: int

GetTangentPressure(): pressure value in tablet surface plane or wheel status of airbrush (Wacom Intuos)
return: int

GetCoords(): absolute coordinates of input device relative to tablet
return: [int x, int y, int z]

GetButtons(): button status as 'or’ed bitfield
return: int

GetCursor(): active tip of the input device (some pens have a pressure sensitive eraser - you can just turn your pen upside down…)
return: int

GetOrientation(): orientation of the input device relative to the tablet surface
return: [int azimuth, int altitude, int twist]

GetRotation(): rotation of the input device relative to the tablet surface
return: [int pitch, int roll, int yaw]

GetStatus(): status of the input device as 'or’ed bitfield
return: int (16 means device is upside down)

GetVersion(): version info of dll
return: string

That’s it - your tablet and input device might not support all of these functions. If so 0 is returned in most cases. All values returned are raw data queried from the tablet driver - their range depends on the type and size of the tablet you have. I’m currently transforming these values to a standardized range so no matter how big your tablet is and what resolution it has you’ll always get the same return value from these functions. Say lower left corner has coordinates [0,0 (,0)] and upper right becomes [1,1 (,1)].

Oooh - long post

Michael

Hi levon!

well tommorow ill try it then
i got a graphire 3 so it should work fine

Perfect - i could add it to my list if you tell me whether it works or not (… how’s your tablet connected and what’s your driver version?)
Any info is appreciated as i can’t test all combinations myself (of course).

Michael

This look like really useful stuff. Is it only possible to use the PyTablet module through Blender or could it be used in non-Blender Python projects?

Is it only possible to use the PyTablet module through Blender or could it be used in non-Blender Python projects?

Hm - haven’t tried that. Actually there’s nothing “Blender specific” inside the dll.

In brief: The dll is loaded into the application by python’s “import” command. With the “Connect()” function the dll tries to retrieve a handle to the main window of the application by examining the windows associated with the current process. If found, a tablet context is associated to the main window handle and the tablet driver starts sending messages to the app’s “mainwndproc” (the windows programmers out there know what i’m talking about…). These messages are catched by the dll using a message hook and made accessable through the dll’s python interface.

So - i guess it’s worth a try… but don’t blame me if your app crashes :wink:

If you try please let me know if it works,

Michael

yep it all works here.

graphire 3 4x5 USB
latest drivers (not sure what number, but the lattest on teh website)

one thing i have found is that the third button reports that is button 4, and the eraser and tip are counted as the same button.

one thing i have found is that the third button reports that is button 4, …

That’s fine - the GetButtons() returns an 'or’ed bitfield
So we have:

button no. -> returned value
1 -> 1 = 00001
2 -> 2 = 00010
3 -> 4 = 00100
4 -> 8 = 01000
5 -> 16 = 10000

if you have button 1 and 3 pressed simultaniously you’d get 5 = 00101 …

… and the eraser and tip are counted as the same button.

That’s ok also. You can check whether the pen is upside down by looking at GetStatus() (16 is upside down) or GetOrientation(). The Altitude (second number) will be negative.

Michael

| @ Windows

Man I want to try this out…but alas I have OS X. It can’t be that difficult to make your plugin work for the mac. Please…I’m begging! :smiley: That’d make the sculpting script so much more powerful!

bydesign

Hm - There’s one problem with porting it:

I’m not aware of any platform independent API that gives access to the driver data of tablets. For Windows there’s “Wintab” - it’s intended to be an open standard and many tablet manufactures support it with their drivers. So for Windows we have a (somewhat) standardized interface to work with - no matter which tablet the user might have.
I haven’t found anything comparable for other platforms - and i definitely cannot write a specialized module for each tablet model and each OS seperately…

If anyone knows more than i do - please tell me

Michael

antont and i were talking on IRC about getting tablet input, he is mac and linux based and he was telling me about the HID (human interface device) standard, and something about glut has support for it. while thats not a python input, it would let you use a tablet natively inside blender.

also, ive screwed around with getting a tablet to do stuff in the game engine, and one problem ive found is that when you click, it doesnt detect that you have clicked.

Thanks for the info - i’ll take a look…

Michael