Re-Write FileBom with "SetBomByFileId" throws error code "1145"

Re-Write FileBom with "SetBomByFileId" throws error code "1145"

Patrick.Gruber
Enthusiast Enthusiast
1,769 Views
5 Replies
Message 1 of 6

Re-Write FileBom with "SetBomByFileId" throws error code "1145"

Patrick.Gruber
Enthusiast
Enthusiast

Hi community,

I have used SetBomByFileId to re-write the FileBom.

 

The new FileBom is the same like the old one but I have removed just 1 component from the CompArray.

The function "SetBomByFileId" throws the error code "1145", but I can nowhere locate the appropriate error message for this code. Where can I find it?

 

Real Problem

GetBOMByFileId returns Components with XRefIds which do not exist in Vault anymore.
After running the Autodesk Job autodesk.vault.extractbom.inventor on the affected Assembly doesn't write a new FileBom like mentioned in this blog post 
The API documentation for SetBomByFileId (which the job should use) says "File cannot have a BOM already associated with it."
Does this mean the job fixes the FileBom only in case there is NO bom at all?
Is there a better way in my case where only some XRefIds are wrong without making a check-in with Inventor?
 
Had somebody else a similar case? Any help is very appreciated thanks!
 
 
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos!
😉
The author,
Patrick

coolOrange
www.coolOrange.com
0 Likes
Accepted solutions (1)
1,770 Views
5 Replies
Replies (5)
Message 2 of 6

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Hi Patrick,

I'd like to clarify the base concept first, even I can't quickly all your question details.

The Job "Extract Item Data" (User command in Vault Professional, Actions->Extract Item Data) runs only if no BOM data exists for the component. It is NOT applicable to update/correct existing BOM data. The only supported path to update existing BOM data in Vault Professional is checking in the file using Inventor.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 3 of 6

ThomasRambach
Advisor
Advisor

@Markus.Koechl  In all the example code I've seen for checking in a file through the API it uses: 

 

public override File CheckinUploadedFile( 
   System.long fileMasterId,
   System.string comment,
   System.bool keepCheckedOut,
   System.DateTime lastWrite,
   FileAssocParam[] associations,
   BOM bom,
   System.bool copyBom,
   System.string newFileName,
   FileClassification fileClassification,
   System.bool hidden,
   ByteArray uploadticket
)

 

Where the BOM is set to NULL and copyBom is set to True. This works well. However, we have part of our code instances where the Inventor BOMStructure is updated from Normal to Purchased as part of the Job Processor job. So, we've discovered that now that we're utilizing Items, some of the BOMS do not match what the file really is set to. 

 

My question is, I haven't seen any examples of code where when you check-in a file, how do you read in the latest BOM information from the file that was uploaded? Is there a way to manipulate the BOMStructure value for a component in a BOM and then associate the manipulated BOM to the file being uploaded?

 

 

0 Likes
Message 4 of 6

Markus.Koechl
Autodesk
Autodesk

Hi @ThomasRambach,

creating/updating the BOM object is reserved for the Inventor-Vault Addin. The Add-In does not provide an API that we could leverage.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 6

ThomasRambach
Advisor
Advisor

@Markus.Koechl What's strange is you can read the info but not change it. Do you think this is something the API may provide in the future?

// Get the File BOM
ACW.BOM fBOM = DocSrvc.GetBOMByFileId(fFileID);

// Read the parent assembly BOM Structure
ACW.BOMStructureEnum fCompBOMStruct = fBOM.CompArray[0].BOMStruct;

// I can even change the assembly BOM structure
fBOM.CompArray[0].BOMStruct = ACW.BOMStructureEnum.Purchased;

// I just can't reassociate the modified BOM back to the file 
0 Likes
Message 6 of 6

ThomasRambach
Advisor
Advisor

I actually was able to get this to work. So, you actually can manipulate the Vault underlying BOM using the API.

0 Likes