forked from Codered741/iLogic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck Vault for File.iLogicVB
More file actions
171 lines (113 loc) · 5.85 KB
/
Copy pathCheck Vault for File.iLogicVB
File metadata and controls
171 lines (113 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
'Check for file in Vault
'https://forums.autodesk.com/t5/inventor-customization/search-vault-to-see-if-a-part-exists/td-p/8786941
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
Sub Main()
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oDocIt As VDF.Vault.Currency.Entities.FileIteration = GetVaultFile(oDoc.FullFileName, mVltCon)
DownloadAssembly(oDocIt, mVltCon)
' Dim DwgName As String
' If FindDrawingFilePN(oDoc) = "" Then
' MsgBox("Drawing not found in WIP")
' DwgName = oDoc.FullFileName
' If oDoc.DocumentType = kPartDocumentObject Then
' DwgName = DwgName.Replace(".ipt", ".dwg")
' Else If oDoc.DocumentType = kAssemblyDocumentObject Then
' DwgName = DwgName.Replace(".iam", ".dwg")
' Else
' Msgbox("Please run from part or assembly")
' Exit Sub
' End If
' CheckVault(DwgName)
' Else
' Msgbox("File found in WIP")
' End If
End Sub 'Main
Function GetVaultFile(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection) As VDF.Vault.Currency.Entities.FileIteration
VaultPath = VaultPath.Replace("C:\_vaultWIP\", "$/")
'flip the slashes
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
GetVaultFile = New VDF.Vault.Currency.Entities.FileIteration(mVltCon,wsFiels(0))
End Function 'GetVaultFile
Sub CheckVault(VaultPath As String, mVltCon As VDF.Vault.Currency.Connections.Connection)
VaultPath = VaultPath.Replace("C:\_vaultWIP\", "$/")
'flip the slashes
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() = New String() {VaultPath}
Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn,wsFiels(0))
Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileLifecycleInfo = mFileIt.LifecycleInfo
VStatus = lifeCycleInfo.StateName
If VStatus = "Work In Progress" OrElse VStatus ="Released" OrElse VStatus ="Quick-Change"
MessageBox.Show("Part is in Vault" & vbCrLf & "(" & VStatus & ")", "In Vault?")
Else
MessageBox.Show("Part not in Vault", "In Vault?")
End If
End Sub 'CheckVault
Function FindDrawingFilePN(PartOrAssemblyDoc As Document) As String
Dim fullFilenamePN As String
fullFilenamePN = PartOrAssemblyDoc.fullFilename
' Extract the path from the full filename.
Dim path As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
'path = Left$(fullFilenamePN, InStrRev(fullFilenamePN, "\"))
Dim iProps as PropertySet = PartOrAssemblyDoc.PropertySets.Item("Design Tracking Properties")
Dim pn = iProps.Item("Part Number")
Dim filename As String = pn.Value
' Find if the drawing exists.
Dim drawingFilename As String
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename & ".dwg")
' Check the result.
If drawingFilename = "" Then
' Find if the drawing exists.
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename & ".idw")
' Return the result.
If drawingFilename <> "" Then
Return drawingFilename
Else
Return ""
End If
Else
' Return the result.
Return drawingFilename
End If
End Function 'FindDrawingFilePN
Public Sub DownloadAssembly(topLevelAssembly As VDF.Vault.Currency.Entities.FileIteration, m_conn As VDF.Vault.Currency.Connections.Connection)
' download the latest version of the assembly to working folders
Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(m_conn)
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeParents = False
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeRelatedDocumentation = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest
settings.AddFileToAcquire(topLevelAssembly, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Dim results As VDF.Vault.Results.AcquireFilesResults
If settings.IsValidConfiguration = True Then
results = m_conn.FileManager.AcquireFiles(settings)
MsgBox("Files Acquired")
Else
MsgBox("Settings Invalid")
End If
End Sub 'DownloadAssembly
' Public Sub DownloadFile(fileIter As (fileIteration(Of VDF.Vault.Currency.Entities.FileIteration))
' ' download individual files to a temp location
' Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(m_conn)
' settings.LocalPath = New VDF.Currency.FolderPathAbsolute(ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath)
' For Each fileIter As VDF.Vault.Currency.Entities.FileIteration In fileIters
' settings.AddFileToAcquire(fileIter, _ _
' VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
' Next
' Dim results As VDF.Vault.Results.AcquireFilesResults = _
' m_conn.FileManager.AcquireFiles(settings)
' End Sub 'DownloadFiles