Yes, you can achieve this using the transmission data:
Here are some old notes from another case on closing worksets and unloading links when opening model:
Q: Can worksets be closed or links unloaded programmatically without actually opening the RVT model?
A developer asks: System memory is hitting the limit. My Add-in does not need the Revit Links to be loaded to be able to function. Can I somehow open the RVT file with
- (1) all worksets closed or
- (2) all RVT links unloaded
to save system memory? Is there a way to achieve this in the APS design automation activity command line?
A: I have two samples demonstrating how to open a RVT file with worksets closed / RVT links unloaded, but I haven’t migrated them to DA4R.
Q: Just to confirm - you change this on the fly, you do not need to save the file for not loading those on next load? by mean if you need to load the file to change the settings for the next load, that does not help. So is it for next time, or does it disable loading on the fly? I ask, because the comment says 'next time': This method will set all Revit links to be unloaded the next time the document at the given location is opened.
A: the command to open the model with worksets closed just sets a property in the OpenOptions SetOpenWorksetsConfiguration. it then calls OpenAndActivateDocument to open the model with worksets closed. so, this is only valid for the lifetime of the OpenOptions and the open call needs to be executed immediately. The command to not load links is different: for that, an option is set and stored in the model transmission data using TransmissionData.WriteTransmissionData. In that case, the option will be remembered and applied next time an open is performed. in the sample command, an open follows immediately. however, it could also be executed later, and the setting would be retained. So, the two methods can both be used to disable loading on the fly, provided the caller does the opening. I hardly think the workset config option can be controlled in this manner by the default design automation environment. However, in DA, the file to open could be passed in as payload, and the DA add-in could implement the call to open the file itself, couldn't it?
... I spent some time to verify if the changes remain in the file after closing Revit. As said, TransmissionData.WriteTransmissionData will store the link unload state in the RVT file. But, if a customer wants to keep workset state, they must call Document#SaveAs to save the changes made.