Hi all,
So I wrote up this macro last year to convert bulk drawings into PDFs and since upgrading to 2015 it doesn't work. Any chance someone could have a quick look and tell me whats wrong with it or a better way to do this? It's only a tiny bit of code. It doesn't get an error or anything I run it and it just doesn't do anything.
Thanks,
Tom.
<p>using SolidWorks.Interop.sldworks;</p><p>using SolidWorks.Interop.swconst;</p><p>using System.Runtime.InteropServices;</p><p>using System;</p><p>using System.IO;</p><p></p><p></p><p>namespace PDF.csproj</p><p>{</p><p> public partial class SolidWorksMacro</p><p> {</p><p></p><p></p><p></p><p></p><p> public void Main()</p><p> {</p><p> string pdfPath;</p><p> string Path = "C:\\\\Solidworks\\\\05-Portable Safety Barriers\\\\13-T Lok Screen 5.4m";</p><p> string txtPath = Path + "\\\\UpdatedPDFs.txt";</p><p> //string Date = DateTime.Now.ToShortDateString();</p><p> string[] drwPaths = System.IO.Directory.GetFiles(Path, "*.SLDDRW", SearchOption.AllDirectories);</p><p> foreach (string s in drwPaths)</p><p> {</p><p> if (!s.Contains("~\\\$"))</p><p> {</p><p> ModelDoc2 swDoc = null;</p><p> int longstatus = 0;</p><p> int longwarnings = 0;</p><p> pdfPath = s;</p><p> pdfPath = pdfPath.Replace("Drawings", "PDFs").Replace("SLDDRW", "PDF");</p><p> (new FileInfo(pdfPath)).Directory.Create();</p><p> swDoc = ((ModelDoc2)(swApp.OpenDoc6(s, 3, 1, "", ref longstatus, ref longwarnings)));</p><p> longstatus = swDoc.SaveAs3(pdfPath, 0, 0);</p><p> swDoc = null;</p><p> swApp.CloseAllDocuments(true);</p><p> }</p><p> }</p><p> //System.IO.File.WriteAllText(txtPath, Date);</p><p> }</p><p></p><p></p><p> /// <summary></p><p> /// The SldWorks swApp variable is pre-assigned for you.</p><p> /// </summary></p><p> public SldWorks swApp;</p><p> }</p><p>}</p>SolidworksApi macros