bsj0526
Mechanical
- Jan 5, 2008
- 40
Hello,
I am trying to write a macro that will help speed up the process of constantly saving drawings as dxf's for the machine shop. Here is what I have so far:
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim CPM As SldWorks.CustomPropertyManager
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set CPM = Part.Extension.CustomPropertyManager("")
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
Dim MyRevVal As String
Dim MyRevValEvaluated As String
CPM.Get2 "Revision", MyRevVal, MyRevValEvaluated
FilePath = Part.GetPathName & Revision
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)
NewFilePath = PathNoExtension & MyRevValEvaluated & "dxf"
Part.SaveAs2 NewFilePath, 0, True, False
MsgBox "File Exported " & NewFilePath
End Sub
I have two problems.
1) It exports the file as "filename.RevDXF
File name being the drawing's name and the revision being the custom property value. Obviously the "." needs to be 3 characters over to the right.
2) The macro gives the dxf the revision of the drawing file, not the part. When we rev a part, we update the revision of the part file, not the drawing. I would like the macro to get the revision from the part file or one of the drawing views.
Any help is greatly appreciated.
I am trying to write a macro that will help speed up the process of constantly saving drawings as dxf's for the machine shop. Here is what I have so far:
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim CPM As SldWorks.CustomPropertyManager
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set CPM = Part.Extension.CustomPropertyManager("")
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
Dim MyRevVal As String
Dim MyRevValEvaluated As String
CPM.Get2 "Revision", MyRevVal, MyRevValEvaluated
FilePath = Part.GetPathName & Revision
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)
NewFilePath = PathNoExtension & MyRevValEvaluated & "dxf"
Part.SaveAs2 NewFilePath, 0, True, False
MsgBox "File Exported " & NewFilePath
End Sub
I have two problems.
1) It exports the file as "filename.RevDXF
File name being the drawing's name and the revision being the custom property value. Obviously the "." needs to be 3 characters over to the right.
2) The macro gives the dxf the revision of the drawing file, not the part. When we rev a part, we update the revision of the part file, not the drawing. I would like the macro to get the revision from the part file or one of the drawing views.
Any help is greatly appreciated.