Cannot get PartsList

Cannot get PartsList

1354448288
Contributor Contributor
698 Views
6 Replies
Message 1 of 7

Cannot get PartsList

1354448288
Contributor
Contributor

Here is my code:

PartsList partsList = drawingDocument.ActiveSheet.PartsLists[1];

When I continue:

MessageBox.Show(partsList.PartsListRows[0].ReferencedFiles[0].ToString());

I cannot get anything, and will get a message(an exception)

$exception HRESULT:0x80070057 (E_INVALIDARG))System.ArgumentException
0 Likes
699 Views
6 Replies
Replies (6)
Message 2 of 7

Michael.Navara
Advisor
Advisor

First item in collections in Inventor has index 1

MessageBox.Show(partsList.PartsListRows[1].ReferencedFiles[1].ToString());

 

0 Likes
Message 3 of 7

1354448288
Contributor
Contributor
I explained the exception a wrong way. The real problem is that :
PartsList partsList = drawingDocument.ActiveSheet.PartsLists[1];
int num = partsList.MaximumRows;
Then, I get a message: exception from HRESULT:0x80004005 (E_FAIL))
0 Likes
Message 4 of 7

1354448288
Contributor
Contributor
I indeed get the partlist, and can print partslist.title partslist.layer, but I cannot get partsList.MaximumRows
0 Likes
Message 5 of 7

Michael.Navara
Advisor
Advisor

OK this member returns exception but you can use another approach

var partsList = drawing.ActiveSheet.PartsLists[1];
int rowsCount = partsList.PartsListRows.Count;

foreach (PartsListRow row in partsList.PartsListRows)
{
    string displayName = row.ReferencedFiles[1].DisplayName;
    //Logger.Debug(displayName);
}

 

 

0 Likes
Message 6 of 7

1354448288
Contributor
Contributor
Thank you !! I just found the same way.
But I am still curious about why cannot get partsList.MaximumRows.
0 Likes
Message 7 of 7

JelteDeJong
Mentor
Mentor

 I expect that partsList.MaximumRows is a reference to the maximum number of rows before a new column  is added to your part list. 

JelteDeJong_0-1631697457413.png

 

 

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