/// <summary> /// Node GetListOfMAPCSLIBRAR for export to LSP file naming of coordinate systems (user or system) /// </summary> /// <param name="CS_value">Name of type "CoordinateSystem"</param> /// <param name="selection">If false - exporting only User's definitions; if true - exporting only system definitions</param> /// <param name="CS_Agree">Permit to add other associated definitions</param> /// <param name="Folder_Path">Directory path to save LSP file</param> public static void GetPartOfMAPCSLIBRARY(string Folder_Path, string CS_value, string CS_Agree, bool selection) { var guid = Guid.NewGuid(); string writePath = $@"{Folder_Path}\{guid}.lsp"; StringBuilder sb = new StringBuilder(); MgCoordinateSystemFactory coordSysFactory = new MgCoordinateSystemFactory(); MgCoordinateSystemCatalog csCatalog = coordSysFactory.GetCatalog(); MgCoordinateSystemDictionary csDict = csCatalog.GetCoordinateSystemDictionary(); MgCoordinateSystemEnum csDictEnum = csDict.GetEnum(); int csCount = csDict.GetSize(); sb.AppendLine(@"(command ""MAPCSLIBRARYEXPORT"""); MgStringCollection csNames = csDictEnum.NextName(csCount); string csName = null; MgCoordinateSystem cs = null; bool csProtect; for (int i = 0; i < csCount; i++) { csName = csNames.GetItem(i); cs = csDict.GetCoordinateSystem(csName); csProtect = cs.IsProtected(); if (csProtect == selection) { sb.AppendLine($@"""{csName}""" + " " + $"\"{CS_value}\""); } } string space = " "; sb.AppendLine(" " + $@"""{space}""" + " " + $@"""{CS_Agree}""" + " " + @"""""" + ")"); using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8)) { export_file.Write(sb.ToString()); } }
/// <summary> /// Node GetCSList returns an external txt file that Contains strings with CS's names /// </summary> /// <param name="Folder_Path">Directory path to save TXT file</param> /// <param name="selection">If = true, export all CS in Library, if false - only Users collection</param> public static string GetCSList(string Folder_Path, bool selection) { StringBuilder sb = new StringBuilder(); var guid = Guid.NewGuid(); string writePath = $@"{Folder_Path}\{guid}CS_List.txt"; MgCoordinateSystemFactory coordSysFactory = new MgCoordinateSystemFactory(); MgCoordinateSystemCatalog csCatalog = coordSysFactory.GetCatalog(); MgCoordinateSystemDictionary csDict = csCatalog.GetCoordinateSystemDictionary(); MgCoordinateSystemEnum csDictEnum = csDict.GetEnum(); int csCount = csDict.GetSize(); MgStringCollection csNames = csDictEnum.NextName(csCount); string csName = null; MgCoordinateSystem cs = null; bool csProtect; for (int i = 0; i < csCount; i++) { csName = csNames.GetItem(i); cs = csDict.GetCoordinateSystem(csName); csProtect = cs.IsProtected(); if (csProtect == selection) { sb.AppendLine(csName.ToString()); } } using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8)) { export_file.Write(sb.ToString()); } return(writePath); }