Page 1 of 1

Changing brush connections

Posted: 05 Nov 2009, 10:39
by KenC
How can I get/set the brush connection parameters?

For example change the current brush to size=pressure, invert?

I'm realy only interested in changing the cutbrush. tv_BrushRestore only has a connection table for "Con_Opacity" as far as I can tell and tv_getactivetool doesn't look like it returns anything I could use.

Maybe there's a specific command for changing the connection tables?

EDIT: This should have been posted in the George subforum. :oops:

Re: Changing brush connections

Posted: 05 Nov 2009, 11:52
by KenC
Figured it out, it's in the cssize, cangle etc.. result from tv_getactivetool

-10 means inverted, 5=direction etc..

Re: Changing brush connections

Posted: 05 Nov 2009, 13:09
by Svengali
Ken,

A cautionary note on adjusting the connection modes. You need to be sure that in changing the mode that you retain the second part of each parameter intact... otherwise you RESET the CURVE profile to default. Parsing the connection value into two parts and re-concatenating with the new mode will keep the custom curve setting.

Here's a function I use that manages that (calls functions from the Basic.grg include file... though you probably already have something similar.)

Code: Select all

#INCLUDE "include/basic.grg"

//------------------------------------------
//
//	SetConnection
//
//	Function:
//			Adjusts the current brushstroke C modifier...
//			Change the selected modifier mode while maintaining
//			the existing connection graph curve
//
//	use = SetConnection(CType, CModifier)
//
//	Arguments:
//		CType = Connection Type in a string (Csize, Cangle or Copacity)
//		CModifier = The brush modifier (0=none, 5=direction, 8=random, 10=pressure, etc. ) 
//
//	Return: none
//
//------------------------------------------

FUNCTION SetConnection(CType, CModifier)
	
	LOCAL CTool CValue CCurve NewCType

	tv_GetActiveTool										// store all brush settings first
	parse result CTool
	
	tv_BrushRestore CType									// retrieve Mode Connection table value and Connection Curve value
	parse result CValue

	CStart = Find(CValue, ";", 1)									// locate the semicolon dividing Mode and Connection Curve
	CCurve = RightString(CValue, (Len(CValue)-CStart) )				// grab existing Curve values

	NewCType = CType ' "' CModifier ";" CCurve						// concatenate new Mode and append existing Connection Curve Value

	tv_Cmd CTool											// must restore remaining brush settings first
	tv_BrushRestore NewCType									// insert new Connection mode into current AnimBrush
	
END
Sven

Re: Changing brush connections

Posted: 05 Nov 2009, 13:55
by KenC
Thanks Sven. Yeah I spent some time figuring out what the numbers meant, the last numbers are x/y for point in the connection curve.

I allready got some code running that uses my arrayfunctions and parses up the connection parameter string from cssize etc.. so I can just pass the parameter index I want to change and return the string with just that number changed.

tv_getactivetool
ParseArray(Result)

cType = "csize"
iPos = ArrayPosition(cType)

If iPos != 0
ParsedArray[iPos+1] = ChangeConnection(ParsedArray[iPos+1],cType,"-4")
tv_cmd StringFromArray() // Returns full Result string with the changed connection type.
END

Re: Changing brush connections

Posted: 05 Nov 2009, 14:07
by Svengali
Yup, same cat, different skin.

Re: Changing brush connections

Posted: 06 Nov 2009, 13:57
by KenC
Another gotcha is that if you use Parse to grab the csize, cangle etc.. parameter strings, is that parse returns them without being wrapped in " " and if you pass that back with tv_cmd without re-adding them that also resets the curves. I was having a great time ( :cry: ) scratching my head about that one.