Changing brush connections

Please use this part to report bugs & errors, ask questions & "How to..."
Post Reply
User avatar
KenC
Posts: 174
Joined: 14 Aug 2009, 09:28
Location: Denmark

Changing brush connections

Post by KenC » 05 Nov 2009, 10:39

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:
There's no place like ~/

User avatar
KenC
Posts: 174
Joined: 14 Aug 2009, 09:28
Location: Denmark

Re: Changing brush connections

Post by KenC » 05 Nov 2009, 11:52

Figured it out, it's in the cssize, cangle etc.. result from tv_getactivetool

-10 means inverted, 5=direction etc..
There's no place like ~/

Svengali
Posts: 1285
Joined: 28 Dec 2006, 10:08
Contact:

Re: Changing brush connections

Post by Svengali » 05 Nov 2009, 13:09

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
Last edited by Svengali on 06 Nov 2009, 18:37, edited 1 time in total.

User avatar
KenC
Posts: 174
Joined: 14 Aug 2009, 09:28
Location: Denmark

Re: Changing brush connections

Post by KenC » 05 Nov 2009, 13:55

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
There's no place like ~/

Svengali
Posts: 1285
Joined: 28 Dec 2006, 10:08
Contact:

Re: Changing brush connections

Post by Svengali » 05 Nov 2009, 14:07

Yup, same cat, different skin.

User avatar
KenC
Posts: 174
Joined: 14 Aug 2009, 09:28
Location: Denmark

Re: Changing brush connections

Post by KenC » 06 Nov 2009, 13:57

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.
There's no place like ~/

Post Reply