-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new sample rules for AddFile() and GetVaultFileStatus()
- Loading branch information
Showing
5 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
iLogic-Vault-QuickstartLibrary/Sample Rules iLogic-Vault/iLogicVault_AddFile.iLogicVb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
AddReference "QuickstartiLogicLibrary.dll" | ||
'enable iLogicVault commands and validate user's login state | ||
break | ||
Dim iLogicVault As New QuickstartiLogicLibrary.QuickstartiLogicLib | ||
If iLogicVault.LoggedIn = False | ||
Logger.Error("Not Logged In to Vault! - Login first and repeat executing this rule.") | ||
Exit Sub | ||
End If | ||
|
||
'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 | ||
Dim oBomRowEnum As Inventor.BOMRowsEnumerator | ||
|
||
Try | ||
oDoc = ThisDoc.Document | ||
If oDoc.DocumentType = kAssemblyDocumentObject Then | ||
oAssyDoc = oDoc | ||
oAssyCompDef = oAssyDoc.ComponentDefinition | ||
End If | ||
oBom = oAssyCompDef.BOM | ||
oBom.StructuredViewEnabled = True | ||
oBom.StructuredViewFirstLevelOnly = False | ||
|
||
'secure constant item numbers | ||
oBomView = oBom.BOMViews.Item("Structured") | ||
For Each oBomRow In oBomView.BOMRows | ||
oBomRow.ItemNumberLocked = True | ||
Next | ||
|
||
Catch ex As Exception | ||
Logger.Error("Something went wrong while enabling BOM Structured View.") | ||
End Try | ||
|
||
'derive export file name from this document | ||
Dim oBOMExpFile = ThisDoc.ChangeExtension("xlsx") | ||
|
||
'enable LOD Master (BOM export is not support using other LOD) | ||
Try | ||
oAssyCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Master").Activate(True) | ||
Catch ex As Exception | ||
Logger.Error("Something went wrong while activating LOD Master") | ||
End Try | ||
|
||
'Delete existing file to avoid overwrite restrictions | ||
Dim oFileInfo As New System.IO.FileInfo(oBOMExpFile) | ||
If oFileInfo.Exists = True Then | ||
If (oFileInfo.Attributes) Then | ||
oFileInfo.Attributes = (oFileInfo.Attributes And Not oFileInfo.Attributes.ReadOnly) | ||
System.IO.File.Delete(oBOMExpFile) | ||
End If | ||
End If | ||
|
||
'create BOM export | ||
ThisBOM.Export("Structured", oBOMExpFile, kMicrosoftExcelFormat) | ||
'attach result | ||
If System.IO.File.Exists(oBOMExpFile) Then | ||
Dim mReturn As Boolean | ||
Dim mVaultPath As String = iLogicVault.ConvertLocalPathToVaultPath(oBOMExpFile) | ||
mReturn = iLogicVault.AddFile(oBOMExpFile, mVaultPath, True) | ||
Else | ||
Logger.Error("Something went wrong exporting BOM (ThisBOM.Export()") | ||
End If | ||
|
31 changes: 31 additions & 0 deletions
31
...Vault-QuickstartLibrary/Sample Rules iLogic-Vault/iLogicVault_GetVaultFileStatus.iLogicVb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
AddReference "QuickstartiLogicLibrary.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 | ||
'enable iLogicVault commands and validate user's login state | ||
Dim iLogicVault As New QuickstartiLogicLibrary.QuickstartiLogicLib | ||
If iLogicVault.LoggedIn = False | ||
Logger.Error("Not Logged In to Vault! - Login first and repeat executing this rule.") | ||
Exit Sub | ||
End If | ||
|
||
'Retrieve the active document's Vault file status as name/value pairs | ||
Dim mDocVaultStatus As New Dictionary(Of String, String) | ||
mDocVaultStatus = iLogicVault.GetVaultFileStatus(ThisDoc.PathAndFileName(True)) | ||
If mDocVaultStatus.Item("ErrorState") = "None" | ||
Logger.Info("CheckOutState = " + mDocVaultStatus.Item("CheckOutState")) | ||
Logger.Info("ConsumableState = " + mDocVaultStatus.Item("ConsumableState")) | ||
Logger.Info("ErrorState = " + mDocVaultStatus.Item("ErrorState")) | ||
Logger.Info("LocalEditsState = " + mDocVaultStatus.Item("LocalEditsState")) | ||
Logger.Info("LockState = " + mDocVaultStatus.Item("LockState")) | ||
Logger.Info("RevisionState = " + mDocVaultStatus.Item("RevisionState")) | ||
Logger.Info("VersionState = " + mDocVaultStatus.Item("VersionState")) | ||
Else | ||
Logger.Error("ErrorState = " + mDocVaultStatus.Item("ErrorState")) | ||
End If | ||
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters