View Full Version : paintInterface problem

12 December 2010, 12:01 PM
hi, ive been trying to get the pressure when painting something in the viewport but for some odd reason i cant figure out it always crashes max (2010 and 11)

scene: empty scene with only one plane called Plane001


local tPlane = $Plane001

fn startStroke =
print "Handle start stroke here"

fn paintStroke =
local localHit = Point3 0 0 0
local localNormal = Point3 0 0 0
local worldHit = Point3 0 0 0
local worldNormal = Point3 0 0 0
local str = 0.0f
local radius = 0.0f

local shift = true
local ctrl = true
local alt = true
local pressure = 0.0

thePainterInterface.getHitPointData &localHit &localNormal &worldHit &worldNormal &radius &str 0

thePainterInterface.getHitPressureData &shift &ctrl &alt &pressure 0

local hit = thePainterInterface.getIsHit 0

if hit do
print "Handle paint stroke here"
thePainterInterface.getHitPointData &localHit &localNormal &worldHit &worldNormal &radius &str 0

format "pos:% zDepth:%\n" worldHit pressure
)catch(print (getcurrentException()) )

fn endStroke =
print "Handle end stroke here"

fn cancelStroke =
print "Handle cancel stroke here"

fn systemEnd =
print "Handle system end here"

if isValidNode tPlane do
thePainterInterface.ScriptFunctions startStroke paintStroke endStroke cancelStroke systemEnd

thePainterInterface.initializeNodes 0 #(tPlane)

-- thePainterInterface.pressureEnable = true
-- thePainterInterface.pressureAffects = 2


anyone got an idea as to why this is crashing and/or how to make it work? :shrug:

12 December 2010, 11:12 AM
quick question: in x64 version !?

i noticed that scripts in x64 crash where in x86 they show the error :)

12 December 2010, 12:45 PM
Does it still crash without the print and format statements?

12 December 2010, 03:27 PM
yeah 64 bit, so whats the error msg say?

yeah ; calc (something), freeze, crash
and the print stuff is taken directly as the whole test code is from the helpFiles so it should work.. theoretically :sad:

paul, did you btw find another way to get the pressure data of a pen tablet? might there be a way in c (or whatever it is you and pete are always messing around with :D )?

12 December 2010, 04:10 PM
your code crashes on format function for pressure. If a device doesn't support Pressure Sensitivity the painter interface might return infinite data for pressure.

thePainterInterface.getHitPointData &localHit &localNormal &worldHit &worldNormal
format "pressure:%\n" (if not bit.isFinite pressure then pressure else "infinite")

try to set thePainterInterface.pressureEnable to OFF to solve the problem.

12 December 2010, 05:05 PM
wow weird, might be when your hovering with the pen cuz i got an intuos3 and its got pressure support
and disableing the pressure in the paintInterface is kinda the wrong direction for me as thats the only reason i use it ;)
if i knew of another way to get the pressure data (when supplied) id use that.

infinite pressure, thx, wouldnt have thought that :D

12 December 2010, 10:25 PM
quick question: in x64 version !?

i noticed that scripts in x64 crash where in x86 they show the error :)

i was talking in general... scripts crash in x64 and in x86 it shows the error :)
(since i wasn't home to test it... still not home until next year :) )

04 April 2011, 08:02 AM

Hi, I have just tried your original script and it works fine for me - prints position and pressure in the listener. No errors.

I have:
- intuos4 (driver 6.1.6-7)
- max 2011 x64

CGTalk Moderation
04 April 2011, 08:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.