Autodesk Community Tips- ADNオープン
Autodesk Community Tipsではちょっとしたコツ、やり方、ショートカット、アドバイスやヒントを共有しています。
ソート順:
質問 Inventor iLogicで現在開いているファイルがVaultに登録されているかを知る方法はありますか。 回答 Inventor iLogicからVaultのAPIを用いて、Vaultのチェックイン状態を確認することが可能です。   Vaultでのチェックイン状態を知るためには、対象のファイルのVualtのフォルダ構造のパス情報を用いてDocumentService.FindLatestFilesByPaths()メソッドを利用します。     以下は、現在Inventorで開いているファイルおよびその参照ファイルがVaultに登録されているかを確認し、Vaultに登録されていない場合は、iLogicのログにファイルのパスを出力するサンプルコードとなります。   なお、サンプルコードではわかりやすさを優先して、1ファイルずつDocumentService.FindLatestFilesByPaths()メソッドを実行していますが、 DocumentService.FindLatestFilesByPaths()メソッドには複数のパス情報を配列として指定可能なため、パフォーマンスを考慮した場合には、まとめて実行することをお勧めいたします。     ◆iLogicのファイルヘッダ AddReference "Autodesk.Connectivity.WebServices.dll" Imports AWS = Autodesk.Connectivity.WebServices AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll" Imports VDF = Autodesk.DataManagement.Client.Framework AddReference "Connectivity.Application.VaultBase.dll" Imports VB = Connectivity.Application.VaultBase AddReference "Autodesk.DataManagement.Client.Framework"   ・ iLogicソース  Sub Main() Dim conn As VDF.Vault.Currency.Connections.Connection conn = VB.ConnectionManager.Instance.Connection If conn Is Nothing Then MessageBox.Show("Vaultにログインしていません。") Return End If Dim rootFolder As String rootFolder = conn .WorkingFoldersManager.GetWorkingFolder("$/").FullPath For Each doc As Inventor.Document In ThisDoc.Document.AllReferencedDocuments If (FindFileInVault(doc.FullFileName, rootFolder, conn)) Then Else Logger.Trace("{0} is not checked in to Vault ", doc.FullFileName) End If Next End Sub Public Function FindFileInVault(localfilePath As String, workingfolder As String, conn As VDF.Vault.Currency.Connections.Connection) As Boolean Dim VaultPath As String = localfilePath.Replace(workingfolder, "$/") VaultPath = VaultPath.Replace("\", "/") Dim VaultPaths() As String = New String() {VaultPath} Dim wsFiels() As AWS.File = conn.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths) If wsFiels(0).Id <> -1 Then Return True End If Logger.Trace("localfilePath is {0}", localfilePath) Logger.Trace("VaultPath={0}, id={1}", VaultPath, wsFiels(0).Id) Return False End Function  
記事全体を表示