I need some help in a bad way. I have a macro that will save a part as a DXF if certain conditions are true. My problem is the way that this macro sets the file name. I have to save my part in a certain folder in order this macro to work which is not the way I need it to work. I need a way to take this parth
D:\Storage\DBWorks\TestPart.SLDPRT
and extract this
TestPart.SLDPRT - or just this - Testpart.
I need to be able to do this automatically, no matter what directory the part is located in.
Will one you you guys help me out. I am no expert by any strech of the imaginatyion. My macro is posted below. It will not work in your version of solidworks because you do not have the add-in, I even covered up my library name so as to not revela too much,but I am sure someone will still be able to help me out.
Declare Sub ExportDXFFile Lib "???????" (ByVal fname As String, ByVal tname As String)
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Sub main()
Dim FileName As String Dim FileNameNoExt As String Dim DrwPathName As String Dim DxfPathName As String Dim Nested As String
Set swApp = CreateObject("SldWorks.Application") Set swModel = swApp.ActiveDoc
ModelPathName = swModel.GetPathName
'parts can only be stored in this location - D:\Storage\DBWorks\TestPart.SLDPRT 'the -19 removes the file path and just leaves the file name 'will not work in another directory unless the -19 is changed FileName = Right(ModelPathName, Len(ModelPathName) - 19)
'takes the file name TestPart.SLDPRT and removes the extension and 'just leaves - TestPart. FileNameNoExt = Left(FileName, Len(FileName) - 6)
'establishes the path and the file name for the dxf DxfPathName = "C:\Documents and Settings\DHales\Desktop\" + FileNameNoExt + "dxf"
'exportdxffile is part of the library that i have as an add-in 'this is the location of the drawing template used to insert the flat pattern of the part 1:1 'and then save the dxf ExportDXFFile DxfPathName, "Y:\DBWORKS_SERVER\PAR\FlatPattern_FullScale.DRWDOT"
End Sub