Delete a iPart Table row Programatically

Delete a iPart Table row Programatically

Anonymous
Not applicable
1,385 Views
3 Replies
Message 1 of 4

Delete a iPart Table row Programatically

Anonymous
Not applicable

Hi Guys,

 

In ipart there is an option to add and delete rows when working with inventor graphically.

 

I have displayed the iPart table and the values in gridview using VB.Net.

 

The user then selects the row in datagridview and clicks the button delete.

When the button onclick even is triggered i want to delete the selected row on ipart table inside inventor 

 

Does anybody has an idea of how to do it ???

0 Likes
Accepted solutions (1)
1,386 Views
3 Replies
Replies (3)
Message 2 of 4

ekinsb
Alumni
Alumni
Accepted solution

Here's some sample code that illustrates deleting a row from the table of an iPart factory.  The example deletes the last row.  In your case I suspect you've loaded them into your grid in the same order as they are in the factory so you know the index of the row to delete.

 

Public Sub DeleteIPartRow()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument    

    If Not partDoc.ComponentDefinition.IsiPartFactory Then
        MsgBox "Must be an iPart factory."
        Exit Sub
    End If

    Dim factory As iPartFactory
    Set factory = partDoc.ComponentDefinition.iPartFactory

    factory.TableRows.Item(factory.TableRows.Count).Delete
End Sub

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 4

Anonymous
Not applicable

ekinsb

 

I have already tried this, but i need the user to select the row from datagridview and then use the delete button.

And Yes I've added all the data in the same order as displayed in inventor, and also disabled the sorting of columns in datagridview.

 

Is there any way to pass the datagridview selected row index in the below code

factory.TableRows.Item(factory.TableRows.Count).Delete)

 


0 Likes
Message 4 of 4

Anonymous
Not applicable

ekinsb,

 

I got it solved...

 

Thanks for the hint provided.

 

 

0 Likes