Issue

When updating Vault file properties with Update-VaultFile or $vaultExplorer.UpdatFileProperties in a powerEvents event AutoCAD crashes.


Cause

This is caused because some assemblies are loaded from multiple locations by powerVault since AutoCAD 2021.


Solution


One possible workaround is to temporarily change the Vault client installation directory in the registry so powerVault isn't loading libraries from multiple locations. The below wrapper function Update-VaultFileAutoCAD can be used to replace your Update-VaultFile calls.


  • In C:\ProgramData\coolOrange\powerEvents\Modules create a new file AutoCAD_Crash_Workaround.psm1 with the following content
function Update-VaultFileAutoCAD {
  param (
    [string]$File,
    [string]$Comment,
    [string]$Category,
    [string]$Status,
    [string]$LifecycleDefinition,
    [string]$Revision,
    [string]$RevisionDefinition,
    [Hashtable]$Properties,
    [string[]]$AddChilds,
    [string[]]$Childs,
    [string[]]$RemoveChilds,
    [string[]]$AddAttachments,
    [string[]]$Attachments,
    [string[]]$RemoveAttachments
  )
  $someFileInVaultAddinDirectory = ([Autodesk.Connectivity.WebServicesTools.WebServiceManager]).Assembly
  $vaultClientExeVersion = $someFileInVaultAddinDirectory.GetName().Version.ToString(2)
  $vaultClientExeLocation = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Autodesk\PLM\Autodesk Vault Professional $vaultClientExeVersion\").Executable
  Set-ItemProperty "HKLM:\SOFTWARE\Autodesk\PLM\Autodesk Vault Professional $vaultClientExeVersion\" -Name 'Executable' -Value ($someFileInVaultAddinDirectory.Location)
  
  $update = Update-VaultFile -File $File -Comment $Comment -Category $Category -Status $Status `
                 -LifecycleDefinition $LifecycleDefinition -Revision $Revision -RevisionDefinition $RevisionDefinition `
                 -Properties $Properties -AddChilds $AddChilds -Childs $Childs -RemoveChilds $RemoveChilds `
                 -AddAttachments $AddAttachments -Attachments $Attachments -RemoveAttachments $RemoveAttachments

  Set-ItemProperty "HKLM:\SOFTWARE\Autodesk\PLM\Autodesk Vault Professional $vaultClientExeVersion\" -Name 'Executable' -Value $vaultClientExeLocation
}


  • Afterwards you need to replace your calls to Update-VaultFile with the new Update-VaultFileAutoCAD function in every script that will run during an AutoCAD checkin. 


Example

If your script looks like this:

Register-VaultEvent -EventName AddFile_Post -Action 'PostAddFile'
function PostAddFile($file, $parentFolder, $dependencies, $attachments, $fileBom, $successful) {
  Update-VaultFile -File $file._FullPath -Properties @{
    'Description' = 'Pen'
    'Engineer' = 'Me'
    'Fruits' = 'Tomato'
  }
}

It will look like this afterwards:

Register-VaultEvent -EventName AddFile_Post -Action 'PostAddFile'
function PostAddFile($file, $parentFolder, $dependencies, $attachments, $fileBom, $successful) {
  Update-VaultFileAutoCAD -File $file._FullPath -Properties @{
    'Description' = 'Pen'
    'Engineer' = 'Me'
    'Fruits' = 'Tomato'
  }
}