static void Main(string[] args) { if (args.Length != 2 || args[0] == "-h") { PrintUsage(); return; } List <string> filesToParse = new List <string>(); List <string> meshTitles = new List <string>(); if (!ParseIndexFile(args[0], ref filesToParse, ref meshTitles)) { Console.WriteLine("Couldn't read index file"); return; } if (filesToParse.Count != meshTitles.Count) { Console.WriteLine("Something amiss: Had different number of files than mesh names. Maybe the index file specified is malformed?"); Console.WriteLine("Num Files: " + filesToParse.Count + ", Num Mesh Names: " + meshTitles.Count); return; } SldWorks.SldWorks swApp = new SldWorks.SldWorks(); List <string> xmlTags = new List <string>(); try { for (int i = 0; i < filesToParse.Count; i++) { SldWorks.ModelDoc2 doc = OpenDoc(swApp, filesToParse[i]); if (doc == null) { Console.WriteLine("Null Doc: " + filesToParse[i]); Console.WriteLine("Check that the index file specified is properly formed."); } else { MassPropertySet mpSet = GetMassPropertiesFromDoc(doc); xmlTags.AddRange(GenerateXMLTags(meshTitles[i], mpSet)); /* It makes the most sense to close the solidworks document at this point... * but for some reason that was giving errors... maybe something about lazy loading? * So instead we leave them all open until we are done with them */ // doc.Close(); } } } catch { Console.WriteLine("Problem while reading from solidworks files"); } swApp.ExitApp(); swApp = null; Console.WriteLine("Outputting to xacro"); OutputToXacroFile(args[1], xmlTags); }
internal static void Dispose() { if (swApp != null) { swApp.ExitApp(); swApp = null; } }
static void Main(string[] args) { SldWorks.SldWorks swApp; swApp = new SldWorks.SldWorks(); swApp.ExitApp(); swApp = null; }