Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Variant Class / CreateWorkspaceFromWorkdesk Method
Name of new workspace
Original workdesk
Path to the template file (*.hxwst).
Example
In This Topic
    CreateWorkspaceFromWorkdesk Method
    In This Topic
    Create a new workspace from workdesk. Workdesk must be opened (See Open)
    Syntax
    public Workspace CreateWorkspaceFromWorkdesk( 
       string name,
       Workdesk workdesk,
       string templatePath
    )

    Parameters

    name
    Name of new workspace
    workdesk
    Original workdesk
    templatePath
    Path to the template file (*.hxwst).

    Return Value

    Derived workspace
    Exceptions
    ExceptionDescription
    The object is in invalid state. Obtain a new one.

    Internal error of HpD or HpD API.

    IMPORTANT: Throwing this exception changes HpD Api's state to Failed.

    This operation was denied because of your license.
    Argument is invalid. The exception is thrown when a wrong argument is passed to the method or the setter of property.
    Argument is null.
    This file was not found.
    The exception that is thrown when the file has the wrong extension.
    You can not perform this action on a document opened as read only.
    Workspace with this name already exists.
    Remarks

    Original workdesk is NOT deleted.

    New workspace has the same content inside as the original workdesk.

    Example
    // API is a singleton.
    HpdApi api = HpdApi.GetInstance();
    
    // Initialize API and load HpD.
    api.Init();
    
    // Open a project.
    Project project = api.OpenProject("path to my project");
    
    // Open a variant.
    // Let's assume there is only one variant in the project, so we simply pick it.
    Variant variant = project.GetVariants().FirstOrDefault();
    
    // Find a workdesk with name "MyWorkdesk".
    // For simplicity let us assume we know for sure that workdesk with this name does exist.
    Workdesk workdesk = variant.GetWorkdesks().Where(n => n.Name == "MyWorkdesk").FirstOrDefault();
    
    // Workdesk must be opened.
    workdesk.Open(false, false);
    
    // Create new workspace.
    Workspace newWorkspace = variant.CreateWorkspaceFromWorkdesk("New workspace name", workdesk);
    
    // Close the workdesk.
    workdesk.Close();
    
    // Save the project.
    project.Save();
    See Also