Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic for link PDF template checklict only to new created drawings

Anonymous

iLogic for link PDF template checklict only to new created drawings

Anonymous
Not applicable

Hi all,

 

i have PDF checklist who is attached in Vault on every new drawing. This is manually done. Every user manually link pdf document for every new drawing. In document is list of things that user must do before releasing drawing.

 

My question is...is there any way to use iLogic for that?

For example when user create new drawing renamed copy of PDF checklist document is automatically attaching on that drawing.

 

Does someone have some similar code?

 

Thnx

0 Likes
Reply
570 Views
5 Replies
Replies (5)

philip1009
Advisor
Advisor

There are a few things to go over for a rule like this.  It is all certainly possible with iLogic unless you're looking for a way to manipulate the contents of the PDF file itself, which isn't possible with iLogic, you'll have to go through VBA to possibly get that kind of functionality.

 

Are you just looking for a rule that checks if there's an attached PDF matching the same name as the document, and if none exists copy a PDF from a template matching the drawing name and attaching it?

 

If this file is meant for checking that a drawing is checked properly, you can directly use iLogic to check parameters and other things without referring to a document at all.  For example, if the part number is supposed to be a specific format, you can check that with iLogic and prompt the user to fix it on the spot.

 

If you want to use a document for double-checking work that non-Inventor users can see, I recommend you use an Excel spreadsheet since Inventor has the ability to manipulate Excel spreadsheets.

 

Could you detail the exact workflow you plan on achieving with this rule?  That will help us nail down the steps we need to take in the iLogic code, thanks.

 

In the meantime, if you're new to using iLogic, I recommend you look into learning all you can about it since it can be a very powerful tool to fill in those gaps that Autodesk hasn't filled yet.  iLogic is based on a coding language called Visual Basic (VB), here's a playlist that teaches each function of VB, it's not exact to what iLogic uses, but it does contain all of the VB functionality so you can use the best methods while writing this code:

https://www.youtube.com/watch?v=mM3zB3QWuv8&list=PLC601DEA22187BBF1&index=1

AlexFielder
Advisor
Advisor

Hi @Anonymous,

 

You can repurpose this rule of mine to do what you want:

Option Explicit On
Sub Main()
	
	'current document
	Dim doc as Inventor.Document = ThisDoc.Document
	
	'Verify the current document has been saved.
	If doc.FullFileName = "" Then
		MessageBox.Show("This document must be saved first.")
		Exit Sub
	End If
	
	'default folder
	Dim FolderName As String  = System.IO.Path.GetDirectoryName(doc.FullFileName)	
	Dim selectedfile As String = String.Empty
	Dim oFileDlg As inventor.FileDialog = Nothing
	InventorVb.Application.CreateFileDialog(oFileDlg)
	oFileDlg.Filter = "Dwg files (*.dwg)|*.dwg|Excel files (*.xlsx)|*.xlsx|pdf files (*.pdf)|*.pdf|Inventor parts (*.ipt)|*.ipt|Inventor iFeatures (*.ide)|*.ide|XML Parameter files (*.xml)|*.xml|Step files (*.stp;*.step;*.stpz)|*.stp;*.step;*.stpz|Other files (*.*)|*.*"
	oFileDlg.InitialDirectory = FolderName
	oFileDlg.CancelError = True
	oFileDlg.MultiSelectEnabled = True
	
	Try
		oFileDlg.ShowOpen()
		selectedfile = oFileDlg.FileName
	Catch
		Return  'operation was cancelled by the user
	End Try
	AddReferences(doc, selectedfile)
End Sub
Public Sub AddReferences(ByVal odoc as Inventor.Document, ByVal selectedfile As String)
	Dim oleReference As ReferencedOLEFileDescriptor
	If selectedfile.Contains("|") Then ' we have multiple files selected.
		Dim file As String() = selectedfile.Split("|")
		For Each s as String in file
			oleReference = odoc.ReferencedOLEFileDescriptors _
				.Add(s, OLEDocumentTypeEnum.kOLEDocumentLinkObject)
			oleReference.BrowserVisible = True
			oleReference.Visible = False
			oleReference.DisplayName = Mid$(s, InStrRev(s, "\") + 1)
		Next
	Else
		oleReference = odoc.ReferencedOLEFileDescriptors _
				.Add(selectedFile,OLEDocumentTypeEnum.kOLEDocumentLinkObject)
		oleReference.BrowserVisible = True
		oleReference.Visible = False
		oleReference.DisplayName = Mid$(selectedFile, InStrRev(selectedFile, "\") + 1)
	End If
End Sub

Depending on the version of Vault you have, you can also go further.

 

Please let me know if the above rule helps.

 

Regards,

 

Alex.

philip1009
Advisor
Advisor

Good timing @AlexFielder, I had your post ready to reference here after I get more context from @Anonymous.

https://forums.autodesk.com/t5/inventor-customization/ilogic-insert-ole-object-problem/td-p/5446246

Anonymous
Not applicable

Hi @philip1009,

 

thnx for answering.

No, i don't wanna control content of document. Just to attach created copy of renamed template PDF checklist document.

 

And yes, i wanna just as you sad...


@philip1009 wrote:

... a rule that checks if there's an attached PDF matching the same name as the document, and if none exists copy a PDF from a template matching the drawing name and attaching it?



In PDF document are information about how to manufacture this component/assembly, welding procedures, coatings...etc...etc...

 

So, workflow is like this:

1. user creates drawing based on part/assembly,

2. Vault is naming it to D###### (for example D000123),

3. User is manually activating iLogic rule,

4. iLogic rule prechecks is there any PDF already attached in active document. If he finds it than rule does nothing,

5. same ilogic creates copy of template PDF checklist (CL-D000000) located on fixed location (for example C:\Vault\Libraries\Checklist\),

5. same iLogic rule rename copy of PDF checklist to match drawing name but add prefix to it "CL-" (for example CL-D000123 ),

6. same iLogic rule link that generated, renamed PDF checklist document to active drawing document.

 

And that's it :slightly_smiling_face:

 

Hi @AlexFielder,

 

thnx for the code. I will definitely try to use some part of yours code :slightly_smiling_face:

Vault is Workgroup. I am thinking in the future, maybe, to use Job Processor and custom job to do that in some lifecycle state. For now i will first try to use iLogic

 

Thnx,

 

Goran

0 Likes

philip1009
Advisor
Advisor

You can certainly set something up in Vault to do this work automatically.  You can also setup Vault to double check document properties among other things during a life-cycle change to make sure all the necessary info is filled out correctly:

https://knowledge.autodesk.com/support/vault-products/learn-explore/caas/CloudHelp/cloudhelp/2018/EN...

 

I'll come up with an iLogic sample when I have enough time and post it here unless someone else beats me to it.

 

EDIT:  You can also have the iLogic rule automatically trigger based on specific events instead of having to run the rule manually.  For example, you'd run a rule like this either whenever the document is open or before the document gets saved.

0 Likes