Get active member row number of open iPart or iAssembly

Get active member row number of open iPart or iAssembly

erichter
Advocate Advocate
1,216 Views
4 Replies
Message 1 of 5

Get active member row number of open iPart or iAssembly

erichter
Advocate
Advocate

I am trying to create a macro that will go to the previous or next row in an iPart table of an open iPart or iAssembly so that I can quickly scroll through without having to double click on the table. I know how to get to a row. For example, to get to row 5, I would write:

iPart.ChangeRow("", 5)

But I do not know how to find the row that is currently active. So if I am already on row 5, then I would like to go to row 6. I tried using iPart.RowNumber, but that doesn't seem to work within the iPart file itself.

 

The most useful link I found was as follows, but I still don't know how to get the active row number.

https://adndevblog.typepad.com/manufacturing/2013/02/manipulate-rows-and-columns-of-ipart-1.html

 

Can anyone help me with this?

0 Likes
Accepted solutions (1)
1,217 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

i wrote this rule last week for an other question. mabey it helps you. it runs throu all mebers on an iPart.

Dim doc As PartDocument = ThisDoc.Document

If (doc.ComponentDefinition.IsiPartFactory = False) Then
    MsgBox("This is not an iPart factory")
End If

Dim fact As iPartFactory = doc.ComponentDefinition.iPartFactory
For Each row As iPartTableRow In fact.TableRows
    fact.DefaultRow = Row
	doc.Update()
	doc.Update2(false)
	
    Dim result As MsgBoxResult = MsgBox("Check this. is it correct?", MsgBoxStyle.YesNo)
    If (result = MsgBoxResult.No) Then
        Exit Sub
    End If
Next

MsgBox("All checked.")

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

erichter
Advocate
Advocate

The code and the link you provided were very helpful. I'm almost there, but I'm still missing the final piece.

 

iPartFactory.DefaultRow describes the open row (though I cannot use it in that form), and iPartFactory.DefaultRow.MemberName provides me with the member name of the current open row, but I am looking for the Default Row number and can't figure out what right bit of code is.

 

If you can help me further, it would be much appreciated.

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

how does this work for you?

Dim doc As PartDocument = ThisDoc.Document

If (doc.ComponentDefinition.IsiPartFactory = False) Then
    MsgBox("This is not an iPart factory")
End If

Dim fact As iPartFactory = doc.ComponentDefinition.iPartFactory
Dim curentRow As iPartTableRow = fact.DefaultRow
Dim rowNumber As Integer = -1
For i = 1 To fact.TableRows.Count
    Dim row As iPartTableRow = fact.TableRows.Item(i)
    If (row.MemberName = curentRow.MemberName) Then
        rowNumber = i
    End If
Next

MsgBox("Curent row number = " & rowNumber)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

erichter
Advocate
Advocate

That's exactly what I was looking for! It's more complicated than I assumed it needed to be, but it doesn't seem like there is a more direct way to get the row number.

 

I just replaced the message box with 

iPart.ChangeRow("", rownumber + 1)

and it switches to the next part exactly as I wanted it to.

0 Likes