GetWorksetConfiguration Method


Revit Link Options Get Workset Configuration Method

Gets the set of worksets to open when creating the link.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 27.0.4.0 (27.0.4.0)
Syntax
public WorksetConfiguration GetWorksetConfiguration()

Return Value

WorksetConfiguration
Example
C#
public bool CreateRevitLinkWithOneWorksetOpen(Document doc, string pathName, string worksetName)
{
    FilePath path = new FilePath(pathName);
    RevitLinkOptions options = new RevitLinkOptions(true);

    // Get info on all the user worksets in the project prior to opening
    IList<WorksetPreview> worksets = WorksharingUtils.GetUserWorksetInfo(path);
    IList<WorksetId> worksetIds = new List<WorksetId>();
    // Find worksetName
    foreach (WorksetPreview worksetPrev in worksets)
    {
        if (worksetPrev.Name.CompareTo(worksetName) == 0)
        {
            worksetIds.Add(worksetPrev.Id);
            break;
        }
    }

    // close all worksets but the one specified
    WorksetConfiguration worksetConfig = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets);
    if (worksetIds.Count > 0)
    {
        worksetConfig.Open(worksetIds);
    }
    options.SetWorksetConfiguration(worksetConfig);

    LinkLoadResult result = RevitLinkType.Create(doc, path, options);
    RevitLinkType type = doc.GetElement(result.ElementId) as RevitLinkType;
    return (result.LoadResult == LinkLoadResultType.LinkLoaded);
}
See Also
ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →