Notifications
Clear all

[Closed] paintInterface problem

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

testScript:


(
	local tPlane = $Plane001
	
	
	fn startStroke = 
	(
		print "Handle start stroke here"
	)

	fn paintStroke = 
	(
		try(
		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:%
" worldHit pressure
			--thePainterInterface.clearStroke()
		)
		)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
		
		thePainterInterface.startPaintSession()
	)
)

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

7 Replies

quick question: in x64 version !?

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

 PEN

Does it still crash without the print and format statements?

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 🙁

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 )?

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:%
" (if not [b]bit.isFinite[/b] pressure then pressure else "infinite")

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

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

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 )

@Insanto

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