コード例 #1
0
//################################################################################################
    public string Get_Project()
    {
        try
        {
            // Read selected Eplan project Path
            //==========================================
            Eplan.EplApi.ApplicationFramework.ActionManager oMngr         = new Eplan.EplApi.ApplicationFramework.ActionManager();
            Eplan.EplApi.ApplicationFramework.Action        oSelSetAction = oMngr.FindAction("selectionset");
            string sProjektT = "";
            if (oMngr != null)
            {
                Eplan.EplApi.ApplicationFramework.ActionCallingContext ctx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
                ctx.AddParameter("TYPE", "PROJECT");
                bool sRet = oSelSetAction.Execute(ctx);

                if (sRet)
                {
                    ctx.GetParameter("PROJECT", ref sProjektT);
                }
                //MessageBox.Show("Project: " + sProjektT);
            }
            return(sProjektT);
        }
        catch
        { return(""); }
    }
コード例 #2
0
        public void SyncAndSave(bool saveDescrSilentMode = true)
        {
            if (currentProject != null && ProjectDataIsLoaded)
            {
                String        strAction = "LoadDescriptionAction";
                ActionManager oAMnr     = new ActionManager();
                Eplan.EplApi.ApplicationFramework.Action oAction =
                    oAMnr.FindAction(strAction);
                ActionCallingContext ctx = new ActionCallingContext();

                if (oAction != null)
                {
                    ctx.AddParameter("loadFromLua", "no");
                    oAction.Execute(ctx);
                }

                strAction = "SaveDescriptionAction";
                oAction   = oAMnr.FindAction(strAction);
                if (oAction != null)
                {
                    ctx.AddParameter("silentMode",
                                     saveDescrSilentMode ? "yes" : "no");
                    oAction.Execute(ctx);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Export to pdf with filter "Для печати" and scheme "SIA"
        /// </summary>
        private void ExportToPdf(string projectName)
        {
            // Scheme of marking export
            string exportType     = "PDFPROJECTSCHEME";
            string exportScheme   = "SIA";
            string exportFileName = $"d:\\Work\\PDF\\{ projectName }_{ DateTime.Now.Year }.{ DateTime.Now.Month }.{ DateTime.Now.Day }.pdf";
            // Action
            string strAction = "export";

            // Export a project in pdf format

            ActionManager oAMnr = new ActionManager();

            Eplan.EplApi.ApplicationFramework.Action oAction = oAMnr.FindAction(strAction);
            if (oAction != null)
            {
                // Action properties
                ActionCallingContext ctx = new ActionCallingContext();

                ctx.AddParameter("TYPE", exportType);
                ctx.AddParameter("EXPORTSCHEME", exportScheme);
                ctx.AddParameter("EXPORTFILE", exportFileName);
                // ctx.AddParameter("USEPAGEFILTER", "1");

                bool bRet = oAction.Execute(ctx);
                if (bRet == false)
                {
                    DoWireMarking.DoWireMarking.MassageHandler("Error in Action - ExportToPdf");
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Export to dwg with filter "Для печати" and scheme "SIA DWG"
        /// </summary>
        private void ExportToDwg()
        {
            // Scheme of marking export
            string exportType = "DWGPROJECT";
            //string exportScheme = "SIA";
            string exportPath = @"d:\Work\DWG\";
            // Action
            string strAction = "export";

            // Export a project in DXF / DWG format
            ActionManager oAMnr = new ActionManager();

            Eplan.EplApi.ApplicationFramework.Action oAction = oAMnr.FindAction(strAction);
            if (oAction != null)
            {
                // Action properties
                ActionCallingContext ctx = new ActionCallingContext();

                ctx.AddParameter("TYPE", exportType);
                // ctx.AddParameter("EXPORTSCHEME", exportScheme);
                ctx.AddParameter("DESTINATIONPATH", exportPath);
                //ctx.AddParameter("USEPAGEFILTER", "1");

                bool bRet = oAction.Execute(ctx);
                if (bRet == false)
                {
                    DoWireMarking.DoWireMarking.MassageHandler("Error in Action - ExportToDwg");

                    DoWireMarking.DoWireMarking.MassageHandler(ctx.ToString());
                    DoWireMarking.DoWireMarking.MassageHandler(ctx.GetParameters().ToString());
                    DoWireMarking.DoWireMarking.MassageHandler(ctx.GetStrings().ToString());
                }
            }
        }
コード例 #5
0
        public static void Execute(string xmlExportFileName)
        {
            // Scheme of marking export
            string config_scheme = "Маркировка проводов для Partex без обратного адреса XML";
            // Action
            string        strAction = "label";
            ActionManager oAMnr     = new ActionManager();
            Action        oAction   = oAMnr.FindAction(strAction);

            if (oAction != null)
            {
                // Action properties
                ActionCallingContext ctx = new ActionCallingContext();

                ctx.AddParameter("CONFIGSCHEME", config_scheme);
                ctx.AddParameter("LANGUAGE", "??_??");
                ctx.AddParameter("DESTINATIONFILE", @"$(TMP)\" + xmlExportFileName);

                bool bRet = oAction.Execute(ctx);
                if (bRet == false)
                {
                    DoWireMarking.DoWireMarking.MassageHandler(strAction);
                }
            }
            // Debug info
            Debug.WriteLine(@"-----------------");
            Debug.WriteLine(@"-------NEW-------");
            Debug.WriteLine(@"-----------------");
            Debug.WriteLine(@"$(TMP)\" + xmlExportFileName);
        }
コード例 #6
0
    private void ToggleDesignMode()
    {
        Eplan.EplApi.ApplicationFramework.ActionManager mgr = new Eplan.EplApi.ApplicationFramework.ActionManager();

        Eplan.EplApi.ApplicationFramework.Action act = mgr.FindAction("XGedActionToggleConstructionMode");
        if (act != null)
        {
            Eplan.EplApi.ApplicationFramework.ActionCallingContext ictx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
            act.Execute(ictx);
        }
    }
コード例 #7
0
    private void Copy()
    {
        Eplan.EplApi.ApplicationFramework.ActionManager mgr = new Eplan.EplApi.ApplicationFramework.ActionManager();

        Eplan.EplApi.ApplicationFramework.Action act = mgr.FindAction("XGedStartInteractionAction");
        if (act != null)
        {
            Eplan.EplApi.ApplicationFramework.ActionCallingContext CopyCtx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
            CopyCtx.AddParameter("Name", "XMIaClipboardCopy");
            act.Execute(CopyCtx);
        }
    }
コード例 #8
0
        public void MyFunctionAsAction()
        {
            string        strAction = "AutoTune";
            ActionManager oAMnr     = new ActionManager();

            Eplan.EplApi.ApplicationFramework.Action oAction = oAMnr.FindAction(strAction);
            if (oAction != null)
            {
                ActionCallingContext ctx = new ActionCallingContext();
                bool bRet = oAction.Execute(ctx);
            }
        }
コード例 #9
0
        private void OnPostOpenProject(IEventParameter iEventParameter)
        {
            //Если нет активного проекта, считываем описание и работаем с ним.
            if (EProjectManager.GetInstance().GetCurrentPrj() == null)
            {
                //Получение текущего проекта.
                Eplan.EplApi.HEServices.SelectionSet selection =
                    new Eplan.EplApi.HEServices.SelectionSet();
                selection.LockSelectionByDefault = false;
                selection.LockProjectByDefault   = false;

                EProjectManager.GetInstance().SetCurrentPrj(
                    selection.GetCurrentProject(true));

                String        strAction = "LoadDescriptionAction";
                ActionManager oAMnr     = new ActionManager();
                Eplan.EplApi.ApplicationFramework.Action oAction =
                    oAMnr.FindAction(strAction);
                ActionCallingContext ctx = new ActionCallingContext();

                if (oAction != null)
                {
                    oAction.Execute(ctx);
                }

                strAction = "ShowTechObjectsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна редактора.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_obj_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowDevicesAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна устройств.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_dev_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowOperationsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна операций.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_oper_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                // Проект открыт, ставим флаг в изначальное состояние.
                EProjectManager.isPreCloseProjectComplete = false;
            }
        }
コード例 #10
0
    public void Action(string rootPath, string schemeName, string fileName, string tempFile, string projectPropertyLabelingScheme)
    //public void Action()
    {
        /*
         * It is not possible in EPLAN scripting to "read" or "get" project properties. This requires API.
         *
         * As workaround, we create a labeling scheme based on Table of Contents, which scheme will only output
         * a single value to a file, which is the property that we want to use as the "new folder" name.
         *
         * Said scheme must exist in EPLAN before this script can perform.
         *
         */

        ActionManager oMngr = new Eplan.EplApi.ApplicationFramework.ActionManager();

        Eplan.EplApi.ApplicationFramework.Action oSelSetAction = oMngr.FindAction("selectionset");
        Eplan.EplApi.ApplicationFramework.Action oLabelAction  = oMngr.FindAction("label");

        //Verify if actions were found
        if (oSelSetAction == null || oLabelAction == null)
        {
            MessageBox.Show("Could not obtain actions");
            return;
        }

        //ActionCallingContext is used to pass "parameters" into EPLAn Actions
        ActionCallingContext ctx = new ActionCallingContext();

        //Using the "selectionset" Action, get the current project path, used later by labeling action
        ctx.AddParameter("TYPE", "PROJECT");
        bool sRet = oSelSetAction.Execute(ctx);

        string sProject = "";

        if (sRet)
        {
            ctx.GetParameter("PROJECT", ref sProject);
        }
        else
        {
            MessageBox.Show("Could not obtain project path");
            return;
        }

        tempFile = string.Format(@"{0}\{1}", rootPath, tempFile);

        //MessageBox.Show(string.Format("{0}\r\n{1}\r\n{2}\r\n{3}\r\n", rootPath, schemeName, fileName, tempFile));

        //Create a new ActionCallingCOntext to make sure we start with an empty one,
        //and then call the labeling action to obtain the desired project value,
        //which gets written to a temporary file.
        ctx = new ActionCallingContext();
        ctx.AddParameter("PROJECTNAME", sProject);
        ctx.AddParameter("CONFIGSCHEME", projectPropertyLabelingScheme);
        ctx.AddParameter("LANGUAGE", "en_US");
        ctx.AddParameter("DESTINATIONFILE", tempFile);
        oLabelAction.Execute(ctx);

        //Now read the temp file, and read the property that was writen to it by the labeling function.
        //Note: Which property gets written to the temp file is determined in the selected labeling scheme settings

        string[] tempContent = File.ReadAllLines(tempFile);
        File.Delete(tempFile);

        //Verify if file had content
        if (tempContent.Length == 0)
        {
            MessageBox.Show("Property file was empty");
            return;
        }

        string projectProperty = tempContent[0];

        //Verify if value is valid
        if (string.IsNullOrEmpty(projectProperty))
        {
            MessageBox.Show("Could not obtain property value from file");
            return;
        }

        string outputPath = string.Format(@"{0}\{1}\{2}", rootPath, projectProperty, fileName);

        //Create a new ActionCallingCOntext to make sure we start with an empty one,
        //and then call the labeling action to obtain the desired labeling output
        //to the desired folder.
        ctx = new ActionCallingContext();
        ctx.AddParameter("PROJECTNAME", sProject);
        ctx.AddParameter("CONFIGSCHEME", schemeName);
        ctx.AddParameter("LANGUAGE", "en_US");
        ctx.AddParameter("DESTINATIONFILE", outputPath);
        oLabelAction.Execute(ctx);
    }