async 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";
string writePath2 = $@"{Folder_Path}\{guid}.scr";
MgCoordinateSystemFactory coordSysFactory = new MgCoordinateSystemFactory();
MgCoordinateSystemCatalog csCatalog = coordSysFactory.GetCatalog();
MgCoordinateSystemDictionary csDict = csCatalog.GetCoordinateSystemDictionary();
MgCoordinateSystemEnum csDictEnum = csDict.GetEnum();
int csCount = csDict.GetSize();
using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8))
{
export_file.WriteLine(@"(command ""MAPCSLIBRARYEXPORT""");
export_file.Close();
export_file.Dispose();
}
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)
{
using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8))
{
string csNameStr = csName.ToString();
await export_file.WriteLineAsync($@"""{csNameStr}""" + " " + $"\"{CS_value}\"");
}
}
}
string space = " ";
using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8))
{
export_file.Write(" " + $@"""{space}""" + " " + $@"""{CS_Agree}""" +" " + @"""""" + ")");
export_file.Close();
export_file.Dispose();
}
using (StreamWriter export_file2 = new StreamWriter(writePath2, true, Encoding.UTF8))
{
export_file2.Write("(load "+ $@"""C:\\Users\\GeorgKeneberg\\Documents\\Temp\\LOG\\{guid}.lsp"")");
export_file2.Write("_QUIT");
export_file2.Close();
export_file2.Dispose();
}
System.Diagnostics.Process.Start($@"""C:\Program Files\Autodesk\AutoCAD 2021\accoreconsole.exe"" /s ""{writePath2}""");
}