In Eplan P8 we have what is called the “Design Mode”. It is useful to copy or move objects relative to a specific point of origin. In order to understand why this mode can be useful, let’s examine what “Normal Mode” is.

When Design Mode is not enabled, any copy or move command will be made relative to the insertion point of the selected component. In some cases this might not be what we want. For example, a Black Box will be copied relative to its insertion point, which is normally in the upper left corner. But what if we want to copy a black box and align it with the center of another Black Box like this:

DesignMode

In this case the Design Mode, along with the Object Snap option will come in handy.

The annoying part about Design Mode is that if you forget to turn it off, and then try to do a Normal Mode copy and paste operation, you will paste the last component selected in Design Mode instead of the one you just selected, and that’s simply because Eplan is still waiting for you the define the “handle” of the copy operation when you are in fact trying to paste. In other words, it didn’t get a chance to complete the copy operation, so it still has the before last object in the clipboard. You will notice this text in the STatus Bar at the bottom of the Graphical Editor:

DefineHandle

In any case, even seasoned Eplan user get bitten by this once in a while, so I decided to write this little script that defines two actions. One is the Normal Mode copy, and the other is the Design Mode copy. Both will work in the desired mode regardless of the current Design Mode state.

Here’s the script:

/*
Copyright (c) 2013 STLM Inc.
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
 
public class STLMCopy
{
    //Add the two actions as menu points under Utilities
    [DeclareMenu()]
    public void CopyNormalMenu()
    {
	Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
        oMenu.AddMenuItem("Copy (Normal Mode)", "NormalCopyAction");
        oMenu.AddMenuItem("Copy (Design Mode)", "DesignCopyAction");
    }
 
    //Declare the action to force copy in normal mode
    [DeclareAction("NormalCopyAction")]
    public void NormalCopyAction()
    {
	bool toggled = false;
 
        if (DesignModeState)
        {
            ToggleDesignMode();
            toggled = true;
        }
 
        Copy();
 
        if (toggled)
            ToggleDesignMode();
    }
 
    //Declare the action to force copy in design mode
    [DeclareAction("DesignCopyAction")]
    public void DesignCopyAction()
    {
        bool toggled = false;
 
        if (!DesignModeState)
        {
            ToggleDesignMode();
            toggled = true;
        }
 
        Copy();
 
        if (toggled)
            ToggleDesignMode();
    }
 
    //Helper functions and properties
 
    private bool DesignModeState
    {
	get
	{
		return new Eplan.EplApi.Base.Settings().GetBoolSetting("USER.GedViewer.ConstructionMode", 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);
        }
    }
 
    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);
    	}
    }
 
}

Once loaded this script will create two new entries under the Utilities menu. Optionally you could assign shortcut keys to the new Actions, or even assign them to custom toolbar buttons.

To use it, make sure you select the objects you want to copy first (this is because of a weird issue in Eplan), and select the desired Action, either Normal Mode Copy or Design Mode Copy.

The script will always revert the Design Mode to the state it was prior to calling the script.

Enjoy !