Hi all, I'm trying to find out if a model is workshared. My code works for Revit 2018 but does not for Revit 2019, 2020, and 2021.
Every time I get to this line, the program throws an error which i cant figure out why:
An exception of type 'Autodesk.Revit.Exceptions.InvalidOperationException' occurred in RevitAPI.dll but was not handled in user code
Additional information: This Document is not a workshared document.
It should only be reading the property and return a boolean but instead crashes.
So far, I've restarted my computer and crawled the web but haven't found any relating posts or bugs for 2019, 2020, or 2021.
public virtual Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document;
bool isWorkSharedBool = doc.IsWorkshared;
if (isWorkSharedBool == true) { // <---- ERROR HERE
Debug.WriteLine("The Model is work shared");
}
}
Has anyone run into this issue before?
Solved! Go to Solution.
Solved by naveen.kumar.t. Go to Solution.
Looks like you're right. There is nothing wrong with the code. I tried it this morning, and now it works.
🤷
That was odd.
Can't find what you're looking for? Ask the community or share your knowledge.