Vault Professional 2012.
Do we have access to the batch plot or any printing/plotting functions built into the Vault Client through the API?
Most of our vendors and clients require PDFs. To that end what we do is manually create a PDF from inventor whenever updating and checking in a drawing.
I have developed a Vault Add-In that allows a user to grab the BOM from an item card, or Associated files from an Inventor Assembly. The "BOM" is then displayed in a multi-level grid with all the information pertinent to us. Title, Description, Revision etc.
I can then click on a button and have all of the related DWFs placed into a folder of choice, have them automatically named/renamed according to our standards with little or no input required by the user.
What I would like is to do the same using PDF instead of DWF, thus eliminating the (often missed) manual process of creating the PDF as we update drawings.
Vault uses DWF as the default format for viewing the drawing, and changing this is not recommended because you may encounter some problems that are not expected and nobody tested those. You can consider to auto-generate the PDF through Inventor API.
EventWatcher is a tool from Inventor SDK. You can use it to view what command is called when updating properties or checking file from Inventor. Two events are useful regrading to this:
1) UserInputEvents.OnActivateCommand
2) UserInputEvents.OnTerminateCommand
And the command names that I found are:
VaultCheckinTop,
VaultPropertyWriteBack
You can use an Inventor AddIn application to capture those events, similar like EventWatcher, and do your business logic when those commands in your interest are called.
Inventor PDF translator can create the PDF file for you. There are existing sample in Inventor API document.
Hope this helps.
Here is some code that does the trick?
But read my remarks in the OnTerminate command. and how do we now grab the pdf and upload it to vault?
regards kent boettger
Private Sub m_UserinputEvents_OnActivateCommand(ByVal CommandName As String, ByVal Context As Inventor.NameValueMap) Handles m_UserinputEvents.OnActivateCommand If (CommandName = "VaultCheckinTop") Then MsgBox("You are about to checkin a drawing to vault") PublishSinglePDF() End If End Sub Private Sub m_UserinputEvents_OnTerminateCommand(ByVal CommandName As String, ByVal Context As Inventor.NameValueMap) Handles m_UserinputEvents.OnTerminateCommand If CommandName = "VaultCheckinTop" Then 'the question here is how do we actually check that the user checked in the drawing? and did no cancel the checkin 'here i figure we have to make a call into vault and somehow check that the version number increased. 'or is this version number somehow stored in the drawing file. because at this point the pdf is allready created 'and we have to go and delete it again if the user canceled the checkin. or can we maybe compare something inside the file before and after the checkin? End If End Sub Public Sub PublishSinglePDF() On Error Resume Next m_inventorApplication = GetObject(, "Inventor.Application") m_Document = m_inventorApplication.ActiveDocument If m_Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then MsgBox("No pdf was Created") Exit Sub End If If m_Document.FileSaveCounter < 1 Then MsgBox("You must save the file, before you can create the pdf") Exit Sub Else ' Get the PDF translator Add-In. Dim PDFAddIn As TranslatorAddIn PDFAddIn = m_inventorApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") Dim oContext As TranslationContext oContext = m_inventorApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism 'kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = m_inventorApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = m_inventorApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If PDFAddIn.HasSaveCopyAsOptions(m_Document, oContext, oOptions) Then ' Options for drawings... oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 Dim Pdf_File_Name As String Pdf_File_Name = m_Document.FullFileName.Substring(0, m_Document.FullFileName.Length - 4) oDataMedium.FileName = (Pdf_File_Name & ".pdf") 'Publish document. Call PDFAddIn.SaveCopyAs(m_Document, oContext, oOptions, oDataMedium) End If End If If m_Document.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then MsgBox("You checked in a file to vault, the pfd was created in the local folder where the checked in drawing is") End If End Sub
This was supplied to me by Steve Bedder but will probably help you (It was written to work with Inventor iLogic):
Public Sub InsertObjectSample() Dim doc As Document Set doc = ThisApplication.ActiveDocument ' Verify the active document has been saved. If doc.FullFileName = "" Then MsgBox "This document must be saved first." Exit Sub End If ' Build the filename based on the filename of the active document. Dim filename As String filename = doc.FullFileName filename = Left$(filename, InStrRev(filename, ".")) & "jpg" ' Make sure the specified file exists. If Dir(filename) = "" Then MsgBox "The file """ & filename & """ does not exist." Exit Sub End If ' Create the embedding. Dim oleReference As ReferencedOLEFileDescriptor Set oleReference = doc.ReferencedOLEFileDescriptors.Add(filename, kOLEDocumentEmbeddingObject) ' Set the name in the browser. oleReference.DisplayName = Mid$(filename, InStrRev(filename, "\") + 1) End Sub
If you've already captured the check-in event within Inventor, there's no reason why you couldn't get Inventor to also add the created .pdf files as OLE attachments to the Inventor file itself which in turn will attach them to the Inventor file once it's in the Vault - in much the same way as images are attached..
I would advise asking the user if they want to create/attach .pdf files each time as it would get extremely irritating if you had to wait for this to complete every time you checked a file in.
In fact, you could simply filter for a specific file type and only then prompt the user for .pdf creation.
EDIT: A colleague just asked me what happens to an existing attachment if/when it gets updated by publishing a new version. I guess it would need to be removed and re-attached within Inventor before being returned to the Vault?
Can the same approach be used with AutoCAD to create a PDF from the DWG on check-in to Vault?
We have 2013 Plant Design Suite & Product Design Suite + Vault Professional
OnTerminateCommand doesn't tell if the user canceled the operation, so it's not idea way to identify the right time for uploading PDF to Vault.
My suggestion is to use Vault web service API to capture Vault's AddFile post event, then upload the PDF file, finally use AddDesignVisualizationFileAttachment API to attach PDF to Vault file.
Below is a C# code sample that add a visualization file to Vault then attach it to an existing Vault file:
_file = ServiceCache.GetDocumentService().AddFile(folder.Id,
fi.Name,
"",
fi.LastWriteTime,
fileParams,
bom,
FileClassification.DesignVisualization,
true,
bytes);
if (System.IO.File.Exists(FileName))
{
System.IO.File.SetAttributes(FileName, System.IO.FileAttributes.Normal);
System.IO.File.SetCreationTime(FileName, _file.CkInDate);
System.IO.File.SetAttributes(FileName, System.IO.FileAttributes.ReadOnly);
}
// Assume that we have known the Id of the Vault file is 175
File pFile = ServiceCache.GetDocumentService().GetLatestFileByMasterId(175);
FileAssocParam fileParam1 = new FileAssocParam();
fileParam1.CldFileId = _file.Id;
fileParam1.RefId=null;
fileParam1.Typ=AssociationType.Attachment;
ServiceCache.GetDocumentService().AddDesignVisualizationFileAttachment(pFile.Id,fileParam1);
Note those arguments of AddFile. The PDF (or DWF) should be hidden, and FileClassification must be DesignVisualization.
AutoCAD API can detect command begin and end event, and tell if the user canceled the command, so it would be easier to identify the proper time for uploading the PDF then Inventor API.
But I still recommend the way I explained in above post, because you don't need to care what design software you are using to detect when the file is uploaded.
Not only AddFile event, you can also keep track on CheckinFile event too, as the file may be checked out and checked back in Vault.
Hi kbo,
Can we add this option under RMB click options? I appreciate your help in advance.
Regards
Deva
Has this ever been asked as an enhancement request for Vault basic?
Its a tick box for solidworks's old add in Workgroup PDM. (Not sure if they are adding it to the new one to replace WPDM). but it was a function I made good use of.