Set paramStr in Maxscript

Set paramStr in Maxscript

bertv
Enthusiast Enthusiast
609 Views
4 Replies
Message 1 of 5

Set paramStr in Maxscript

bertv
Enthusiast
Enthusiast

Hi,

 

I have a problem with formatting a paramStr:

The code below works perfect.

But I want to set the tooltip in the paramStr directly instead of using a variable.

 Because I'm using the paramStr in a dynamic created rollout.

 

This works:

local nameSwatch = "swatch_" + (counter as string)

paramStr:(
"fieldWidth:"+swatch_width as string \
+" height:"+swatch_height as string \
+" pos:["+swatch_x as string+","+swatch_y as string+"]" \
+" color:" + col_line[2] as string \
+" modal:"+true as string \
+" toolTip:'toolTipData'"
)

 

This isn't working with the custom tooltip set to myTooltipText?

local nameSwatch = "swatch_" + (counter as string)

paramStr:(
"fieldWidth:"+swatch_width as string \
+" height:"+swatch_height as string \
+" pos:["+swatch_x as string+","+swatch_y as string+"]" \
+" color:" + col_line[2] as string \
+" modal:"+true as string \
+" toolTip:" + "myTooltipText"
)

 

Any ideas,

Thanks

0 Likes
Accepted solutions (2)
610 Views
4 Replies
Replies (4)
Message 2 of 5

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

 

 

rcg.addControl #button #reset_bt "" paramstr:("width:22 align:#left offset:[-6,0] tooltip:\"Reset\"")

 

 

... or use stringstream for dynamic string creation:

 

ss = stringstream ""
format "width:% align:% offset:% tooltip:\"%\"" 22 #left [-6,0] "Reset" to:ss 
_str = ss as string

rcg.addControl #button #reset_bt "" paramstr:_str

 

 

0 Likes
Message 3 of 5

bertv
Enthusiast
Enthusiast

Thanks Denis,

 

Worked perfectly

I implemented as following using your suggestion:

 

			ss = stringstream ""
			format "fieldWidth:% height:% pos:% color:% modal:% tooltip:%" swatch_width swatch_height ("["+swatch_x as string+","+swatch_y as string+"]") (col_line[2]) true ("\"" + col_line[1] as string + "\"") to:ss
			_str = ss as string

 

0 Likes
Message 4 of 5

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

format is to convert a value to string ... so it can be:

format "fieldWidth:% height:% pos:[%,%] color:% modal:% tooltip:\"%\"" swatch_width swatch_height swatch_x swatch_y col_line[2] true col_line[1] to:ss
0 Likes
Message 5 of 5

bertv
Enthusiast
Enthusiast

Thanks Denis,

Neat code

0 Likes