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: 

IsWorkShared bug in 2019, 2020, 2021?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Maltezc
598 Views, 2 Replies

IsWorkShared bug in 2019, 2020, 2021?

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?

Labels (1)
2 REPLIES 2
Message 2 of 3
naveen.kumar.t
in reply to: Maltezc

Hi @Maltezc ,

I checked the code and I don't see any problem with your code.

Your code is working fine.

I would suggest you create a new visual studio project and create a new dll.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
Maltezc
in reply to: Maltezc

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.

Post to forums  

Forma Design Contest


Rail Community