Update Item From File during Inventor CheckinFile

Update Item From File during Inventor CheckinFile

Anonymous
Not applicable
2,205 Views
2 Replies
Message 1 of 3

Update Item From File during Inventor CheckinFile

Anonymous
Not applicable

Hi Vault users,

i need to update the last item version during the Inventor CheckinFile event

Basically when the drafter has finished his work, he upload the file to the server, and immediately
the Vault must update the Item link with the new file version. I DON'T WANT TO TO AN ITEM REVISION

In Vault 2013 i've done this with an extension, using the Vault SDK function "UpdateItemsFromFile(...)

 

In Vault 2015 this function was removed, and now i'm not able to do the same work with the new functions added.


Here there is my piece of partial-working code

 

' put the item in edit mode
Dim modItem As Item() = m_ServiceManager.ItemService.EditItems(New Long() {articolo.RevId})

' AS THE VAULT SDK GUIDE SAYS: "Begin an "update items from files" operation on a component-by-component basis"
m_ServiceManager.ItemService.UpdatePromoteComponents(New Long() {modItem(0).RevId}, ItemAssignAll.Yes, True)

' final commit and unlock item
m_ServiceManager.ItemService.UpdateAndCommitItems(modItem)



Checking the status of the item from the Vault client i see that it continues to point to the previous version of file!
To align all it's necessary to do an "Update item" manually  Smiley Frustrated

 

I cannot force a new item revision, and i don't know which changes has been made in the Inventor file


Is there a way to do it AGAIN (via extension like Vault 2013)?

 

Thanks in advance

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

minkd
Alumni
Alumni
Accepted solution

I think you want to do something like the following (sorry for C# syntax, but I don't know VB syntax):

// promote the file to item

// NOTE: ItemAssignAll.Yes means we will also create items for all children (and their children, recursively)

// ItemAssignAll.No might be more appropriate for what you are doing - but I'm not sure.
svcmgr.ItemService.AddFilesToPromote(new long[] { fileIterationId }, ItemAssignAll.Yes, /*autoAssignDuplicates*/true);
// If you know the itemRevId you can use the following instead:
//svcmgr.ItemService.UpdatePromoteComponents(new long[] { itemRevId }, ItemAssignAll.Yes, /*autoAssignDuplicates*/true);

// get the order of promotion
DateTime tstamp;
webobj.GetPromoteOrderResults order = svcmgr.ItemService.GetPromoteComponentOrder(out tstamp);

// assume we have a small number of primary components (no batching).
// for large assemblies the array should be broken into chunks and sent individually.
if (order.PrimaryArray != null && order.PrimaryArray.Length > 0)
    svcmgr.ItemService.PromoteComponents(tstamp, order.PrimaryArray);

// assume we have a small number of non-primary components (no batching).
// for large assemblies the array should be broken into chunks and sent individually.
if (order.NonPrimaryArray != null && order.NonPrimaryArray.Length > 0)
    svcmgr.ItemService.PromoteComponentLinks(order.NonPrimaryArray);

// get results
webobj.ItemsAndFiles promoteResult = svcmgr.ItemService.GetPromoteComponentsResults(tstamp);

List<webobj.Item> items = new List<webobj.Item>();
for (int i = 0; i < promoteResult.ItemRevArray.Length; ++i)
{
    if (promoteResult.StatusArray[i] > 1) // 1 means unchanged, 2 means new item was created, 4 means existing item was updated
    {
        items.Add(promoteResult.ItemRevArray[i]);
    }
}
if (items.Count > 0)
    svcmgr.ItemService.UpdateAndCommitItems(items.ToArray());

-Dave



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 3 of 3

Anonymous
Not applicable
Thank you very much Dave!
This was EXACTLY what i was looking for!

And, last but not least, you were correct too about the set ItemAssignAll to NO.

Thanks again!
Dave
0 Likes