Save then Check In PDF

Save then Check In PDF

tkennedy26
Enthusiast Enthusiast
3,548 Views
17 Replies
Message 1 of 18

Save then Check In PDF

tkennedy26
Enthusiast
Enthusiast

We are now using our Vault to store all of our PDFs, where this use to be a shared drive. How can I check in a PDF after it is created? "VaultCheckInTop" Only gets my drawing and model, doesn't recognize the PDF. I've posted my entire code but all I need to do is Check In the PDF. Any ideas?

Dim invApp As Inventor.Application = ThisApplication
Dim doc As Document = ThisApplication.ActiveDocument
Dim PDFAddIn As Inventor.ApplicationAddIn
Dim oContext As TranslationContext
Dim oOptions As NameValueMap
Dim pdfDataMedium As DataMedium
		
		CurFileName = doc.FullFileName
  		'defines backslash As the subdirectory separator
		Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar
		'find the postion of the last backslash in the path
		FNamePos = InStrRev(CurFileName, "\", -1)   
		'get the file name with the file extension
		Name = Right(CurFileName, Len(CurFileName) - FNamePos)
		'get the file name (without extension)
		ShortName = Left(Name, Len(Name) - 4)
		'get the path of the folder containing the file
		Folder_Location = Left(CurFileName, Len(CurFileName) - Len(Name))
		

        'start pdf addin. save current file as pdf.
        PDFAddIn = invApp.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

        oContext = invApp.TransientObjects.CreateTranslationContext
        oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
        oOptions = invApp.TransientObjects.CreateNameValueMap
        pdfDataMedium = invApp.TransientObjects.CreateDataMedium

        If PDFAddIn.HasSaveCopyAsOptions(pdfDataMedium, oContext, oOptions) Then
            oOptions.Value("Remove_Line_Weights") = 1
            oOptions.Value("Vector_Resolution") = 400
            oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
        End If

        pdfDataMedium.FileName = Folder_Location & "\" & doc.DisplayName & ".PDF"
        Call PDFAddIn.SaveCopyAs(doc, oContext, oOptions, pdfDataMedium)
        'set text box to complete notification
		MessageBox.Show("PDF has been saved", "PDF Saved")
		
		ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckintop").Execute2(False)'Check In
0 Likes
Accepted solutions (1)
3,549 Views
17 Replies
Replies (17)
Message 2 of 18

AlexFielder
Advisor
Advisor
Accepted solution

You could attach the pdf to the drawing and then check the drawing in.

 

I have a rule here that does this:

 

https://github.com/AlexFielder/iLogic/blob/master/AddRemove/embed%20inventor%20drawings.iLogicVb

 

🙂

Message 3 of 18

bradeneuropeArthur
Mentor
Mentor

Hoi better use the add it check in of vault selves:

 

Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn(My.Settings.Server, My.Settings.DataBase, Vcred.UserName,My.Settings.Password, VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)

Dim connection AsVDF.Vault.Currency.Connections.Connection = results.Connection

Dim lfolderID As Long = VaultfolderId

Dim folder As Autodesk.Connectivity.WebServices.Folder = serviceManager.DocumentService.GetFolderById(lfolderID)

Dim myFolder As VDF.Vault.Currency.Entities.Folder = NewVDF.Vault.Currency.Entities.Folder(connection, folder)

Dim myFileIterationNewFile AsVDF.Vault.Currency.Entities.FileIteration = Nothing

Using fileStream As Stream = New FileStream(filePath,FileMode.Open, FileAccess.Read)

' Add the file to the vault

myFileIterationNewFile = connection.FileManager.AddFile(myFolder,Path.GetFileName(filePath), Path.GetFileName(filePath),DateTime.Now, Nothing, Nothing, FileClassification.None,False, fileStream)

End Using

'Logout

VDF.Vault.Library.ConnectionManager.LogOut(connection)

UploadFile = myFileIterationNewFile.EntityMasterId

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 4 of 18

AlexFielder
Advisor
Advisor

Hi @bradeneuropeArthur

 

That's an interesting snippet you shared, it doesn't look like it would run in iLogic without a reference to the VDF .dll though?

 

EDIT: FWIW I mean the .dlls listed here: http://help.autodesk.com/view/VAULT/Help/ENU/?guid=GUID-959DDEDA-0FB5-4C93-8685-970CC0364498

0 Likes
Message 5 of 18

bradeneuropeArthur
Mentor
Mentor

This is a snippet from VB.net add in for inventor.

 

Because of these issues I do not prefer I-logic.

vb.net has more flexibility regarding dll links etc.

 

I could prepare a vb.net add very easy, but with I-logic this is very hard.

 

let me know if I can help you further with vb.net.

 

You can add a reference in illogic to.

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 6 of 18

AlexFielder
Advisor
Advisor

I completely agree with you about the difficulty in doing this with iLogic and with my last reply was hoping to tease out of you that this was NOT in fact** possible using iLogic - something you have now done. Smiley Wink

 

I guess it's left to @tkennedy26 to come back to us as to whether he wants/needs an addin created or could use my rule to attach the created pdf file and then check the files in.

 

 

 

** technically, if the Vault dlls I mentioned were placed in the GAC (I'm assuming they aren't as I haven't checked today) or manually copied to the "C:\Program Files\Autodesk\Inventor [Version]\Bin\iLogicAdd" folder, one could according to this post use the addreference mechanic to reference those dlls in an iLogic rule.

 

0 Likes
Message 7 of 18

tkennedy26
Enthusiast
Enthusiast

I was trying to get into writing this into VB.Net to use the Vault options like you said. But something that I think is unrelated is going on so I'm trying to work through that. I'm looking through programming forums to try and figure this out but after I write some code with my references I get this error (see attached) I'm not that great at this stuff but I'm pretty sure this is a problem on my machine. I'll have access to another machine on Thursday so I'm hoping to try it there until I can figure this out. Thanks for your help though! I'll let you know if I can take this further.

0 Likes
Message 8 of 18

tkennedy26
Enthusiast
Enthusiast

I was worried this wouldn't show up in the Vault Thin Client as  a standalone PDF being an attachment to the drawing but it does!

I'm working on tweaking this to automatically find and add the PDF that was just exported in an earlier sub. But this will get me there. Thanks!

0 Likes
Message 9 of 18

AlexFielder
Advisor
Advisor

You're very welcome. Smiley Happy

 

RE: your problem with the missing references, it leads me to ask the following questions:

 

1) how did you create the addin project that you're using? was it

  • manually or
  • using the template provided by the Inventor SDK

2) is your addin project stored somewhere like github? (so that I & others might help)

