Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I cannot get RevitLinkType WorksetConfiguration.Close to work

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Rockit_for_Revit
610 Views, 3 Replies

I cannot get RevitLinkType WorksetConfiguration.Close to work

Hello,

I have collected the Link WorksetIds I want to close and put this into the following code.

 

objWorksetConfiguration.Close(ListOfWorksetID)
objRevitLinkType.LoadFrom(objModelPath, objWorksetConfiguration)

The Link is the same, when I run the command the link is reloaded however the Link worksets are not closed.

Any ideas?

 

Kind Regards

David

 

3 REPLIES 3
Message 2 of 4

Open worksets is working successfully.

objWorksetConfiguration.Open(lstOfWorksetIDsToOpen)

However still cannot get .close to work.

 

Kind Regards

David

 

Message 3 of 4
zhong_wu
in reply to: Rockit_for_Revit

Hi David, Interesting, I tried with one of our sample revit file(added some worksets), and open the file by the code as follow, the WorksetConfiguration.Close() method works as good as I expected. I can't reproduce the issue as you mentioned so far, maybe you can share with me the reproduce sample code and the revit files, I would be happy to check more.

 

public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
    ref string message, Autodesk.Revit.DB.ElementSet elements)
{
    // Get the application and document from external command data.
    UIApplication app = commandData.Application;

    // the list of worksets that will be closed
    List<WorksetId> wsIds = new List<WorksetId>();
    wsIds.Add(new WorksetId(0));
    wsIds.Add(new WorksetId(163));
    wsIds.Add(new WorksetId(343));
    wsIds.Add(new WorksetId(344));

    WorksetConfiguration wsConf = new WorksetConfiguration(WorksetConfigurationOption.OpenAllWorksets);
    wsConf.Close(wsIds);

    // open the file from BIM360 Docs
    ModelPath modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(new Guid("55a82cfc-680d-XXXX-bcf7-2f11837062a5"), new Guid("0e57bf28-XXXX-443c-9d10-aee9ef0d37f4"));

    OpenOptions oo = new OpenOptions();
    oo.SetOpenWorksetsConfiguration(wsConf);
        app.OpenAndActivateDocument(modelPath, oo, false);


    return Autodesk.Revit.UI.Result.Succeeded;
}

 

 

  

 


John Wu
Developer Technical Services
Autodesk Developer Network


Message 4 of 4
Rockit_for_Revit
in reply to: zhong_wu

Thank you,

If you want to modify the Worksets you must begin with WorksetConfigurationOption.CloseAllWorksets or WorksetConfigurationOption.OpenAllWorksets. This was where I was going wrong.

 

WorksetConfiguration = New WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets)

 

Kind Regards

David

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community