Hi all,
Our client requires each drawing that we produce from Inventor to have a "Used On" field/property filled out. This normally refers to the Assembly that each part/sub-assembly is used on.
How would I go about using the "Where Used" data from Vault Professional 2012 to fill out this property?
Thanks in advance,
Alex.
If we are talking API programming then DocumentService.GetFileAssociationsByIds is the function you want. It allows you to get parent dependencies (where used) and child dependencies (uses) for a given file.
Thanks Doug,
That's what I thought I would need.
Do you have any examples showing how to add just such a command to the Vault interface?
I'm thinking that on doing so, I can set up my drawing (Inventor/AutoCAD) templates so that when this information gets populated to the file data stored in the Vault it can then be mapped to these custom file properties on each refresh/check-in.
What do you think?
I have another question;
Having added some User Defined Properties to my Inventor/AutoCAD file templates, and affter mapping them within Vault, I'm wondering what the next steps are:
Do I make this an add-in for Inventor that gets called when a file is checked in, or is it easier to create an extension for Vault Pro. that can be run by an administrator against a bunch of drawings.
Actually typing that last question makes it sound easier to (to me at least) work with Inventor than Vault - given that I've created Inventor add-ins before, but not Vault extensions.
If I am able to figure out the "Where used" data from within Inventor, I can simply add that to/update the file when the check-in event is fired? And then my mappings within the Vault will take care of themselves?
Wait. Let me see if I understand.
You are taking Vault were used data, adding it as and Inventor property which maps it back to a Vault property.
So you end up with the same data in 4 places:
Why do you need this as property data in the CAD file? Generally you want to avoid duplicating data if possible.
Also there is a bit of "chicken and the egg" problem. You need to add the file to Vault in order to read Vault where used data, but the CAD property needs to be set before you add it to Vault.
Lastly, what happens when a part is used in a new assembly? That where used information in the CAD file is now stale. Do you have to check-out the part and update the property?
I think you've hit the proverbial nail on the head:
I can understand your concern about duplicating lots of data, but at the moment I can't see any other way around it for my purposes; primarily because the where used data isn't easily accessible as a Standard property.
My process so far involves first having to make sure the file is in the vault and is checked out to the current user, then retrieve the "Where Used" data (if there is any available) for each part/sub-assembly and add it to a custom property stored within the file itself (UsedOn001 for instance) but not now in the Vault. (One less duplication I think?)
I had been planning to use mapping to populate user defined properties in the Vault, but when I think about your last reply, you're right, there's (not currently) a need to duplicate this data.
When I know that the file is checked out, I can update the (UsedOn001) file-property and this can then be used in the resultant Inventor Drawing Border.
Can I ask that the addition of a standard property containing "Where Used" data be added to the wish list? - I'm quite surprised that it isn't already a feature, but I suppose our client and their system is quite unique.
Currently, we have to fill out these fields in the Inventor Drawing Borders by hand; Which I'm sure you'll agree is massively time-consuming, but the configuration requirement from our client is such that if a part or sub-assembly changes, it updates the Drawing List of the parent Assembly also. (Which is something I plan to look at once I've gotten this part working)
I'm in the middle of writing code for Inventor that makes use of the Autodesk.Connectivity.WebServices.DocumentSvc & Autodesk.Connectivity.WebServices.WinAuthSvc functionality exposed by the API.
Here's what I've got so far that is called by the OnSaveDocument Event:
Public Shared Sub m_applicationEvents_OnSaveDocument(ByVal DocumentObject As _Document, _ ByVal BeforeOrAfter As EventTimingEnum, _ ByVal Context As NameValueMap, _ ByRef HandlingCode As HandlingCodeEnum) Handles m_applicationEvents.OnSaveDocument Dim proplist As New List(Of String) If BeforeOrAfter = EventTimingEnum.kBefore Then 'we should check whether the file is already in the vault. 'if it's not, stop but prompt the user to check in the file into the vault at least once. 'if it is in the vault, we need to check whether the file is checked out to the currently logged in user Try ' log in to the vault using Windows authentication Dim winAuthSvc As New WinAuthService() winAuthSvc.Url = "http://bas069/AutodeskDM/Services/WinAuth/WinAuthService.asmx" winAuthSvc.UseDefaultCredentials = True winAuthSvc.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.WinAuthSvc.SecurityHeader() winAuthSvc.SignIn("Vault") 'copy the security information over Dim docSvc As New DocumentService() docSvc.Url = "http://bas069/AutodeskDM/Services/DocumentService.asmx" docSvc.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader() docSvc.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket docSvc.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId Dim filename As String() = Nothing filename(0) = DocumentObject.FullFileName Dim results As FilePathArray() = docSvc.GetLatestFilePathsByNames(filename) 'check the file exists in the Vault. If results.Length = 0 Then Throw New Exception("This file isn't in the vault!") Else ' now that we know that at least one instance of this file exists in the vault ' we can try to determine if it is checked out to the current user? For i As Integer = 0 To results.Length Dim fp As Autodesk.Connectivity.WebServices.FilePath() = results(i).FilePaths For j As Integer = 0 To fp.Length Dim f As Autodesk.Connectivity.WebServices.File = fp(j).File If f.CheckedOut = True Then Dim currentuser As Long = docSvc.SecurityHeaderValue.UserId If f.CkOutUserId = currentuser Then 'the file is checked out to the current user! Else Throw New Exception("This file isn't checked out to you!" & vbCrLf & "Please check the file out and re-save to update Used On properties!") End If End If Next Next i End If Catch ex As Exception MessageBox.Show(ex.Message) Finally AddUpdateUsedOnProps(DocumentObject, proplist) End Try ElseIf BeforeOrAfter = EventTimingEnum.kAfter Then 'we can do something after the save? End If End Sub
Apologies for the brain dump.
TL;DR: You're right, duplicating data is a bad idea.
🙂
Yep..This is what I am going to have to figure out soon as well.
Let me start out by saying that having 'where used' on drawings is the basis of our entire logistical process. We use mark numbers/letters and have multiple details per drawing. Everything we make gets 'shipped' from these 'where used' tables in our drawings. The drawings are not just the design information but also the shipping instructions. In the 'where used' table we don't actually list the assembly part number the detail goes into per se, but we list the one (or many) drawing number/s that detail may appear on.
Anyway, I think vault still knows everywhere a detail is used, even if it is just a drawing and not subassembly, and whether it appears on the base view in the parent drawing or not. If so, I should be able to populate where used tables in drawings. I hope so otherwise I'm stuck. Of course I would prefer to change our thinking and have everything mapped from the assembly boms down and eliminate the bottom up reference, but that would be a big change and not well received. I could use some encouragement as I am trying to automate some processes without breaking this logistical process.
Lastly, all the item item information gets manually entered from physical drawings into the MRP. We are not a small company and we pride ourselves on our information mgmt, so this needs to be updated.
Back story...
The reason they do this is to give the installer a bidirectional reference to know where an item goes from the detail level up as well as from the assembly bom down. Shipping and the field can know everywhere an item/sub is used and how many. I know this was an innovation based on convenience, however I believe a DB query could do this better with reports.
This whole process may not make a lot of sense for a product or machine designer because things are fairly contained and you can do a file dump to MRP, but when you have dozens of partial improvement projects around a plant and manufacture and shipping will occur in multiple waves then the logistics and therefore documentation get very fragmented. It may be be unrealistic to model the logistical reality in cad assemblies in the first place, though that would mean being stuck in the 20th century indefinitely. In the past I would dump a hierarchical bom,..So I have worked with a more modern approach.
I think the end goal is to have a system that can take multiple BOM dumps in waves and track updated order quantities and account for WIP. Then you can release patials early and add detail and update quantities as you go. In that case we would define the shipping level in the ERP and just generate reports for the distribution/where used.
Perhaps some things this company does with its drawings complicate drawing automation, however I also know that if it can be done manually, then it can be done with the API. Question is how to approach it for incremental success?
Also, I understand this isn't that uncommon in automotive (fabrication) industries versus machine design where I come from, so I expect others have done or want to do something similar. Please share your thoughts experiences.
Hi Indentor,
Way to resurrect a thread! (Arrrgh, Braaaaains!)
Anywho, I was going to say that your needs sound completely different to mine, but then I thought about it some more and actually, when it comes down to it, the need is exactly the same - albeit on a different scale.
My "where used" data refers to items in the parent assembly/facility and yours refers (if I understand correctly) to a different logistical location.
Re-reading Doug's comments from last year, the DocumentService.GetFileAssociationsByIds method seems to be the most logical step, but, also referring to his last comment, you'd be stuck with the same chicken and egg scenario as me.
Taking his point about inserting an existing part in a new assembly as an example, you would need to check out the existing part, insert it into the new assembly (into which you could force the user to insert some rudimentary information) and then save the ****'y, then update the information contained within the existing part to reflect this new additional "Used On" variable.
All fine in theory (I think) but it's been a while since I've delved into the Vault API so I couldn't begin to tell you where to start code-wise.
Perhaps now this thread is re-born, someone will be able to chime in with some boiler-plate code that might prove useful?
Thanks for replying. These automation initiatives can get lonely.
The different part that we do is list all of drawings where a detail gets consumed, but yeah it's pretty much the same. Not sure when I can tackle this but hope it is soon.
I don't however see the other fellow's argument that this is chicken or the egg because we are trying to capture a static condition of what drawings/asssemblies use/consume the detail in question, and that won't change as a result of the query at least, or any property edits we do. So while we may change/ add detail iprops the where used part is static. I can imagine not wanting to run this query every time one opens a drawing to update a where used table, but that would be the only way to guarantee the data don't go stale.
As a first improvement I would be happy making a vault report and manually filling in where-used into the drawings. That I can sort of do from the vault explorer now, so we''ll see how far this gets.
Hi all,
I realise this is an old thread, but it's something that could (still) be really useful to us (and more importantly) to our client.
Is there anything new in the API that makes this task easier or do I still *only* need the functions/capabilities given by Doug in his replies?
Thanks,
Alex.
Hi guys,
I tryign the following,
DocumentService docSer = new DocumentService(); FileAssocArray[] filePaths = docSer.GetFileAssociationsByIds(new[] { vaultFile.Id }, FileAssociationTypeEnum.None, false, FileAssociationTypeEnum.Attachment, true, true, true);
I am getting the following error
System.Web.Services.Protocols.SoapException: 106 at Autodesk.Connectivity.WebServices.DocumentSvc._DocumentService.Invoke(String methodName, Object[] parameters) at Autodesk.Connectivity.WebServices.DocumentSvc._DocumentService.GetFileAssociationsByIds(Int64[] fileIds, FileAssociationTypeEnum parentAssociationType, Boolean parentRecurse, FileAssociationTypeEnum childAssociationType, Boolean childRecurse, Boolean includeRelatedDocuments, Boolean includeHidden) at SendFile.Helper.vaultHelper.getVaultFileProp(File vaultFile) in vaultHelper.cs:line 112 at SendFile.Helper.vaultHelper.getVaultFileDetails(Connection connection, List`1 filesColl) in Helper\vaultHelper.cs:line 214
Hi Alex!
In our company's case I shifted that topic to Inventor where the documents are beeing created and modified. Therefore I think there should be no chicken-egg-question as it is quite clear that the CAD data is created in CAD and Inventor knows about the file usage.
In my solution I used Inventor VBA like this:
Set activeDoc = InvAppl.ActiveDocument
If activeDoc.File.ReferencingFiles.Count <> 0 Or activeDoc.ReferencedDocuments.Count <> 0 Then
For Each RefFile In activeDoc.File.ReferencingFiles
...
Next
For Each refDoc In activeDoc.ReferencedDocuments
...
Next
End If
Maybe this is an idea for you also!?
Best regards
Lars