Area :: Header
New tools, templates and workflows
Announcing Extension 2 for 3ds Max 2015 and 3ds Max Design 2015
Discussion Groups


Active Member
Posts: 10
Registered: ‎04-17-2012 and setting FBCellStyle

85 Views, 1 Replies
04-26-2013 06:44 AM
I'm attempting to put various types into spreadsheet cells (buttons, vectors, ints, reals, etc)...w/o any luck.

In fact, I can not get the sample (Running MoBu 2012) to populate the cells with any values other than the text field....

# From shipped code...

s = FBSpread()
s.Caption = "Spread"

s.ColumnAdd("Col 1")
s.ColumnAdd("Col 2")
s.ColumnAdd("Col 3")

s.RowAdd("Row 1", 0)
s.RowAdd("Row 2", 1)
s.RowAdd("Row 3", 2)


c = s.GetColumn(0)
c.Caption = "first column"
s.SetCellValue(0, 0, 3)
s.SetCellValue(0, 1, 3.1416)
s.SetCellValue(0, 2, "py = 3.1416")

# only populates cell 0,2 with the text.....any ideas?

signed confused....
Please use plain text.
Posts: 11
Registered: ‎04-03-2013

Re: and setting FBCellStyle

04-26-2013 01:32 PM in reply to: ReviveOften
If you change those values to a string (and start them with a letter) those commands work.

It seems like there's something broken in the way the SetCellValue is working, because the docs say that it's supposed to set the FBSpreadCell.Style of the cell you're putting something in to match the data type of whatever you're putting in there. It looks like, by default, it only works with strings.

You can set the cell style yourself though, and this seems to work.

# set some initial values:
s.GetSpreadCell(0,0).Style = FBCellStyle().kFBCellStyleInteger
s.SetCellValue(0, 0, 3)
s.GetSpreadCell(0,1).Style = FBCellStyle().kFBCellStyleDouble
s.SetCellValue(0, 1, 3.1416)
s.SetCellValue(0, 2, "py = 3.1416")

I only spent a couple minutes looking this up, though, so there might be something more to this. It is odd, though, that the script that shipped with MB doesn't seem to work out of the box.

Totally missed your first line. You can check out the fbcontrols.h File Reference page in the C++ docs to see all the cell styles. There's a Button style, but it doesn't look like you put a button in it, it just makes the cell look and act like a button with the caption set by giving it a string through SetCellValue.

Vectors would probably have to be handled by splitting each value out across 3 cells, not all in a single cell (unless you made it a string and handled it with some funky formatting behind the scenes).

Found the reason it's only accepting strings by default. If you don't set the cell style yourself, all the cells are created as kFBCellStyleString. Also, setting them to kFBCellStyleDefault results in them becoming kFBCellStyleString.
Please use plain text.