0 Likes
Message 10 of 18

bradeneuropeArthur
Mentor
Mentor

what version of visual studio are you running?

Have you installed the Inventor API and Vault API?

What version of inventor and vault are you running?

 

Regarding the coding:

 

The code I have provided is also possible in I-logic but is more difficult.

The could of make an attachment has advantages and some disadvantages for the vault data base and relations.

  1. it is easier to add these files because the vault api is not needed.
  2. the file is not easily to be checked out from vault if the file needs to be added (Pdf).
  3. the attachement cannot be deleted without inventor (Pdf)

so the code id have provided is easier in future, keep this in consideration!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 11 of 18

tkennedy26
Enthusiast
Enthusiast

The picture that error was taken from was actually from the Inventor SDK User Interaction sample. I get the same result when I use the Vault SDK samples and when I start a new project and manually add the references.

0 Likes
Message 12 of 18

bradeneuropeArthur
Mentor
Mentor

What version of Visual studio do you have installed?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 13 of 18

tkennedy26
Enthusiast
Enthusiast

I'm using VS 2015 Community, Inventor 2017 and Vault Pro 2017.

I installed the SDK tools for both programs, so I have all of the examples, the Vault dll reference files, and the Inventor Add In shows up as an option to in Visual Studio. Do I have to install something else too?

0 Likes
Message 14 of 18

AlexFielder
Advisor
Advisor

I don't think you have mentioned what Windows version you are running? One assumes Windows 10, but...?

0 Likes
Message 15 of 18

tkennedy26
Enthusiast
Enthusiast

Still on Windows 7 Professional. IT has given me permission to upgrade to 10, but most everyone else is staying on 7. Do you think this could solve it?

0 Likes
Message 16 of 18

AlexFielder
Advisor
Advisor

Honestly I don't know.

 

I have Windows 7 Pro here and Windows 10 Pro at home.

 

Are you able to share the project you have?

 

Failing that, you could try downloading and building this project I have been working on for some time with @MrSmithtastic:

 

https://github.com/AlexFielder/MyFirstInventorAddin

 

I know for certain that it builds on both my systems.

Message 17 of 18

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Open your project in Visual studio and change in the framework to a different version:

This should solve the problem.

 

let me know if it has worked.

 

Framework.PNG

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 18 of 18

tkennedy26
Enthusiast
Enthusiast

Sorry it took me so long to reply. Fortunately and Unfortunately I did not get to test changing the framework, I put it down for a bit and when I opened it up this week everything seems to be working OK. I'll keep it in mind if it happens again. Thanks for all your help.

0 Likes