TableCommandInput .getPosition() method

TableCommandInput .getPosition() method

tomas.bangoA2EPZ
Advocate Advocate
429 Views
3 Replies
Message 1 of 4

TableCommandInput .getPosition() method

tomas.bangoA2EPZ
Advocate
Advocate

Hi, I have a table that has 1 column and 3 rows. On the 3rd row there is a commandInput whose ID is 'Text3'. I got stuck in creating a def that returns me the position of that ID.

 

def Show_ro(tbl: adsk.core.TableCommandInput):
    input_List=adsk.core.CommandInputs.cast(tbl.commandInputs)
    input_ID='Text3'
    cmd_input=?#STUCKED HERE
    row_number=tbl.getPosition(cmd_input)
    return row_number

I need some advice on how to define a cmd_input variable as a commandInput using its ID so that it can go to get its position using the .getPosition() method.

 

 

Thank you so much for any advice I've been trying this all night and it's driving me crazy that I can't figure out how

 

0 Likes
430 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @tomas.bangoA2EPZ .

 

I was able to obtain it by following these steps.

def Show_ro(tbl: core.TableCommandInput):

    # get target command input
    input_ID = 'Text3'
    txtIpt: core.TextBoxCommandInput = tbl.commandInputs.itemById(input_ID)

    # TableCommandInput getPosition
    # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-EB17A923-818D-424D-970E-8721802D0B73
    returnValue, row, column, rowSpan, columnSpan = tbl.getPosition(txtIpt)

    return row
Message 3 of 4

tomas.bangoA2EPZ
Advocate
Advocate

Hi for me it's not working for some reason. I have this feature. And I have created a list inputs_List into which

def Show_row_BN(Ass_name,tbl: adsk.core.TableCommandInput):
    #CMDinput=adsk.core.CommandInputs.cast(cmd_input.commandInputs)
    input_List=adsk.core.CommandInputs.cast(tbl.commandInputs)
    Subs_List=[]
    Subs_List=ComponentWork.findSubs(Ass_name)
    Subs_List_count=len(Subs_List)
    rs_number=tbl.rowCount
    inputs_List=[]
    for tblr in range(0,rs_number):
        inputo=tbl.getInputAtPosition(tblr,1)
        id_inputo=inputo.id
        obj_inputo=inputo.objectType
        inputs_List.append(f'{id_inputo}_{obj_inputo}')

    for pex in range(0,Subs_List_count):
        for ex in range(0,rs_number):
            get_name=(Subs_List)[pex]
            input_ID=(f'Prop_{1}_{get_name}')
            my_ipt: adsk.core.StringValueCommandInput = tbl.commandInputs.itemById(input_ID)
            poz, row, coll,rowS,collS = tbl.getPosition(my_ipt)
            pass

I use getInputAtPosition to retrieve the id and objecttype of each commandInput placed in the table, see picture below.

tomasbangoA2EPZ_0-1677531310281.png

input id is:

tomasbangoA2EPZ_1-1677531357797.png

 

Unfortunately, if I try to define a commandInput using its ID, it returns as None and this leads to an invalid command Input error. Any advice please? 

0 Likes
Message 4 of 4

kandennti
Mentor
Mentor

@tomas.bangoA2EPZ .

 

I am sorry, but I cannot understand more than this even if I am shown only a part of it.

If it were me, I would create something that works in part only, test it until it works, and make it functional.

0 Likes