solidworks+pdm二次开发
时间: 2023-12-14 08:33:39 浏览: 233
solidworks PDM是一款用于管理和控制Solidworks CAD文件的软件,它提供了许多功能,如版本控制、协作、审批、工作流等。而二次开发则是在PDM的基础上进行开发,以满足特定的需求。以下是solidworks PDM二次开发的一些常见操作:
1. 使用PDM API进行二次开发
```vb.net
Dim vault As IEdmVault5 = New EdmVault5()
Dim login As Boolean = vault.Login("VaultAdmin", "password", "Vault1")
If login Then
Dim folder As IEdmFolder5 = vault.GetFolderFromPath("C:\PDM\NewFolder")
If folder IsNot Nothing Then
Dim newFolder As IEdmFolder5 = folder.AddFolder(Nothing, "NewSubFolder")
If newFolder IsNot Nothing Then
Console.WriteLine("New folder created successfully!")
End If
End If
End If
```
2. 使用PDM add-in进行二次开发
```vb.net
Public Class MyAddIn
Implements IEdmAddIn5
Private vault As IEdmVault5
Public Sub OnCmd(ByRef poCmd As EdmCmd, ByRef ppoData As Array) Implements IEdmAddIn5.OnCmd
If poCmd.meCmdType = EdmCmdType.EdmCmd_Menu Then
If poCmd.mlCmdID = 1 Then
Dim folder As IEdmFolder5 = vault.GetFolderFromPath("C:\PDM\NewFolder")
If folder IsNot Nothing Then
Dim newFolder As IEdmFolder5 = folder.AddFolder(Nothing, "NewSubFolder")
If newFolder IsNot Nothing Then
MsgBox("New folder created successfully!")
End If
End If
End If
End If
End Sub
Public Sub OnConnect(ByVal poVault As EdmVault5) Implements IEdmAddIn5.OnConnect
vault = poVault
End Sub
Public Sub OnDisconnect() Implements IEdmAddIn5.OnDisconnect
vault = Nothing
End Sub
End Class
```
3. 使用PDM Task进行二次开发
```vb.net
Public Class MyTask
Implements IEdmAddIn5
Private vault As IEdmVault5
Public Sub OnCmd(ByRef poCmd As EdmCmd, ByRef ppoData As Array) Implements IEdmAddIn5.OnCmd
' do nothing
End Sub
Public Sub OnConnect(ByVal poVault As EdmVault5) Implements IEdmAddIn5.OnConnect
vault = poVault
End Sub
Public Sub OnDisconnect() Implements IEdmAddIn5.OnDisconnect
vault = Nothing
End Sub
Public Sub OnTaskRun(ByVal poVault As EdmVault5, ByVal poTask As EdmTask, ByVal hJob As Long) Implements IEdmAddIn5.OnTaskRun
Dim folder As IEdmFolder5 = vault.GetFolderFromPath("C:\PDM\NewFolder")
If folder IsNot Nothing Then
Dim newFolder As IEdmFolder5 = folder.AddFolder(Nothing, "NewSubFolder")
If newFolder IsNot Nothing Then
poTask.SetTaskResult(EdmTaskResult.EdmTaskResult_Success)
Else
poTask.SetTaskResult(EdmTaskResult.EdmTaskResult_Failure)
End If
Else
poTask.SetTaskResult(EdmTaskResult.EdmTaskResult_Failure)
End If
End Sub
End Class
```
阅读全文