API returns zero revisions

API returns zero revisions

Anonymous
Not applicable
346 Views
1 Reply
Message 1 of 2

API returns zero revisions

Anonymous
Not applicable

We have an internally developed addin installed across our user base. Yesterday, a user had the addin crash. When I looked at the journal, I found that it had a line in it that said "This project has no revisions! This shouldn't happen.".

 

Here is the only place in our addin code that would produce this line. As you can see, that text is thrown if the API returns 0 revisions. But the API should never return zero revisions, right? We've never seen this issue before, but I thought it was worth mentioning in the forum, since, for whatever reason, the API did return zero revisions, even though there was definitely one revision in the project. The revision in that project has "None" for numbering scheme, and we've seen odd behavior (like you can't show a label in a titleblock for a revision that has no numbering scheme) related to that. So, maybe there's a connection. But, something is definitely not quite right if the API can return 0 revisions, right?

 

            // Users can't delete the last remaining revision, so there should always be one. Get it.
            FilteredElementCollector revs = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Revisions);
            if (revs.Count() == 0)
            {
                throw (new Exception( "This project has no revisions! This shouldn't happen." ) );
            }
            Revision rev = (Revision)revs.FirstElement();

 

0 Likes
347 Views
1 Reply
Reply (1)
Message 2 of 2

Mustafa.Salaheldin
Collaborator
Collaborator

What is the Revit API version do you use?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes