MostafaElAyoubi / Data-shapes

code for revit, dynamo
50 stars 12 forks source link

Error with rect = activeUIView.GetWindowRectangle() in UI.MultipleInputForm ++ #21

Closed clicketyclackety closed 7 years ago

clicketyclackety commented 7 years ago

Full error message : Traceback (most recent call last): File "<string>", Line 775 in <module> IndexError: index out of range: 0

772 #Positionning the form at top left of current view
773 uiviews = uidoc.GetOpenUIViews()
774 activeviewid = doc.ActiveView.Id
775 activeUIView = [v for v in uiviews if v.ViewId == activeviewid][0]
776 rect = activeUIView.GetWindowRectangle()
777 form.StartPosition = FormStartPosition.Manual
778 form.Location = Point(rect.Left-7,rect.Top)

I've tried re-writing it a little and can get it to stop giving me the error message by eliminating line 775 and condensing some parts, however my UI box then does not seem to inherit any dimensions and looks very squished, although still admittedly usable. I don't quite understand what I'm doing but I hope this helps.

772 #Positionning the form at top left of current view
773 uiviews = uidoc.GetOpenUIViews()
774 rect = uiviews[0].GetWindowRectangle()
775 form.StartPosition = FormStartPosition.Manual
776 form.Location = Point(rect.Left-7,rect.Top)
MostafaElAyoubi commented 7 years ago

Hi @clicketyclackety , thanks for reporting this. What versions of Revit / Dynamo are you using? And do you have a 4k monitor?

clicketyclackety commented 7 years ago

I work across Revit 15/16/17 and I just tried every single one of them now and it worked perfectly, but Revit 15 was the one causing me grief with the error earlier. I'm not using a 4K monitor but I am using something similar, 2x 1920x1080 monitors rotated to portrait. Like this > [][].

andydandy74 commented 7 years ago

Interesting, I had the same error the other day, but only once. I couldn't reproduce it after restarting Dynamo. I have a 34" screen with a resolution of 3440x1440 px. @clicketyclackety Does this happen with every graph or only with specific files?

clicketyclackety commented 7 years ago

Hey @andydandy74 I think it only tends to happen with one very specific script. I can't recall it happening with other scripts. but this script requires an axo and a floor plan to be open at the same time wheras other ones don't have any specific requirements.

MostafaElAyoubi commented 7 years ago

What that part of the code does is look for the active window in revit so it can position the UI form at the top left. If the last window that was clicked on in revit is the project browser or the properties panel, It might cause that kind of issue. @andydandy74 , does the form show op correctly on your 4k screen ? I never could test it myself .

andydandy74 commented 7 years ago

@MostafaElAyoubi yeah, no problems with that. @clicketyclackety will the error occur if you remove everything but the nodes that generate the form?

andydandy74 commented 7 years ago

@MostafaElAyoubi: You could filter out the project browser and system browser by querying the view's type (using GetTypeId()) - it'll return null/None.

MostafaElAyoubi commented 7 years ago

@andydandy74 Yes I'll do that. It will most definitely solve the first part of the issue. Now I'm not sur what might cause the "squished" form ..

clicketyclackety commented 7 years ago

That's probably just from my meddling @MostafaElAyoubi !

MostafaElAyoubi commented 7 years ago

Okay I just updated the package (2017.05.15) . This issue should be solved with this fix.