MostafaElAyoubi / Data-shapes

code for revit, dynamo
50 stars 12 forks source link

Suggestion: Improve performance of setviewforelement function in MultiInputForm++ #37

Closed andydandy74 closed 1 year ago

andydandy74 commented 6 years ago

Hi Mostafa, I recently used a ListView to display a list of annotation elements on a fairly large project and noticed that it took MultiInputForm a looong time to find an appropriate view. Is there any particular reason you're not using the UIDocument.ShowElements method? http://www.revitapidocs.com/2018.1/52ac2a55-1397-3d05-311f-de3443421ae6.htm Using it, I can reduce setviewforelement to this:

def setviewforelement(self, sender, event):    
    item = sender.GetItemAt(event.X,event.Y).Text
    element = UnwrapElement(sender.Values[item])
    uidoc.ShowElements(element)

This seems to vastly improve performance on my end.

MostafaElAyoubi commented 6 years ago

Hi @andydandy74 , I did experience some of that trouble too. Thank you very much for the improvement suggestion, I will try it out and publish it ASAP.

MostafaElAyoubi commented 6 years ago

Hi Andreas, I am doing some package updating and I wanted to seize the opportunity to implement your code. But I noticed that the element is almost always "hilighted" in the general 3D view. Does it behave the same on your side?

andydandy74 commented 5 years ago

Sorry for not replying earlier. In my experience this command will basically take the easiest path. If the object is "visible" in the active view (i.e. within the scope of the active view which doesn't necessarily mean that it may not be occluded by other objects) the active view will be used. So yeah, it might not always be ideal. If you're not happy with this approach, I could think of an alternative for 2D elements, though: Check if the element has an OwnerView attribute and if that attribute isn't null use the OwnerView. That would be far less computationally heavy for 2D elements at least.

MostafaElAyoubi commented 5 years ago

Okay well I did multiple researches and couldn't find anything better .. I'm implementing your suggestion thanks a lot Andreas!! :) (done in version 2019.2.7 of the package)