I’m trying to create a Table, and in the Documents is written that a User can create rows, but when I’m in the editor there is not an ‘+’ sign as when I create a DynamicArray. Do I have to create all the rows first? If yes, I tried adding a default value based on a list, but I get the error: Object of type function is not JSON serializable. Here is a code snippet:
def node_list(params):
if params.geometry.truss_type == 'Warren' and params.geometry.truss_style == 'Without Vertical Elements':
return [{'node_id':i,'fx':0,'fy':0} for i in range(1,(params.geometry.divisions*2)+2)]
class Parametrization(ViktorParametrization):
geometry.divisions = NumberField('Number of Truss Spans:', min=2, max=20, num_decimals=0, variant='slider', default=5)
tab3 = Tab('Loads & Supports')
tab3.noad_load_table_button = BooleanField('Node Load Table',default=False)
tab3.noad_load_table = Table('Node Load Table',visible=IsNotEqual(Lookup('tab3.noad_load_table_button'),False),
default=node_list)
PS: when I put a list of dicts that follow the same pattern generated by the function node_list it works perfectly.
Okay the problem here is two-fold: on the one hand you’re struggling with how the user should create new rows in a table and on the other you’re trying to implement a default table which isn’t working.
The creation (and deletion) of new rows in a table is most easily done by simply right-clicking the table and choosing the three options (“add new row above”, “add new row below” or “remove row”). You are correct that the table does not include a button to add new rows. This is a design choice to keep the table field somewhat more compact than the DynamicArray.
Thanks for the fast reply, as you told there is a lot of topics with this subject. With right-click solves all my issues, but I didn’t think about it at first hahaha .