You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SolidWorks VBA宏保存文件至PDM Vault时的数据卡异常问题求助

SolidWorks VBA宏保存PDM Vault文件的问题

我正在开发一款SolidWorks VBA宏,用于在PDM Vault中命名并保存新模型。该宏使用内置的SaveAs3方法,支持用户选择三种保存选项:另存为、另存为副本并继续和另存为副本并打开。

遇到的问题

  • 保存完成后,PDM数据卡不会像常规保存那样自动弹出,我认为这与后续更严重的问题相关。
  • 用户填写以此方式保存的文件的数据卡并检入后,数据卡中的所有数据会丢失。而检出文件、重新填写数据卡并再次检入,数据则能正常保留。

测试用精简代码

Option Explicit

Const newModelName As String = "C:\VaultName\FolderName\ModelName.SLDPRT"
Const tipo As Long = swDocPART 'swDocASSEMBLY

'This option changes depending on which test I want to run. I switch between them commenting one or the other.
Const opzioni As Long = swSaveAsOptions_Copy
'Const opzioni As Long = swSaveAsOptions_CopyAndOpen

Sub main()
    
    UserForm1.Show
    
End Sub

Sub SalvaNuovoCodice()

    Dim swApp As SldWorks.SldWorks
    Dim swModel As ModelDoc2
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel.SaveAs3(newModelName, swSaveAsCurrentVersion, opzioni) = 0 Then

        'If I use the option swSaveAsOptions_Copy and I want to open the file after the save I use the line below. In this test version I just comment it if I don't need it.
        Set swModel = swApp.OpenDoc(newModelName, tipo)
        
    Else
    
        MsgBox "Il salvataggio non è andato a buon fine."
        
    End If

End Sub

已尝试的排查

我曾尝试检查文件在Vault中的锁定状态,但未找到解决方案。我怀疑内置的SaveAs3方法在保存文件至Vault时存在问题,这很奇怪,因为PDM Vault与SolidWorks出自同一厂商。我已在官方论坛提问,但未得到回复。

内容的提问来源于stack exchange,提问作者Enrico Calzolai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 18:22:43