API Help
EPLAN API / User Guide / API DataModel / Creating or opening projects
In This Topic
    Creating or opening projects
    In This Topic
                   

    The most important object in the Eplan.EplApi.DataModel namespace is the Project. The project must be open in EPLAN in order to work with it. In an add-in you most often will be working with the project, which the user interactively opened via the GUI. You can obtain the project currently selected by the user via the SelectionSet object which is described under the topic "Getting the current selection". 

     

    However you also might want to open or create a project in EPLAN via API -- this will definitely the case in offline programs. In order to do this and other project related tasks, the Eplan.EplApi.Datamodel namespace provides the ProjectManager Class. 

     

    To create a project, you use the CreateProject method. It takes two parameters, the full file name of the new project link file to be created and the link file of the project template. After successfully creating the project, the project is open and the method returns the new project object. 

    The following example shows, how to create a project. 

     

    C#
    Copy Code
    Project oProject = new ProjectManager().CreateProject("$(MD_PROJECTS)\Example_003.elk", "$(MD_TEMPLATES)\IEC_tpl001.ept");
    

     

    To open a project, you use the OpenProject method. Its only parameter is the full name and path of the project's link file.  

    C#
    Copy Code
    Project oProject = new ProjectManager().OpenProject("$(MD_PROJECTS)\ESS_Sample_Project.elk");
    

     

    Remarks

    In offline programs, you need to open a LockingStep, before you open or create an EPLAN project or use any other DataModel object.