Skip to content

Commit

Permalink
updated iLogic-Vault snippets to include new methods and options
Browse files Browse the repository at this point in the history
updated iLogic-Vault snippets to support 2022 changes
added sample rules for iLogic-VaultInventorServer
  • Loading branch information
koechlm committed May 28, 2022
1 parent c450232 commit 40a04b3
Show file tree
Hide file tree
Showing 17 changed files with 1,394 additions and 62 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Sub Main
mFileList += vbCr & mFile
Next
Logger.Info("iLogic-Vault file search found: " & mFileList)
Logger.Info("iLogic-Vault file search finished.")
End If

End Sub
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<Name>iLogic-VaultInventorServer Header</Name>
<ToolTip>Add required references</ToolTip>
<Index>6001</Index>
<Code><![CDATA[AddReference "QuickstartiLogicVltInvSrvLibrary.dll"
<Code>
<![CDATA[AddReference "QuickstartiLogicVltInvSrvLibrary.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
]]></Code>
]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
Expand All @@ -19,8 +21,8 @@ AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
<Index>6002</Index>
<Code>
<![CDATA[ 'get the job processor's Vault connection (note - this is different from Inventor Application)
Dim ex As Exception
Dim iLogicVault As New QuickstartiLogicVltInvSrvLibrary.iLogicVltInvSrvLibrary
Dim ex as Exception
Dim iLogicVault As New QuickstartiLogicVltInvSrvLibrary.iLogicVltInvSrvLibrary
Dim LoggedIn As Boolean
Dim FileState As String
Try
Expand All @@ -30,37 +32,44 @@ AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
userId = RuleArguments("UserId")
SessionId = RuleArguments("SessionId")
LoggedIn = iLogicVault.ReuseConnection(dbServer, fServer, vltName, userId, SessionId)
If LoggedIn = False Then
Logger.Error("Rule could not re-use Job Processor's Vault Login.")
Throw ex
End If
Catch
Logger.Error("Failed Reading Rule Arguments.")
Throw ex
End Try
If LoggedIn = False
Logger.Error("Rule could not re-use Job Processor's Vault Login.")
Throw ex
End If]]></Code>
]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
<Name>Get Vault File by FullFilePath</Name>
<ToolTip>Downloads Vault file Using full File Path, e.g. "$/Designs/Base.ipt". Returns full File name In local working folder (download enforces override, If local File exists),
Preset Options: Download Children (recursively) = Enabled, Enforce Overwrite = True'
Optionally check-out the file; preset: check-out = false</ToolTip>
<ToolTip>
Downloads Vault file Using full File Path, e.g. "$/Designs/Base.ipt". Returns full File name In local working folder (download enforces override, If local File exists),
Preset Options: Download Children (recursively) = Enabled, Enforce Overwrite = True'
Optionally check-out the file; preset: check-out = false
</ToolTip>
<Index>6003</Index>
<Code><![CDATA[Dim mVaultFile As String = iLogicVault.GetFileByFullFilePath("$/") 'add ..., True) to enable check-out of downloaded file.
<Code>
<![CDATA[Dim mVaultFile As String = iLogicVault.GetFileByFullFilePath("$/") 'add ..., True) to enable check-out of downloaded file.
If mVaultFile Is Nothing Then
Logger.Error("Vault file not found - Please double check that file exists in Vault.")
ElseIf mVaultFile.Count > 0 Then
''add next action using the downloaded file here, e.g. Component.Replace("Part1:1", mVaultFile, True)
End If]]></Code>
End If]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
<Name>Get Vault File by Search</Name>
<ToolTip>Search Vault file using 1 to n property/value pairs; returns full local file name in working folder</ToolTip>
<Index>6004</Index>
<Code><![CDATA['Build one to many name/value pairs of Property/Value as search criteria
<Code>
<![CDATA['Build one to many name/value pairs of Property/Value as search criteria
Dim mSearchParams As New System.Collections.Generic.Dictionary(Of String, String) 'add UDP.DisplayName, Value Pairs
mSearchParams.Add("Part Number", "001002")
mSearchParams.Add("Title", "Back Side Cover")
Expand All @@ -74,14 +83,16 @@ End If]]></Code>
Else
Logger.Info("File " & mVaultFile & " found by search and downloaded to local workspace.")
'add next action using the downloaded file here, e.g. Component.Replace("Part1:1", mVaultFile, True)
End If]]></Code>
End If]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
<Name>Check Vault File(s) Exist by Search</Name>
<ToolTip>Search Vault files using 1 to n property/value pairs; returns list of file names and shares logger info</ToolTip>
<Index>6005</Index>
<Code><![CDATA['Build one to many name/value pairs of Property/Value as search criteria;
<Code>
<![CDATA['Build one to many name/value pairs of Property/Value as search criteria;
Dim mSearchParams As New System.Collections.Generic.Dictionary(Of String, String) 'add UDP.DisplayName, Value Pairs
mSearchParams.Add("Part Number", "001003")
mSearchParams.Add("Title", "Back Side Cover")
Expand All @@ -97,14 +108,16 @@ ElseIf mVaultFiles.Count > 0 Then
mFileList += mFile & vbCr
Next
Logger.Info("iLogic-Vault file search found: " & mFileList)
End If]]></Code>
End If]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
<Name>Get Thumbnail from Vault by Search as Image File</Name>
<ToolTip>Searches for a source file to extract the thumbnail of and downloads it as JPG file</ToolTip>
<Index>6006</Index>
<Code><![CDATA['Build one to many name/value pairs of Property/Value as search criteria
<Code>
<![CDATA['Build one to many name/value pairs of Property/Value as search criteria
Dim mSearchParams As New System.Collections.Generic.Dictionary(Of String, String) 'add UDP.DisplayName, Value Pairs
mSearchParams.Add("Part Number", "001002") 'applies to file 001002.ipt
mSearchParams.Add("Title", "Back Side Cover") 'applies to file 001002.ipt and to file 001068.iam
Expand All @@ -116,20 +129,23 @@ If mImageFile Is Nothing Then
Else
''add next action using the downloaded file here...
End If]]></Code>
End If]]>
</Code>
</CodeSnippet>
<CodeSnippet>
<Category>iLogicVaultInventorServer</Category>
<Name>Get Thumbnail from Vault by Full File Path as Image File</Name>
<ToolTip>Extracts thumbnail from source file and downloads it as JPG file</ToolTip>
<Index>6007</Index>
<Code><![CDATA[Dim mImageFile As String = iLogicVault.GetThumbnailFileByFullSourceFilePath("$/Designs/Inventor Sample Data/Fishing Rod Model/001002.ipt", 254, 254)
<Code>
<![CDATA[Dim mImageFile As String = iLogicVault.GetThumbnailFileByFullSourceFilePath("$/Designs/Inventor Sample Data/Fishing Rod Model/001002.ipt", 254, 254)
If mImageFile Is Nothing Then
Logger.Error("Could not convert thumbnail to image file - Please double check that file exists in Vault including a thumbnail.")
Else
''add next action using the downloaded file here...
End If]]></Code>
End If]]>
</Code>
</CodeSnippet>
</Snippets>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'DISCLAIMER:
'---------------------------------
'In any case, code, templates, and snippets of this solution are of "work in progress" character.
'Neither Markus Koechl, nor Autodesk represents that these samples are reliable, accurate, complete, or otherwise valid.
'Accordingly, those configuration samples are provided “as is” with no warranty of any kind and you use the applications at your own risk.

Sub Main
break 'prepared for step by step debugging
'some insights on the job's iLogic settings
Logger.Info("----------------------- this job's iLogic settings ------------------------------------")
For Each mDir As String In iLogicVb.Automation.FileOptions.ExternalRuleDirectories
Logger.Info("iLogic External Rule Directories: " & mDir)
Next
Logger.Info("iLogic Addin DLLs Directory: " & iLogicVb.Automation.FileOptions.AddinDirectory)
Logger.Info("iLogic Loglevel set by Vault Job: " & iLogicVb.Automation.LogControl.Level)
Logger.Info("--------------------------------------------------------------------------------------------")

'insights on rule arguments that optionally may publish all Vault properties of the processed file
Logger.Info("----------------------- Rule Arguments published by Vault Job ----------------")
Dim mArgs As NameValueMap = RuleArguments.Arguments
If mArgs.Count > 0 Then
For i = 1 To mArgs.Count
Logger.Info(mArgs.Name(i) & ": " & mArgs.Value(mArgs.Name(i)))
Next
End If
Logger.Info("--------------------------------------------------------------------------------------------")

'Note - Vault Inventor Server uses a subset of the Inventor API. Use the Inventor Server object istead of Inventor Application.
Dim mInvSrv As InventorServer = ThisServer

'access the active document like you do in Inventor application rules
Dim oDoc As Document = ThisDoc.Document
Dim oAsmDoc As AssemblyDocument
Dim oPrtDoc As PartDocument
Dim eDocumentType As Inventor.DocumentTypeEnum = oDoc.DocumentType
Dim oParams As Inventor.Parameters

If eDocumentType = DocumentTypeEnum.kPartDocumentObject Then
oPartDoc = oDoc
oParams = oPartDoc.ComponentDefinition.Parameters
Logger.Info("----------------------- Parameters published by Vault Job ----------------")
For Each oParam As Object In oParams
Logger.Info("Parameter: " & oParam.Name & "; Expression: " & oParam.Expression)
Next
Logger.Info("----------------------- Parameters published by Vault Job ----------------")
End If

'use known iLogic syntax and snippets in job processor rules like you do in Inventor application rules
iProperties.Value("Custom", "DateTimeStamp") = "JobProcessorTestRuleSuccess: " & DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")

End Sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
AddReference "QuickstartiLogicVltInvSrvLibrary.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
'DISCLAIMER:
'---------------------------------
'In any case, code, templates, and snippets of this solution are of "work in progress" character.
'Neither Markus Koechl, nor Autodesk represents that these samples are reliable, accurate, complete, or otherwise valid.
'Accordingly, those configuration samples are provided “as is” with no warranty of any kind and you use the applications at your own risk.

Sub Main
break 'prepared for step by step debugging
'to enable iLogicVault commands reuse the job processor's user connection
Dim iLogicVault As New QuickstartiLogicVltInvSrvLibrary.iLogicVltInvSrvLibrary
Dim LoggedIn As Boolean
Dim FileStateName As String
Try
dbServer = RuleArguments("ServerName")
fServer = RuleArguments("ServerName")
vltName = RuleArguments("VaultName")
userId = RuleArguments("UserId")
SessionId = RuleArguments("SessionId")
LoggedIn = iLogicVault.ReuseConnection(dbServer, fServer, vltName, userId, SessionId)
If LoggedIn = False
Dim ex As New Exception
Logger.Error("Rule could not re-use Job Processor's Vault Login.")
Throw ex
Exit Sub
End If
FileStateName = RuleArguments("File.State (Historical)")
Catch
End Try


'some insights on the job's iLogic settings
Logger.Info("----------------------- this job's iLogic settings ------------------------------------")
For Each mDir As String In iLogicVb.Automation.FileOptions.ExternalRuleDirectories
Logger.Info("iLogic External Rule Directories: " & mDir)
Next
Logger.Info("iLogic Addin DLLs Directory: " & iLogicVb.Automation.FileOptions.AddinDirectory)
Logger.Info("iLogic Loglevel set by Vault Job: " & iLogicVb.Automation.LogControl.Level)
Logger.Info("--------------------------------------------------------------------------------------------")

'insights on rule arguments that optionally may publish all Vault properties of the processed file
Logger.Info("----------------------- Rule Arguments published by Vault Job ----------------")
Dim mArgs As NameValueMap = RuleArguments.Arguments
If mArgs.Count > 0 Then
For i = 1 To mArgs.Count
Logger.Info(mArgs.Name(i) & ": " & mArgs.Value(mArgs.Name(i)))
Next
End If
Logger.Info("--------------------------------------------------------------------------------------------")

'Note - Vault Inventor Server uses a subset of the Inventor API. Use the Inventor Server object istead of Inventor Application.
Dim mInvSrv As InventorServer = ThisServer

'access the active document like you do in Inventor application rules
Dim oDoc As Document = ThisDoc.Document

'use known iLogic syntax and snippets in job processor rules like you do in Inventor application rules
iProperties.Value("Custom", "DateTimeStamp") = "JobProcessorTestRuleSuccess: " & DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")

End Sub



Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
AddReference "QuickstartiLogicVltInvSrvLibrary.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
'DISCLAIMER:
'---------------------------------
'In any case, code, templates, and snippets of this solution are of "work in progress" character.
'Neither Markus Koechl, nor Autodesk represents that these samples are reliable, accurate, complete, or otherwise valid.
'Accordingly, those configuration samples are provided “as is” with no warranty of any kind and you use the applications at your own risk.

Sub Main
break 'step debugging using Visual Studio

'don't run rules for AnyCAD components.
If ThisDoc.Document.FullFileName.Contains("*LocalDocs*") = True Then
Exit Sub
End If

Dim oAssyDoc As Inventor.AssemblyDocument
Dim oAssyCompDef As Inventor.AssemblyComponentDefinition
Dim oBom As Inventor.BOM
Dim oBomView As Inventor.BOMView
Dim oBomRow As Inventor.BOMRow


oDoc = ThisDoc.Document
If oDoc.DocumentType = kAssemblyDocumentObject Then
oAssyDoc = oDoc
oAssyCompDef = oAssyDoc.ComponentDefinition
End If
oBom = oAssyCompDef.BOM
oBom.StructuredViewEnabled = True
oBom.StructuredViewFirstLevelOnly = False

'get the job processor's Vault connection (note - this is different from Inventor Application)
Dim ex As Exception
Dim iLogicVault As New QuickstartiLogicVltInvSrvLibrary.iLogicVltInvSrvLibrary
Dim LoggedIn As Boolean
Dim FileState As String
Try
dbServer = RuleArguments("ServerName")
fServer = RuleArguments("ServerName")
vltName = RuleArguments("VaultName")
userId = RuleArguments("UserId")
SessionId = RuleArguments("SessionId")
LoggedIn = iLogicVault.ReuseConnection(dbServer, fServer, vltName, userId, SessionId)
If LoggedIn = False
Logger.Error("Rule could not re-use Job Processor's Vault Login.")
Throw ex
End If
Catch ex
Logger.Error("Failed Reading Rule Arguments.")
Throw ex
End Try



Dim mInvBomSettings As String = iLogicVault.GetFileByFullFilePath("$/Templates/Settings/InventorBomSettingsPDMC-Sample.xml")
If mInvBomSettings Is Nothing Then
Logger.Error("Vaulted BOM settings file not found - Please double check that file exists in Vault.")
Throw ex
End If

Try
oBom.ImportBOMCustomization(mInvBomSettings)

oBomView = oBom.BOMViews.Item("Structured")
For Each oBomRow In oBomView.BOMRows
oBomRow.ItemNumberLocked = True
Next

Catch ex
Logger.Error("Something went wrong while enabling BOM Structured View.")
Throw ex 'for Job Processing: the rule should not return success in case of failure
End Try
End Sub
Loading

0 comments on commit 40a04b3

Please sign in to comment.