pyrevitlabs/pyRevit

[Bug]: show view range - error when Levels off

RevitIRL opened this issue · 3 comments

✈ Pre-Flight checks

  • I don't have SentinelOne antivirus installed (see above for the solution)
  • I have searched in the issues (open and closed) but couldn't find a similar issue
  • I have searched in the pyRevit Forum for similar issues
  • I already followed the installation troubleshooting guide thoroughly
  • I am using the latest pyRevit Version

🐞 Describe the bug

If Levels are turned off in v/g (our default), I get an error when selecting a plan view

⌨ Error/Debug Message

Traceback (most recent call last): 
 File "C:\Users\<username>\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Toggles.panel\toggles3.stack\ViewRange.pushbutton\script.py", line 128, in context_changed 
 corners = corners_from_bb(level_bbox) 
 File "C:\Users\<username>\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Toggles.panel\toggles3.stack\ViewRange.pushbutton\script.py", line 95, in corners_from_bb 
 transform = bbox.Transform 
AttributeError: 'NoneType' object has no attribute 'Transform'

♻️ To Reproduce

  1. go to 3D view and turn off Levels in v/g
  2. click "show view range"
  3. click a plan view

⏲️ Expected behavior

It should check the status, and turn Levels on automatically (if it has to - and back off again after?), but I'd prefer it just keep the user's setting. Alternate solution would be to just notify user that Levels need to be turned on.

🖥️ Hardware and Software Setup (please complete the following information)

Microsoft Windows [Version 10.0.19045.3448]
(c) Microsoft Corporation. All rights reserved.

C:\Users\<username>>pyrevit env
==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.8.16.24121+2117" | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
==> Attachments
master | Product: "24.1" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2023.1.1" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2022.1.5" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2021.1.9" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2020.2.7" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2019.2.5" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
master | Product: "2018.3.3 Security Fix" | Engine: DEFAULT (2711) | Path: "C:\Users\<username>\AppData\Roaming\pyRevit-Master"
==> Installed Extensions
==> Default Extension Search Path
C:\Users\<username>\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
24.1 | Version: 24.1.0.66 | Build: 20230701_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2024\"
2023.1.1 | Version: 23.1.10.4 | Build: 20221122_1550(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2023\"
2022.1.5 | Version: 22.1.50.17 | Build: 20230915_1530(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2022\"
2021.1.9 | Version: 21.1.90.15 | Build: 20230907_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021\"
2020.2.7 | Version: 20.2.70.6 | Build: 20220112_1230(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020\"
2019.2.5 | Version: 19.2.50.16 | Build: 20220111_1110(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2019\"
2018.3.3 Security Fix | Version: 18.3.3.18 | Build: 20190510_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018\"
==> Running Revit Instances
PID: 38168 | 2023.1.1 | Version: 23.1.10.4 | Build: 20221122_1550(x64) | Language: 0 | Path: "C:\Program Files\Autodesk\Revit 2023"
==> User Environment
Microsoft Windows 10 [Version 10.0.19045]
Executing User: <username>
Active User:
Admin Access: No
%APPDATA%: "C:\Users\<username>\AppData\Roaming"
Latest Installed .Net Framework: 4.8
Installed .Net Target Packs: v3.5 v4.0 v4.5 v4.5.1 v4.5.2 v4.6 v4.6.1 v4.6.2 v4.7 v4.7.1 v4.7.2 v4.8 v4.X
Installed .Net-Core Target Packs: v5.0.400
pyRevit CLI v4.8.16.24121+2117.23a0b8cbc4babdeb29a0611e159d017bbe9cbad5

Additional context

No response

The script gets the bounding box of the related level, and calculates the plane's outline from it. I've also noticed that levels return None for the boundingbox if their visibility has never been tirned on. Once it is turned on it will work when it is turned off. I will add a warning about this, because cycling the visibility can be more complicated than desired.

if I turn Levels back off, I get the error again

maybe you could get the bounding box of the view instead? If it's not precisely the outline of the crop region, that's fine (i.e. it can be rectangular), but sometimes our level is huge, but the plan view is smaller

I think my proposal in #2245 (comment) will solve this issue too. As a last resort there will be a warning, red exceptions scare people 😊