Hello,
Copy this into a .cs file and run it.
You'll need to export the scheme first.
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System.Windows.Forms;
public class Class
{
[Start]
public void Function()
{
CommandLineInterpreter oCLI = new CommandLineInterpreter();
ActionCallingContext acc = new ActionCallingContext();
string strProjectnameFull = PathMap.SubstitutePath("$(P)");
///assumes scheme is in hte EPLAN default directory
string XmlPath = PathMap.SubstitutePath("$(MD_SCHEME)") + "\\";
string XmlFile = "NUnu.SchemeFile.xml";
MessageBox.Show("Full path for Scheme File:\n" + XmlPath+XmlFile);
#region Imports XML
///*****************************************************************************************************************
acc.AddParameter("XmlFile", XmlPath + XmlFile);
acc.AddParameter("Option", "OVERWRITE");
///this option is REQUIRED for project based Settings!!!
///if "Project" is not specified, IT DOES NOT WORK
acc.AddParameter("Project", strProjectnameFull);
oCLI.Execute("XSettingsImport", acc);
///*****************************************************************************************************************
#endregion Imports XML
string SchemeName;
///removes the extenion to the file
SchemeName = XmlFile.Substring(0, XmlFile.IndexOf(".xml"));
///removes the prefix of the file
SchemeName = SchemeName.Substring(XmlFile.IndexOf(".") + 1, SchemeName.Length-(XmlFile.IndexOf(".") + 1));
MessageBox.Show("Scheme Name:\n" + SchemeName);
///e.g. "NUnu.SchemeFile.xml" becomes just "SchemeFile"
///this assumes that the exported file name for the scheme was the default given by EPLAN
///PROJECT.NumerationGui.NumerationScheme.LastUsed
acc.AddParameter("set", "NumerationGui.NumerationScheme.LastUsed");
acc.AddParameter("value", SchemeName);
oCLI.Execute("XAfActionSettingProject", acc);
//PROJECT.NumerationGui.NumerationScheme.LastUsed_ToInsertMacro
acc.AddParameter("set", "NumerationGui.NumerationScheme.LastUsed_ToInsertMacro");
acc.AddParameter("value", SchemeName);
oCLI.Execute("XAfActionSettingProject", acc);
return;
} ///public void Function()
} ///public class Class
It works for me.
Regards,
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP