-
-
Notifications
You must be signed in to change notification settings - Fork 465
Add pyrevit.revit.avf — helpers for displaying values via the Analysis Visualization Framework
#3487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Wurschdhaud
wants to merge
5
commits into
pyrevitlabs:develop
Choose a base branch
from
Wurschdhaud:new-lib-avf
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add pyrevit.revit.avf — helpers for displaying values via the Analysis Visualization Framework
#3487
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e8a2c64
new lib: avf
Wurschdhaud 05f7da5
add correct defaults, rerun black
Wurschdhaud 55852d9
Add AVF unit tests for first-call schema unit handling
devloai[bot] 576001d
Revert "Add AVF unit tests for first-call schema unit handling"
Wurschdhaud d4d4c9e
Apply suggestions from code review
Wurschdhaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+997 Bytes
...Tools.extension/pyRevitDev.tab/Developer Examples.panel/AVF.pushbutton/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions
79
...yRevitDevTools.extension/pyRevitDev.tab/Developer Examples.panel/AVF.pushbutton/script.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """Developer example: pick an element, display a number on it via AVF. | ||
|
|
||
| Minimal end-to-end smoke test for pyrevit.revit.avf. Pick any element with | ||
| solid geometry visible in the active view, type in a number, choose a | ||
| display style (text marker or colored surface), and it gets painted onto | ||
| the element. | ||
| """ | ||
|
|
||
| from pyrevit import revit, forms | ||
| from pyrevit.revit import avf | ||
|
|
||
| doc = revit.doc | ||
| view = revit.active_view | ||
|
|
||
| # 1. Pick a single element in the model | ||
| with forms.WarningBar(title="Select an element to label"): | ||
| element = revit.pick_element() | ||
|
|
||
| if not element: | ||
| forms.alert("Nothing selected.", exitscript=True) | ||
|
|
||
| # 2. Ask for a value to display | ||
| value_str = forms.ask_for_string( | ||
| default="42", | ||
| prompt="Value to display on the selected element:", | ||
| title="AVF Demo", | ||
| ) | ||
|
|
||
| if value_str is None: | ||
| forms.alert("Cancelled.", exitscript=True) | ||
|
|
||
| try: | ||
| value = float(value_str) | ||
| except ValueError: | ||
| forms.alert("'{}' is not a number.".format(value_str), exitscript=True) | ||
|
|
||
| # 3. Pick a display style, get-or-create it, and assign it to the view. | ||
| style_choice = forms.CommandSwitchWindow.show( | ||
| ["Text Marker", "Colored Surface"], | ||
| message="Pick an AVF display style:", | ||
| ) | ||
|
|
||
| if style_choice is None: | ||
| forms.alert("Cancelled.", exitscript=True) | ||
|
|
||
| if style_choice == "Colored Surface": | ||
| style = avf.get_or_create_colored_surface_display_style( | ||
| doc, "pyRevitAVF_Demo_ColoredSurface" | ||
| ) | ||
| else: | ||
| style = avf.get_or_create_marker_display_style(doc, "pyRevitAVF_Demo_Marker") | ||
|
|
||
| with revit.Transaction("Set AVF Display Style"): | ||
| view.AnalysisDisplayStyleId = style.Id | ||
|
|
||
| results = avf.display_avf_values( | ||
| {element: value}, | ||
| view, | ||
| schema_name="pyRevitAVF_Demo", | ||
| schema_desc="AVF pick-and-display demo", | ||
| ) | ||
|
|
||
| elem_id_val = results.keys()[0] | ||
| success, sfp_id = results[elem_id_val] | ||
|
|
||
| if success: | ||
| forms.alert( | ||
| "Displayed value {} on element ID {}.\n\n" | ||
| "Run again on other elements, or use " | ||
| "avf.clear_avf_results(view) to remove all markers from " | ||
| "this view.".format(value, elem_id_val) | ||
| ) | ||
| else: | ||
| forms.alert( | ||
| "Could not find a viewer-facing face on the selected element.\n" | ||
| "Try an element with solid geometry (wall, floor, generic model), " | ||
| "or adapt the script to pass use_bbox_center=True." | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,5 @@ layout: | |
| - Settings Window | ||
| - Modeless | ||
| - DockablePane | ||
| - ExportIFC | ||
| - ExportIFC | ||
| - AVF | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.