Getting the views from a ViewSheetSet takes forever!

Getting the views from a ViewSheetSet takes forever!

hzamani
Advocate Advocate
1,122 Views
8 Replies
Message 1 of 9

Getting the views from a ViewSheetSet takes forever!

hzamani
Advocate
Advocate

Hi there,

 

I'm making a simple call to the Views property of a ViewSheetSet and each sheet set is taking around 1.5 seconds to return the views! Is this normal? Any workaround to get the views quicker?

 

viewset.jpg

0 Likes
1,123 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

Sounds like a lot of time to me.

 

You might want to share a complete minimal reproducible case so other people can check what you are doing:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 9

hzamani
Advocate
Advocate

Thanks Jeremy,

 

Created a repo here: https://github.com/HossZamani/RevitAPISamples/tree/master/FetchingViewsOfViewSheetSets

 

This is a result I'm getting on my machine:

 

sample.jpg

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Thank you for the sample code.

 

I integrated it into The Building Coder samples release 2020.0.148.3 to test it for you:

 

https://github.com/jeremytammik/the_building_coder_samples/compare/2020.0.148.2...2020.0.148.3

 

It took a long time to update to 2020 and save and produced six warnings that I could ignore.

 

I cannot reproduce the extremely long times that you report:

  

ViewSheetSet.Views Benchmark.png

   

 Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 9

hzamani
Advocate
Advocate

Thanks Jeremy. I tested this on Revit 2018, 2019 & 2020 (with latest bug fix installed) using different files and I'm still getting the same slow results I have been getting. These results are from a computer which I'm remote-desktopping into (vpn & remote connection). Could this have anything to do with how fast Revit can process some API calls?

 

Strangely, I tested this directly (without using remote desktop) on two different computers and the results are fine.

I'll investigate this further and will get back if I can find the problem.

0 Likes
Message 6 of 9

hzamani
Advocate
Advocate

@jeremytammik Today I tested this on the same computer(A) in three different scenarios:

 

1- Opening Revit locally on computer(A) : Average loop iteration ~60ms

2- Using another computer(B) on the same local network to remote desktop into the target computer(A) and running Revit on computer(A): Average loop iteration ~400ms

3- Using a computer(C) 30km away from computer(A), to connect to computer(A) using vpn and remote desktop and running Revit on computer(A): Average loop iteration ~1800ms

 

How weird is that? 

0 Likes
Message 7 of 9

jeremytammik
Autodesk
Autodesk

You have unusually lazy electrons.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 9

hzamani
Advocate
Advocate

Yep. Weird that they are lazy only for this specific property.

0 Likes
Message 9 of 9

RPTHOMAS108
Mentor
Mentor

ViewSet can be enumerated directly without calling .GetEnumerator, it implements IEnumerable and .GetEnumerator is the required method to implement that.

 

There is a GetForwardIterator which seems to return a RevitAPI specific object i.e. IEnumerable doesn't require the implementation of a method called GetForwardIterator. So I don't know what that was added specifically for?

 

My experience is that if you've recently opened/printed views then those return quicker than ones you haven't.

 

0 Likes