Could someone please point me in the right direction.
I want to use the PDM Task tool to Convert SaveAs a sldprt with a specific naming syntax. (The sample they give is called Convert, I want to do what convert does, but save as a sldprt)
The default convert task does not have an option to convert to sldprt.
I have a working Macro that I typically use myself, and I'm trying to modify it to work with the PDM Task tool. By using the Task Tool I'm hoping to automate this action when transitioning to a specific State in PDMpro.
What I want is to be able to run the task on .sldprt files, and for it to save them out to a predefined location (C:\EXPORTS) with a predefined naming syntax. This is to help automate preparing files to be placed in our separate document control system and coordinate all the names to follow the same structure by removing human error.
Example:
Original Name = AB12345.sldprt
After State Transition the Task runs and a new File is saved to C:\EXPORTS as = AB12345 - REV2.sldprt
I'm using PDMpro & SolidWorks 2018 SP5
This is how I'm trying to create the Task. I selected the General task user interface type, and paste my macro here.
The following is what I used in the script box but it does not seem to be working:
SolidworksApi/macrosDim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim FileType As String
Dim Rev As String
Dim FilePath As String
Dim FileName As String
Dim NameSize As Long
Dim NameNoExtension As String
Dim NewFileName As String
Dim FileLocation As String
Dim boolstatus As BooleanSub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc'Check if file is open
If Not swModel Is Nothing Then
FileTyp = swModel.GetType
'Check if Drawing and gather info
If FileTyp <> swDocDRAWING Then
Rev = swModel.CustomInfo2(strConfigName, "Revision")
FilePath = swModel.GetPathName
FileName = swModel.GetTitle()
NameSize = Strings.Len(FileName)
NameNoExtension = Strings.Left(FileName, NameSize - 7)
'File name syntax and extension type here
NewFileName = NameNoExtension & " - REV " & Rev & ".SLDPRT"
'Set static folder location here
FileLocation = "C:\EXPORTS"'Save As
If Len(FileLocation) Then
boolstatus = swModel.SaveAs3(FileLocation & "\" & NewFileName, 0, 2)
End If
End If
End If
End Sub