├── .gitattributes ├── .gitignore ├── EF-Tutor.tab ├── Resources.panel │ └── Resources.stack │ │ ├── Docs.pulldown │ │ ├── icon.png │ │ ├── pyRevit_input.urlbutton │ │ │ └── bundle.yaml │ │ ├── pyRevitdocs.urlbutton │ │ │ └── bundle.yaml │ │ └── revitapidocs.urlbutton │ │ │ └── bundle.yaml │ │ ├── Templates.pulldown │ │ ├── icon.png │ │ ├── pyRevitTemplate.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ └── pyRevitTemplate_min.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── Tools.pulldown │ │ ├── RevitLookUp.urlbutton │ │ │ └── bundle.yaml │ │ ├── RevitPythonShell.urlbutton │ │ │ └── bundle.yaml │ │ ├── icon.png │ │ ├── icons8.urlbutton │ │ │ └── bundle.yaml │ │ └── pyCharm.urlbutton │ │ │ └── bundle.yaml │ │ └── bundle.yaml ├── Tutorials.panel │ ├── 01.01 - Revit API Introduction.pushbuttonn │ │ ├── icon.png │ │ └── script.py │ ├── ChangeHost.pushbuttonOBSOLETE │ │ ├── icon.png │ │ └── script.py │ ├── DevDiary.pulldown │ │ ├── 01_Match Overrides.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 02 - ReplaceMaterials.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 03 - GroupName to Elements.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 04 - CenterRoomTags.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 05 - CreateElementsLibrary.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ └── icon.png │ ├── YouTubeLessons_2023.pulldown │ │ ├── 01_LevelsElevation.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 02 - Elements Info.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 03 - Parameters.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 04 - FilteredElementCollector.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 05 - RevitAPI - CreateCopyDelete Elements.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 06 - CopyElements.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 07 - FurnitureRooms.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 08 - CreateElementsLibrary.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 09 - RandomizeParameter.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 10 - ElementParameterFilter.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ ├── 11 - GetDefaultTypes.pushbutton │ │ │ ├── icon.png │ │ │ └── script.py │ │ └── icon.png │ └── YouTubeLessons_2024.pulldown │ │ ├── 24_01_AutomateWindowSections.pushbutton │ │ ├── icon.png │ │ ├── script.py │ │ └── temp.py │ │ ├── 24_02_PlaceViewsOnSheets.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ ├── 24_03_ConvertCoordinates.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ ├── 24_04_pyRevitLinkify.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ ├── 24_05_PurgeViewFilters.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ ├── 24_06_PurgeViewTemplates.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ ├── 24_07_MorePythonPackages.pushbutton │ │ ├── icon.png │ │ └── script.py │ │ └── icon.png └── bundle.yaml ├── LICENSE ├── README.md ├── extension.json ├── hooks └── hooks-archive │ └── doc-updater.py └── lib ├── Snippets ├── __init__.py ├── _convert.py └── _selection.py └── __init__.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | EF-Tutor.tab/Tests.panel 2 | .idea/ 3 | *.xlsx 4 | EF-Tutor.tab/Dev.panel/ 5 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Docs.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Resources.panel/Resources.stack/Docs.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Docs.pulldown/pyRevit_input.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: pyRevit Effective Input 2 | tooltip: Collection of examples about pyrevit.forms 3 | hyperlink: "https://www.notion.so/Effective-Input-ea95e95282a24ba9b154ef88f4f8d056" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Docs.pulldown/pyRevitdocs.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: pyRevit Dev Docs 2 | tooltip: pyRevit Developer's Documentation 3 | hyperlink: "https://www.notion.so/Developer-Docs-2c88f3ecccde422d9504e20b6b9e04f8" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Docs.pulldown/revitapidocs.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: RevitApiDocs 2 | tooltip: online RevitAPI Documentation 3 | hyperlink: "https://revitapidocs.com" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "EF Template" # Name of the button displayed in Revit UI 3 | __doc__ = """Version = 1.0 4 | Date = 20.04.2022 5 | _____________________________________________________________________ 6 | Description: 7 | This is a template file for pyRevit Scripts. 8 | _____________________________________________________________________ 9 | How-to: (Example) 10 | -> Click on the button 11 | -> Change Settings(optional) 12 | -> Make a change 13 | _____________________________________________________________________ 14 | Last update: 15 | - [12.06.2023] - 1.1 UPDATE - New Feature 16 | - [12.06.2023] - 1.0 RELEASE 17 | _____________________________________________________________________ 18 | To-Do: 19 | - Check Revit 2021 20 | - Add ... Feature 21 | _____________________________________________________________________ 22 | Author: Erik Frits""" # Button Description shown in Revit UI 23 | 24 | # pyRevit EXTRA metatags: You can remove them. 25 | __author__ = "Erik Frits" # Script's Author 26 | __helpurl__ = "https://www.youtube.com/watch?v=YhL_iOKH-1M" # Link that can be opened with F1 when hovered over the tool in Revit UI. 27 | # __highlight__ = "new" # Button will have an orange dot + Description in Revit UI 28 | __min_revit_ver__ = 2019 # Limit your Scripts to certain Revit versions if it's not compatible due to RevitAPI Changes. 29 | __max_revit_ver = 2022 # Limit your Scripts to certain Revit versions if it's not compatible due to RevitAPI Changes. 30 | # __context__ = ['Walls', 'Floors', 'Roofs'] # Make your button available only when certain categories are selected. Or Revit/View Types. 31 | # __context__ = ['Walls', 'Floors', 'Roofs'] # Make your button available only when certain categories are selected. Or Revit/View Types. 32 | # Docs Link: https://pyrevitlabs.notion.site/Anatomy-of-IronPython-Scripts-f11d0099667f46a28d29b028dd99ccaf 33 | 34 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 35 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 36 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 37 | # ================================================== 38 | # Regular + Autodesk 39 | import os, sys, math, datetime, time # Regular Imports 40 | # from Autodesk.Revit.DB import Transaction, FilteredElementCollector # or Import only classes that are used. 41 | from Autodesk.Revit.DB.Architecture import Room, TopographySurface # Import Discipline Specific Elements 42 | from Autodesk.Revit.DB import * # Import everything from DB (Very good for beginners) 43 | 44 | # pyRevit 45 | from pyrevit import revit, forms # import pyRevit modules. (Lots of useful features) 46 | 47 | # Custom Imports 48 | from Snippets._selection import get_selected_elements # lib import 49 | from Snippets._convert import convert_internal_to_m # lib import 50 | 51 | # .NET Imports 52 | import clr # Common Language Runtime. Makes .NET libraries accessinble 53 | clr.AddReference("System") # Refference System.dll for import. 54 | from System.Collections.Generic import List # List() <- it's special type of list from .NET framework that RevitAPI requires 55 | # List_example = List[ElementId]() # use .Add() instead of append or put python list of ElementIds in parentesis. 56 | 57 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 58 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 59 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 60 | # ================================================== 61 | doc = __revit__.ActiveUIDocument.Document #type: UIDocument # Document class from RevitAPI that represents project. Used to Create, Delete, Modify and Query elements from the project. 62 | uidoc = __revit__.ActiveUIDocument #type: Document # UIDocument class from RevitAPI that represents Revit project opened in the Revit UI. 63 | selection = uidoc.Selection #type: Selection 64 | app = __revit__.Application #type: UIApplication # Represents the Autodesk Revit Application, providing access to documents, options and other application wide data and settings. 65 | rvt_year = int(app.VersionNumber) # e.g. 2023 66 | 67 | active_view = doc.ActiveView 68 | active_level = active_view.GenLevel # Only FloorPlans are associated with a Level! 69 | PATH_SCRIPT = os.path.dirname(__file__) # Absolute path to the folder where script is placed. 70 | 71 | # GLOBAL VARIABLES 72 | 73 | # - Place global variables here. 74 | 75 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 76 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 77 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS 78 | # ================================================== 79 | 80 | # - Place local functions here. If you might use any functions in other scripts, consider placing it in the lib folder. 81 | 82 | # ╔═╗╦ ╔═╗╔═╗╔═╗╔═╗╔═╗ 83 | # ║ ║ ╠═╣╚═╗╚═╗║╣ ╚═╗ 84 | # ╚═╝╩═╝╩ ╩╚═╝╚═╝╚═╝╚═╝ CLASSES 85 | # ================================================== 86 | 87 | # - Place local classes here. If you might use any classes in other scripts, consider placing it in the lib folder. 88 | 89 | # ╔╦╗╔═╗╦╔╗╔ 90 | # ║║║╠═╣║║║║ 91 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 92 | # ================================================== 93 | if __name__ == '__main__': 94 | # START CODE HERE 95 | 96 | # AVOID placing Transaction inside of your loops! It will drastically reduce perfomance of your script. 97 | t = Transaction(doc,__title__) # Transactions are context-like objects that guard any changes made to a Revit model. 98 | 99 | # You need to use t.Start() and t.Commit() to make changes to a Project. 100 | t.Start() # <- Transaction Start 101 | 102 | #- CHANGES TO REVIT PROJECT HERE 103 | 104 | t.Commit() # <- Transaction End 105 | 106 | # Notify user that script is complete. 107 | print('-' * 50) 108 | print('Script is finished.') 109 | print('Template has been developed by Erik Frits.') -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate_min.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate_min.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Templates.pulldown/pyRevitTemplate_min.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "EF Template.min" 3 | __doc__ = """Version = 1.0 4 | Date = 20.04.2022 5 | _____________________________________________________________________ 6 | Description: 7 | This is a template file for pyRevit Scripts. 8 | _____________________________________________________________________ 9 | How-to: 10 | -> Click on the button 11 | -> Change Settings(optional) 12 | -> Make a change 13 | _____________________________________________________________________ 14 | Last update: 15 | - [24.04.2022] - 1.0 RELEASE 16 | _____________________________________________________________________ 17 | To-Do: 18 | - 19 | _____________________________________________________________________ 20 | Author: Erik Frits""" 21 | 22 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 23 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 24 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 25 | # ================================================== 26 | # Regular + Autodesk 27 | from Autodesk.Revit.DB import * 28 | 29 | # pyRevit 30 | from pyrevit import revit, forms 31 | 32 | # .NET Imports 33 | import clr 34 | clr.AddReference("System") 35 | from System.Collections.Generic import List 36 | 37 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 38 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 39 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 40 | # ================================================== 41 | doc = __revit__.ActiveUIDocument.Document 42 | uidoc = __revit__.ActiveUIDocument 43 | app = __revit__.Application 44 | 45 | # ╔╦╗╔═╗╦╔╗╔ 46 | # ║║║╠═╣║║║║ 47 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 48 | # ================================================== 49 | if __name__ == '__main__': 50 | # START CODE HERE 51 | print('Template has been developed by Erik Frits.') -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/RevitLookUp.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: Revit LookUp 2 | tooltip: Tool for exploring RevitAPI hidden behind Elements. 3 | hyperlink: "https://github.com/jeremytammik/RevitLookup" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/RevitPythonShell.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: RevitPythonShell 2 | tooltip: The RevitPythonShell adds an IronPython interpreter to Autodesk Revit. 3 | hyperlink: "https://github.com/architecture-building-systems/revitpythonshell" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/icons8.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: Icons8 2 | tooltip: Website full of free Icons. 3 | hyperlink: "https://www.icons8.com" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/Tools.pulldown/pyCharm.urlbutton/bundle.yaml: -------------------------------------------------------------------------------- 1 | title: pyCharm 2 | tooltip: pyCharm - python IDE. 3 | hyperlink: "https://www.jetbrains.com/pycharm/" -------------------------------------------------------------------------------- /EF-Tutor.tab/Resources.panel/Resources.stack/bundle.yaml: -------------------------------------------------------------------------------- 1 | layout: 2 | - Docs 3 | - Tools 4 | - Templates 5 | 6 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/01.01 - Revit API Introduction.pushbuttonn/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/01.01 - Revit API Introduction.pushbuttonn/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/01.01 - Revit API Introduction.pushbuttonn/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = 'What is Revit API?' 3 | 4 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 5 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 6 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 7 | #-------------------------------------------------- 8 | from Autodesk.Revit.DB import * 9 | 10 | # ╔╦╗╔═╗╦╔╗╔ 11 | # ║║║╠═╣║║║║ 12 | # ╩ ╩╩ ╩╩╝╚╝ 13 | #-------------------------------------------------- 14 | document = __revit__.ActiveUIDocument.Document 15 | viewId = document.ActiveView.Id 16 | position = XYZ(0,0,0) 17 | text = 'Visit LearnRevitAPI.com to Learn More!' 18 | typeId = document.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType) 19 | 20 | t = Transaction(document, 'Create TextNote') 21 | t.Start() 22 | TextNote.Create(document, viewId, position, text, typeId) 23 | t.Commit() 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/ChangeHost.pushbuttonOBSOLETE/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/ChangeHost.pushbuttonOBSOLETE/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/ChangeHost.pushbuttonOBSOLETE/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "Change Host" 3 | __doc__ = """Date = 22.04.2023 4 | Randomize Parameter Values for specific Families 5 | _____________________________________________________________________ 6 | Author: Erik Frits""" 7 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 8 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 9 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 10 | #================================================== 11 | import random 12 | from Autodesk.Revit.DB import * 13 | from Autodesk.Revit.UI import UIDocument, UIApplication 14 | from pyrevit import forms 15 | from Autodesk.Revit.DB.Architecture import TopographySurface 16 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 17 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 18 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 19 | #================================================== 20 | uidoc = __revit__.ActiveUIDocument #type: UIDocument 21 | doc = __revit__.ActiveUIDocument.Document #type: Document 22 | app = __revit__.Application #type: UIApplication 23 | rvt_year = int(app.VersionNumber) 24 | 25 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 26 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 27 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS 28 | #================================================== 29 | # def get_elements_by_type_name(type_name): 30 | # """Function to get Elements by Type Name.""" 31 | # 32 | # # CREATE RULE 33 | # param_id = ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME) 34 | # f_param = ParameterValueProvider(param_id) 35 | # f_evaluator = FilterStringEquals() 36 | # f_rule = FilterStringRule(f_param, f_evaluator , type_name, True) 37 | # # Revit 2023 does not need last argument in f_rule! 38 | # 39 | # # CREATE FILTER 40 | # filter_type_name = ElementParameterFilter(f_rule) 41 | # 42 | # # GET ELEMENTS 43 | # return FilteredElementCollector(doc).WherePasses(filter_type_name)\ 44 | # .WhereElementIsNotElementType().ToElements() 45 | # 46 | # 47 | # 48 | # def get_elements_by_family_name(family_name): 49 | # """Function to get Elements by Family Name.""" 50 | # 51 | # # CREATE RULE 52 | # param_id = ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME) 53 | # f_param = ParameterValueProvider(param_id) 54 | # f_evaluator = FilterStringEquals() 55 | # f_rule = FilterStringRule(f_param, f_evaluator , family_name, True) 56 | # # Revit 2023 does not need last argument in f_rule! 57 | # 58 | # # CREATE FILTER 59 | # filter_family_name = ElementParameterFilter(f_rule) 60 | # 61 | # # GET ELEMENTS 62 | # return FilteredElementCollector(doc).WherePasses(filter_family_name)\ 63 | # .WhereElementIsNotElementType().ToElements() 64 | # 65 | # 66 | # def convert_internal_units(value, get_internal = True, units='m'): 67 | # #type: (float, bool, str) -> float 68 | # """Function to convert Internal units to meters or vice versa. 69 | # :param value: Value to convert 70 | # :param get_internal: True to get internal units, False to get Meters 71 | # :param units: Select desired Units: ['m', 'm2'] 72 | # :return: Length in Internal units or Meters.""" 73 | # 74 | # if rvt_year >= 2021: 75 | # from Autodesk.Revit.DB import UnitTypeId 76 | # if units == 'm' : units = UnitTypeId.Meters 77 | # elif units == "m2": units = UnitTypeId.SquareMeters 78 | # elif units == 'cm': units = UnitTypeId.Centimeters 79 | # else: 80 | # from Autodesk.Revit.DB import DisplayUnitType 81 | # if units == 'm' : units = DisplayUnitType.DUT_METERS 82 | # elif units == "m2": units = DisplayUnitType.DUT_SQUARE_METERS 83 | # elif units == "cm": units = DisplayUnitType.DUT_CENTIMETERS 84 | # 85 | # if get_internal: 86 | # return UnitUtils.ConvertToInternalUnits(value, units) 87 | # return UnitUtils.ConvertFromInternalUnits(value, units) 88 | # 89 | # def random_step(_min, _max, _step): 90 | # return random.randrange(_min, _max+1, _step) 91 | 92 | 93 | # ╔╦╗╔═╗╦╔╗╔ 94 | # ║║║╠═╣║║║║ 95 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 96 | #================================================== 97 | 98 | # 1️⃣ Variables 99 | # family_name = 'Vertical Blade' 100 | # type_name = 'Vertical Blade' 101 | # param_name = 'Tiefe' 102 | # _min = 40 103 | # _max = 250 104 | # _step = 10 105 | 106 | # 🔷 Bonus: Custom UI 107 | 108 | 109 | # GET ELEMENTS 110 | selection = uidoc.Selection.GetElementIds() 111 | elements = [doc.GetElement(e_id) for e_id in selection] 112 | 113 | trees = [] 114 | topo = None 115 | 116 | for i in elements: 117 | if type(i) == FamilyInstance: trees.append(i) 118 | elif type(i) == TopographySurface: topo = i 119 | 120 | if not topo or not trees: 121 | forms.alert('No Topo or Trees selected',__title__, exitscript=True) 122 | 123 | 124 | 125 | 126 | for tree in trees: 127 | # Tree Line 128 | pt = tree.Location.Point 129 | 130 | print(topo.ContainsPoint(pt)) 131 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/01_Match Overrides.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/01_Match Overrides.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/01_Match Overrides.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "01 - Match Override Graphics" # Name of the button displayed in Revit UI 3 | __doc__ = """Version = 1.0 4 | Date = 22.05.2022 5 | _____________________________________________________________________ 6 | Description: 7 | Match Graphic Overviews 8 | _____________________________________________________________________ 9 | How-to: 10 | -> Run the tool 11 | -> Select main element 12 | -> Match other elements 13 | 14 | _____________________________________________________________________ 15 | Video Tutorial is available on my Patreon: www.patreon.com/ErikFrits 16 | Click F1 while hovering this button to open the link.""" # Button Description shown in Revit UI 17 | __helpurl__ = 'https://www.patreon.com/posts/01-dev-diary-66841678' 18 | 19 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 20 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 21 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 22 | # ================================================== 23 | from Autodesk.Revit.DB import * # Import everything from DB (Very good for beginners) 24 | 25 | # pyRevit 26 | from pyrevit import revit, forms # import pyRevit modules. (Lots of useful features) 27 | 28 | 29 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 30 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 31 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 32 | # ================================================== 33 | doc = __revit__.ActiveUIDocument.Document # Document class from RevitAPI that represents project. Used to Create, Delete, Modify and Query elements from the project. 34 | uidoc = __revit__.ActiveUIDocument # UIDocument class from RevitAPI that represents Revit project opened in the Revit UI. 35 | app = __revit__.Application # Represents the Autodesk Revit Application, providing access to documents, options and other application wide data and settings. 36 | 37 | 38 | # ╔╦╗╔═╗╦╔╗╔ 39 | # ║║║╠═╣║║║║ 40 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 41 | # ================================================== 42 | 43 | # Pick Main Element 44 | with forms.WarningBar(title='Pick Main Element:'): 45 | main_elem = revit.pick_element() 46 | if not main_elem: 47 | forms.alert("No element was selected. Please Try Again.", title=__title__, exitscript=True) 48 | 49 | # Get Main GraphicsOverrides 50 | graphics = doc.ActiveView.GetElementOverrides(main_elem.Id) 51 | 52 | # Loop keep selecting elements to match 53 | with forms.WarningBar(title='Pick Elements to match Graphics:', handle_esc=True): 54 | while True: 55 | elem = None 56 | try: 57 | elem = revit.pick_element() 58 | except: 59 | break 60 | if not elem: break 61 | 62 | # Set GraphicsOverrides 63 | t = Transaction(doc, __title__) 64 | t.Start() 65 | doc.ActiveView.SetElementOverrides(elem.Id, graphics) 66 | t.Commit() 67 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/02 - ReplaceMaterials.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/02 - ReplaceMaterials.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/02 - ReplaceMaterials.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "02 - Replace Materials" 3 | __doc__ = """This tool will replace Material A with Material B. 4 | It is part of the Dev Diary video availabel on my Patreon, 5 | where I document how i write my tools. 6 | You can access it by signing up on: 7 | www.patreon.com/ErikFrits""" 8 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 9 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 10 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 11 | # ================================================== 12 | # Regular + Autodesk 13 | from Autodesk.Revit.DB import * 14 | 15 | import clr 16 | clr.AddReference('System') 17 | from System.Collections.Generic import List 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 22 | # ================================================== 23 | doc = __revit__.ActiveUIDocument.Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | # ╔╦╗╔═╗╦╔╗╔ 28 | # ║║║╠═╣║║║║ 29 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 30 | # ================================================== 31 | 32 | # GET ALL MATERIALS 33 | all_materials = FilteredElementCollector(doc).OfClass(Material).ToElements() 34 | 35 | # GET MATERIAL A/B 36 | mat_A = all_materials[0] 37 | mat_B = all_materials[1] 38 | 39 | 40 | # GET WALLS/FLOORS/ ROOFS 41 | excl_families = ['Curtain Wall', 'Stacked Wall', 'Sloped Glazing'] 42 | 43 | all_walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements() 44 | all_floors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsElementType().ToElements() 45 | all_roofs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Roofs).WhereElementIsElementType().ToElements() 46 | all_types = list(all_walls) + list(all_floors) + list(all_roofs) 47 | all_types = [t for t in all_types if t.FamilyName not in excl_families] # EXCLUDE TYPES WITHOUT STRUCTURE LAYERS 48 | all_types = [t for t in all_types if type(t) != FamilySymbol] # REMOVE MODEL IN-PLACE ELEMENTS 49 | 50 | # GET USED MATERIALS 51 | t = Transaction(doc, __title__) 52 | t.Start() 53 | 54 | count = 0 55 | for typ in all_types: 56 | structure = typ.GetCompoundStructure() # This is just a copy. It's not related to any Types 57 | layers = structure.GetLayers() 58 | 59 | for layer in layers: 60 | mat_id = layer.MaterialId 61 | if mat_id == ElementId(-1): 62 | continue 63 | 64 | mat = doc.GetElement(mat_id) 65 | mat_name = mat.Name 66 | 67 | 68 | # REPLACE MATERIALS 69 | inx = layer.LayerId 70 | structure.SetMaterialId(inx, mat_B.Id) # We are modifying our structure copy 71 | typ.SetCompoundStructure(structure) # Finally we need to assign our new structure to the type. 72 | count += 1 73 | 74 | # REPORT CHANGES 75 | print('Changed: {} -> {}'.format(mat_name, mat_B.Name)) 76 | print('In total {} materials have been renamed.'.format(count)) 77 | 78 | t.Commit() 79 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/03 - GroupName to Elements.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/03 - GroupName to Elements.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/03 - GroupName to Elements.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "03 - GroupName to Elements" 3 | __doc__ = """This script is from Dev Diary video that I 4 | posted on Patreon. I will show you how to : 5 | - Get Groups 6 | - Get Elements in Groups 7 | - Get Group Name 8 | - Write Groupname to one of parameters. 9 | 10 | You can support my channel on: 11 | www.patreon.com/ErikFrits""" 12 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 13 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 14 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 15 | # ================================================== 16 | # Regular + Autodesk 17 | from Autodesk.Revit.DB import * 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 22 | # ================================================== 23 | doc = __revit__.ActiveUIDocument.Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | OUTPUT_PARAM = 'GroupName' 28 | CATEGORIES = [BuiltInCategory.OST_Walls, BuiltInCategory.OST_Floors] 29 | 30 | # ╔╦╗╔═╗╦╔╗╔ 31 | # ║║║╠═╣║║║║ 32 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 33 | # ================================================== 34 | 35 | # GET ALL GROUPS + FILTER 36 | all_groups = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_IOSModelGroups).WhereElementIsNotElementType().ToElements() 37 | all_whg_groups = [g for g in all_groups if 'WHG' in g.Name] # List Comprehension to filter Apartment groups. 38 | 39 | with Transaction(doc, __doc__) as t: 40 | t.Start() 41 | 42 | # CLEAN PARAMETERS 43 | all_walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements() 44 | all_floors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements() 45 | all_doors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements() 46 | clean_elements = list(all_walls) + list(all_floors) + list(all_doors) 47 | 48 | for el in clean_elements: 49 | el_param = el.LookupParameter(OUTPUT_PARAM) 50 | el_param.Set('') 51 | 52 | 53 | 54 | for g in all_whg_groups: 55 | # GET GROUP MEMBERS 56 | member_ids = g.GetMemberIds() 57 | members = [doc.GetElement(id) for id in member_ids] 58 | 59 | # FILTER MEMBERS CATEGORIES 60 | for el in members: 61 | try: 62 | if el.Category.Name not in CATEGORIES: 63 | continue 64 | except: 65 | continue 66 | 67 | # SET GROUP NAME 68 | el_param = el.LookupParameter(OUTPUT_PARAM) 69 | el_param.Set(g.Name) 70 | 71 | # break 72 | 73 | t.Commit() 74 | 75 | 76 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/04 - CenterRoomTags.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/04 - CenterRoomTags.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/04 - CenterRoomTags.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "04 - Center Room Tags" 3 | __author__ = "Erik Frits" 4 | __version__ = "Version 1.0" 5 | __doc__ = """Version = 1.0 6 | Date = 03.09.2022 7 | _____________________________________________________________________ 8 | Description: 9 | WIP: 10 | Move your existing tags to the center of the room, 11 | together with reference of your Room. 12 | _____________________________________________________________________ 13 | How-to: 14 | -> Click on Button 15 | _____________________________________________________________________ 16 | Author: Erik Frits""" 17 | 18 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 19 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 20 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 21 | #================================================== 22 | from Autodesk.Revit.DB import * 23 | 24 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 25 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 26 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ 27 | #================================================== 28 | doc = __revit__.ActiveUIDocument.Document 29 | uidoc = __revit__.ActiveUIDocument 30 | app = __revit__.Application 31 | 32 | # ELEMENTS 33 | all_room_tags = FilteredElementCollector(doc, doc.ActiveView.Id)\ 34 | .OfCategory(BuiltInCategory.OST_RoomTags).WhereElementIsNotElementType().ToElements() 35 | 36 | # CONTROLS 37 | step = 2 # INTERNAL UNITS IN FEET 38 | 39 | 40 | def move_room_and_tag(tag, room, new_pt): 41 | """Function to move both Room and Tag Locations, if they are not part of the group. 42 | :param tag: Room Tag 43 | :param room: Room 44 | :param new_pt: XYZ Point.""" 45 | if room.GroupId == ElementId(-1): #ElementId(-1) means None 46 | room.Location.Point = new_pt 47 | 48 | if tag.GroupId == ElementId(-1): 49 | tag.Location.Point = new_pt 50 | 51 | # ╔╦╗╔═╗╦╔╗╔ 52 | # ║║║╠═╣║║║║ 53 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 54 | #================================================== 55 | 56 | with Transaction(doc, __title__) as t: 57 | t.Start() 58 | 59 | 60 | for tag in all_room_tags: 61 | # ROOM DATA 62 | room = tag.Room 63 | room_bb = room.get_BoundingBox(doc.ActiveView) 64 | room_center = (room_bb.Min + room_bb.Max) / 2 65 | 66 | # MOVE TO CENTER (if possible) 67 | if room.IsPointInRoom(room_center): 68 | move_room_and_tag(tag, room, room_center) 69 | 70 | # FIND ANOTHER LOCATION 71 | else: 72 | room_boundaries = room.GetBoundarySegments(SpatialElementBoundaryOptions()) 73 | room_segments = room_boundaries[0] 74 | 75 | # Get Longest Segment 76 | length = 0 77 | longest_curve = None 78 | 79 | for seg in room_segments: 80 | curve = seg.GetCurve() 81 | if curve.Length > length: 82 | longest_curve = curve 83 | length = curve.Length 84 | 85 | # Get middle point on Curve 86 | pt_start = longest_curve.GetEndPoint(0) 87 | pt_end = longest_curve.GetEndPoint(1) 88 | pt_mid = (pt_start + pt_end) / 2 89 | 90 | pt_up = XYZ(pt_mid.X , pt_mid.Y +step , pt_mid.Z) 91 | pt_down = XYZ(pt_mid.X , pt_mid.Y -step , pt_mid.Z) 92 | pt_right = XYZ(pt_mid.X +step , pt_mid.Y , pt_mid.Z) 93 | pt_left = XYZ(pt_mid.X -step , pt_mid.Y , pt_mid.Z) 94 | 95 | # Move on X Axis 96 | if not (room.IsPointInRoom(pt_up) and room.IsPointInRoom(pt_down)): 97 | if room.IsPointInRoom(pt_up): 98 | move_room_and_tag(tag, room, pt_up) 99 | 100 | elif room.IsPointInRoom(pt_down): 101 | move_room_and_tag(tag, room, pt_down) 102 | 103 | 104 | # Move on Y Axis 105 | elif not(room.IsPointInRoom(pt_right) and room.IsPointInRoom(pt_left)): 106 | if room.IsPointInRoom(pt_right): 107 | move_room_and_tag(tag, room, pt_right) 108 | 109 | elif room.IsPointInRoom(pt_left): 110 | move_room_and_tag(tag, room, pt_left) 111 | t.Commit() -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/05 - CreateElementsLibrary.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/05 - CreateElementsLibrary.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/05 - CreateElementsLibrary.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "05 - Create Library of Elements" 3 | __doc__ = """Date = 22.10.2022 4 | _____________________________________________________________________ 5 | Description: 6 | Script from a video Tutorial for my Ko-Fi and Patreon supporters. 7 | _____________________________________________________________________ 8 | Author: Erik Frits""" 9 | __context__ = 'active-floor-plan' 10 | 11 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 12 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 13 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 14 | #==================================================================================================== 15 | from Autodesk.Revit.DB import * 16 | 17 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 18 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 19 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ 20 | #==================================================================================================== 21 | doc = __revit__.ActiveUIDocument.Document 22 | uidoc = __revit__.ActiveUIDocument 23 | app = __revit__.Application 24 | 25 | active_view = doc.ActiveView 26 | active_level = doc.ActiveView.GenLevel 27 | 28 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 29 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 30 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ 31 | #==================================================================================================== 32 | def create_text(origin, text_type): 33 | """Function to create TextNote at the given location. 34 | TextType Name is going to be used as a Text.""" 35 | text = text_type.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString() 36 | 37 | # CREATE TEXT NOTE 38 | txt = TextNote.Create(doc, active_view.Id, origin, text, text_type.Id) 39 | return txt 40 | 41 | def create_wall(origin, wall_type): 42 | """Function to create a Wall at the given location.""" 43 | pt_start = origin 44 | pt_end = XYZ(origin.X + 2, origin.Y, origin.Z) 45 | curve = Line.CreateBound(pt_start, pt_end) 46 | 47 | H = 10 48 | O = 0 49 | flip = False 50 | struc = False 51 | 52 | wall = Wall.Create(doc, curve, wall_type.Id, active_level.Id, H, O, flip, struc) 53 | return wall 54 | 55 | 56 | def create_floor(origin, floor_type): 57 | """Function to create a Floor at the given location.""" 58 | # POINTS 59 | pt_0 = origin 60 | pt_1 = XYZ(origin.X+1 , origin.Y , origin.Z) 61 | pt_2 = XYZ(origin.X+1 , origin.Y+1 , origin.Z) 62 | pt_3 = XYZ(origin.X , origin.Y+1 , origin.Z) 63 | 64 | # LINES 65 | l_0 = Line.CreateBound(pt_0, pt_1) 66 | l_1 = Line.CreateBound(pt_1, pt_2) 67 | l_2 = Line.CreateBound(pt_2, pt_3) 68 | l_3 = Line.CreateBound(pt_3, pt_0) 69 | 70 | # BOUNDARY 71 | boundary = CurveArray() 72 | boundary.Append(l_0) 73 | boundary.Append(l_1) 74 | boundary.Append(l_2) 75 | boundary.Append(l_3) 76 | 77 | # CREATE FLOOR 78 | new_floor = doc.Create.NewFloor(boundary, floor_type, active_level, False) 79 | return new_floor 80 | 81 | # ╔╦╗╔═╗╦╔╗╔ 82 | # ║║║╠═╣║║║║ 83 | # ╩ ╩╩ ╩╩╝╚╝ 84 | #==================================================================================================== 85 | # Get Types 86 | all_walls_types = FilteredElementCollector(doc).OfClass(WallType).ToElements() 87 | all_floors_types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).OfClass(FloorType).ToElements() 88 | all_text_types = FilteredElementCollector(doc).OfClass(TextNoteType).ToElements() 89 | 90 | #🔵 ORIGIN 91 | X = 0 92 | Y = 0 93 | Z = 0 94 | 95 | 96 | #🔓 Transaction - Start 97 | t = Transaction(doc, __title__) 98 | t.Start() 99 | 100 | 101 | #✅ Create TextTypes 102 | for txt_type in all_text_types: 103 | origin = XYZ(X,Y,Z) 104 | create_text(origin, txt_type) 105 | Y -= 2 106 | 107 | X += 15 108 | Y = 0 109 | 110 | #✅ Create WallType 111 | for wall_type in all_walls_types: 112 | origin = XYZ(X,Y,Z) 113 | create_wall(origin, wall_type) 114 | Y -= 2 115 | 116 | X += 15 117 | Y = 0 118 | 119 | #✅ Create FloorType 120 | for floor_type in all_floors_types: 121 | origin = XYZ(X,Y,Z) 122 | create_floor(origin, floor_type) 123 | Y -= 2 124 | 125 | 126 | #🔒 Transaction - Commit 127 | t.Commit() 128 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/DevDiary.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/01_LevelsElevation.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/01_LevelsElevation.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/01_LevelsElevation.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "01 - Add Levels Elevation" # Name of the button displayed in Revit UI 3 | __doc__ = """Version = 1.0 4 | Date = 20.04.2022 5 | _____________________________________________________________________ 6 | Description: 7 | 8 | This tool will add/update your level name to have its elevation. 9 | _____________________________________________________________________ 10 | How-to: 11 | 12 | -> Click on the button 13 | -> Change Settings(optional) 14 | -> Rename Levels 15 | _____________________________________________________________________ 16 | Last update: 17 | - [24.04.2022] - 1.0 RELEASE 18 | _____________________________________________________________________ 19 | To-Do: 20 | _____________________________________________________________________ 21 | Author: Erik Frits""" # Button Description shown in Revit UI 22 | 23 | #EXTRA: 24 | __author__ = "Erik Frits" # Script's Author 25 | __helpurl__ = "https://www.youtube.com/watch?v=YhL_iOKH-1M&t=626s" # Link that can be opened with F1 when hovered over the tool in Revit UI. 26 | # __highlight__ = "new" # It will have an orange dot + Description in Revit UI 27 | __min_revit_ver__ = 2019 # Limit your Scripts to certain Revit versions if it's not compatible due to RevitAPI Changes. 28 | __max_revit_ver = 2022 # Limit your Scripts to certain Revit versions if it's not compatible due to RevitAPI Changes. 29 | # __context__ = ['Walls', 'Floors', 'Roofs'] # Make your button available only when certain categories are selected 30 | 31 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 32 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 33 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 34 | #================================================== 35 | # Regular + Autodesk 36 | import os 37 | from Autodesk.Revit.DB import * # Import everything from DB (Very good for beginners and during development) 38 | from Autodesk.Revit.DB import Transaction, FilteredElementCollector # or Import only used classes. 39 | 40 | # pyRevit 41 | from pyrevit import revit, forms 42 | 43 | # Custom Imports 44 | from Snippets._selection import get_selected_elements 45 | from Snippets._convert import convert_internal_to_m 46 | 47 | # .NET Imports 48 | import clr 49 | clr.AddReference("System") 50 | from System.Collections.Generic import List # List() <- it's special type of list from .NET framework that RevitAPI requires sometimes. 51 | 52 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 53 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 54 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 55 | #================================================== 56 | doc = __revit__.ActiveUIDocument.Document # Document class from RevitAPI that represents project. Used to Create, Delete, Modify and Query elements from the project. 57 | uidoc = __revit__.ActiveUIDocument # UIDocument class from RevitAPI that represents Revit project opened in the Revit UI(user interface). 58 | app = __revit__.Application # Represents the Autodesk Revit Application, providing access to documents, options and other application wide data and settings. 59 | PATH_SCRIPT = os.path.dirname(__file__) # Absolute path to the folder where this current script is located. Used 60 | # from pyrevit.revit import uidoc, doc, app # Alternative import option 61 | 62 | # Global Settings 63 | symbol_start = "【" 64 | symbol_end = "】" 65 | mode = 'add' # 'add'/'remove' 66 | position = 'prefix' # 'prefix'/'suffix' 67 | 68 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 69 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 70 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS 71 | #================================================== 72 | 73 | # Place local functions here. If you might use any functions in other scripts, consider placing it in the lib folder. 74 | 75 | def get_text_in_brackets(text, symbol_start, symbol_end): 76 | #type:(str,str,str) -> str 77 | """Function to get content between 2 symbols 78 | :param text: Initial Text 79 | :param symbol_start: Start Symbol 80 | :param symbol_end: End Symbol 81 | :return: Text between 2 symbols, if found. 82 | e.g. get_text_in_brackets('This is [not] very important message.', '[', ']') -> 'not'""" 83 | if symbol_start in text and symbol_end in text: 84 | start = text.find(symbol_start) + len(symbol_start) 85 | stop = text.find(symbol_end) 86 | return text[start:stop] 87 | return "" 88 | 89 | # ╔═╗╦ ╔═╗╔═╗╔═╗╔═╗╔═╗ 90 | # ║ ║ ╠═╣╚═╗╚═╗║╣ ╚═╗ 91 | # ╚═╝╩═╝╩ ╩╚═╝╚═╝╚═╝╚═╝ CLASSES 92 | #================================================== 93 | 94 | # Place local classes here. If you might use any classes in other scripts, consider placing it in the lib folder. 95 | 96 | # ╔╦╗╔═╗╦╔╗╔ 97 | # ║║║╠═╣║║║║ 98 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 99 | #================================================== 100 | if __name__ == '__main__': 101 | # Get all Levels 102 | all_levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements() # FilteredElementCollector is the common class for getting specific elements from Revit. 103 | 104 | # DO NOT place Transaction inside of your loops! It will drastically reduce perfomance of your script. 105 | t = Transaction(doc, __title__) # Transactions are context-like objects that guard any changes made to a Revit model. You need to use t.Start() and t.Commit() to make changes to a Project. 106 | t.Start() # <- Transaction Start 107 | 108 | for lvl in all_levels: 109 | # Get Levels Elevations + convert to meters 110 | lvl_elevation = lvl.Elevation 111 | lvl_elevation_m = round(convert_internal_to_m(lvl.Elevation), 2) 112 | lvl_elevation_m_str = "+" + str(lvl_elevation_m) if lvl.Elevation > 0 else str(lvl_elevation_m) 113 | 114 | # Prepare New Name - ELEVATION EXISTS (update) 115 | if symbol_start in lvl.Name and symbol_end in lvl.Name: 116 | current_value = get_text_in_brackets(lvl.Name, symbol_start, symbol_end) 117 | new_name = lvl.Name.replace(current_value, lvl_elevation_m_str) 118 | #TODO Homework: Add an option to remove Elevation from levels name. 119 | 120 | # Prepare New Name - ELEVATION DOES NOT EXIST (new) 121 | else: 122 | elevation_value = symbol_start + lvl_elevation_m_str + symbol_end 123 | new_name = lvl.Name + elevation_value 124 | #TODO Homework: Different Elevation Position = 'Prefix'/'Suffix' 125 | 126 | # Add/Update Levels Elevation 127 | try: 128 | # Ensure that new_name is different that current. 129 | if lvl.Name != new_name: 130 | current_name = lvl.Name 131 | lvl.Name = new_name 132 | # REPORT: if Level has changed. 133 | print('Renamed: {} -> {}'.format(current_name, new_name)) 134 | except: 135 | print("Could not change Level's name...") 136 | 137 | t.Commit() # <- Transaction End 138 | 139 | # Notify user that script is complete. 140 | print('-'*50) 141 | print('Script is finished. Type keyboard emoji in the comments if you managed to follow it until here -> ⌨') -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/02 - Elements Info.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/02 - Elements Info.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/02 - Elements Info.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "02 - Element Information" 3 | __doc__ = """This is a simple tool to pick an element and 4 | print out some simple information about it. 5 | It's part of my YouTube RevitAPI Tutorial. 6 | Author: Erik Frits""" 7 | 8 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 9 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 10 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 11 | # ================================================== 12 | # Regular + Autodesk 13 | import sys 14 | from Autodesk.Revit.DB import * 15 | 16 | #pyRevit 17 | from pyrevit import forms, revit 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 22 | # ================================================== 23 | doc = __revit__.ActiveUIDocument.Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | # ╔╦╗╔═╗╦╔╗╔ 28 | # ║║║╠═╣║║║║ 29 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 30 | # ================================================== 31 | # print('Hello World!') 32 | 33 | # BONUS: pyRevit Input 34 | # selected_views = forms.select_views() 35 | # if selected_views: 36 | # print(selected_views) 37 | 38 | # PICK ELEMENT 39 | 40 | with forms.WarningBar(title='Pick an Element:'): 41 | element = revit.pick_element() 42 | 43 | element_type = type(element) 44 | 45 | if element_type != Wall: 46 | forms.alert('You were supposed to pick a Wall.', exitscript=True) 47 | 48 | # print(element) 49 | # print(element_type) 50 | 51 | # GET INFORMATION 52 | e_cat = element.Category.Name 53 | e_id = element.Id 54 | e_level = doc.GetElement(element.LevelId) 55 | e_wall_type = element.WallType 56 | e_width = element.Width 57 | 58 | # PRINT CONSOLE 59 | print('Element Category: {}'.format(e_cat)) 60 | print('ElementId: {}'.format(e_id)) 61 | print('ElementLevelId: {}'.format(e_level.Name)) 62 | print('Wall WallType: {}'.format(e_wall_type)) 63 | print('Wall Width: {}'.format(e_width)) 64 | 65 | 66 | 67 | 68 | # pyCharm Shortcut: CTRL + B <- Show where object is declared 69 | # pyCharm Shortcut: CTRL + Q <- Read doc string of objects 70 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/03 - Parameters.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/03 - Parameters.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/03 - Parameters.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "03 - RevitAPI: Parameters" 3 | __doc__ = """This script is part of YouTube video 4 | where I explain RevitAPI Parameters and how to work with them. 5 | 6 | You can support my channel on: 7 | www.patreon.com/ErikFrits""" 8 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 9 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 10 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 11 | # ================================================== 12 | # Regular + Autodesk 13 | from Autodesk.Revit.DB import * 14 | 15 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 16 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 17 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 18 | # ================================================== 19 | doc = __revit__.ActiveUIDocument.Document 20 | uidoc = __revit__.ActiveUIDocument 21 | app = __revit__.Application 22 | 23 | # ╔╦╗╔═╗╦╔╗╔ 24 | # ║║║╠═╣║║║║ 25 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 26 | # ================================================== 27 | # print("*** It's time to learn how to use Parameters with RevitAPI + python. ***") 28 | 29 | # ╔═╗╔═╗╔╦╗ ╦ ╦╔═╗╦ ╦ 30 | # ║ ╦║╣ ║ ║║║╠═╣║ ║ 31 | # ╚═╝╚═╝ ╩ ╚╩╝╩ ╩╩═╝╩═╝ GET A WALL 32 | #==================================================================================================== 33 | wall_id = ElementId(428745) 34 | wall = doc.GetElement(wall_id) 35 | # print(wall) 36 | # print(list(wall.Parameters)) 37 | 38 | # ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗╔═╗ 39 | # ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝╚═╗ 40 | # ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═╚═╝ PARAMETERS 41 | #==================================================================================================== 42 | # print('*'*100) 43 | # print('*** Parameters: ***') 44 | # for p in wall.Parameters: 45 | # if p.Definition.Name == 'Comments': # DON'T USE THIS METHOD 46 | # print("It's a comment parmaeter!") 47 | # print(p.Id) 48 | 49 | # print(p) 50 | # print('.Name: {}'.format(p.Definition.Name)) 51 | # print('.BuiltInParameter: {}'.format(p.Definition.BuiltInParameter)) 52 | # print('.StorageType: {}'.format(p.StorageType)) 53 | # print('.IsShared: {}'.format(p.IsShared)) 54 | # print('.IsReadOnly: {}'.format(p.IsReadOnly)) 55 | # print("-"*50) 56 | 57 | # ╔═╗╔═╗╔╦╗ ╔╗ ╦ ╦╦╦ ╔╦╗ ╦╔╗╔ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗ 58 | # ║ ╦║╣ ║ ╠╩╗║ ║║║ ║───║║║║ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝ 59 | # ╚═╝╚═╝ ╩ ╚═╝╚═╝╩╩═╝╩ ╩╝╚╝ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═ GET BUILT-IN PARAMETER 60 | # ==================================================================================================== 61 | # print('-' * 100) 62 | # print('*** Built-in Parameters: ***') 63 | # wall_comments = wall.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS) 64 | # wall_type_name = wall.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString() 65 | # 66 | # print('.Name: {}'.format(wall_comments.Definition.Name)) 67 | # print('.BuiltInParameter: {}'.format(wall_comments.Definition.BuiltInParameter)) 68 | # print('.StorageType: {}'.format(wall_comments.StorageType)) 69 | # print('.IsShared: {}'.format(wall_comments.IsShared)) 70 | # print('.IsReadOnly: {}'.format(wall_comments.IsReadOnly)) 71 | # print("-"*50) 72 | # 73 | # print(wall_comments.AsString()) 74 | 75 | # ╔═╗╔═╗╔╦╗ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗ ╔╗ ╦ ╦ ╔╗╔╔═╗╔╦╗╔═╗ 76 | # ║ ╦║╣ ║ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝ ╠╩╗╚╦╝ ║║║╠═╣║║║║╣ 77 | # ╚═╝╚═╝ ╩ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═ ╚═╝ ╩ ╝╚╝╩ ╩╩ ╩╚═╝ GET PARAMETER BY NAME 78 | #==================================================================================================== 79 | # print('*** Getting Shared Parameters: ***') 80 | 81 | # GET PROJECT/SHARED PARAMETER 82 | # sp_text = wall.LookupParameter('sp_text') 83 | # print(sp_text.AsString()) 84 | 85 | # sp_mat_id = wall.LookupParameter('sp_material').AsElementId() 86 | # sp_mat = doc.GetElement(sp_mat_id) 87 | # print(sp_mat) 88 | # print(sp_mat.Name) 89 | 90 | # sp_text = wall.LookupParameter('sp_bool') 91 | # print(sp_text.AsInteger()) 92 | 93 | 94 | 95 | # ╔═╗╔═╗╔╦╗ ╔╦╗╦ ╦╔═╗╔═╗ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗╔═╗ 96 | # ║ ╦║╣ ║ ║ ╚╦╝╠═╝║╣ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝╚═╗ 97 | # ╚═╝╚═╝ ╩ ╩ ╩ ╩ ╚═╝ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═╚═╝ GET TYPE PARMAETERS 98 | #==================================================================================================== 99 | # print('-'*100) 100 | # print("*** GET TYPE PARAMETERS ***") 101 | # 102 | # wall_type = wall.WallType 103 | # wall_type_description = wall_type.get_Parameter(BuiltInParameter.ALL_MODEL_DESCRIPTION) 104 | # wall_type_mark = wall_type.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_MARK) 105 | # print(wall_type_description.AsString()) 106 | # print(wall_type_mark.AsString()) 107 | 108 | # ╔═╗╔═╗╔╦╗ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗ ╦ ╦╔═╗╦ ╦ ╦╔═╗ 109 | # ╚═╗║╣ ║ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝ ╚╗╔╝╠═╣║ ║ ║║╣ 110 | # ╚═╝╚═╝ ╩ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═ ╚╝ ╩ ╩╩═╝╚═╝╚═╝ SET PARAMETER VALUE 111 | #==================================================================================================== 112 | # GET PARAMETERS 113 | # wall_comments = wall.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS) 114 | # sp_area = wall.LookupParameter('sp_area') 115 | # sp_bool = wall.LookupParameter('sp_bool') 116 | # sp_float = wall.LookupParameter('sp_float') 117 | # sp_int = wall.LookupParameter('sp_int') 118 | # sp_length = wall.LookupParameter('sp_length') 119 | # sp_mat = wall.LookupParameter('sp_material') 120 | # sp_text = wall.LookupParameter('sp_text') 121 | 122 | # SET PARAMTERES 123 | # t = Transaction(doc, __title__) 124 | # t.Start() 125 | 126 | # # wall_comments.Set('That was terrible joke. Comment better jokes under my video.') 127 | # # print(wall_comments.AsString()) 128 | 129 | # sp_area.Set(555.55) 130 | # sp_bool.Set(1) 131 | # sp_float.Set(25.5) 132 | # sp_int.Set(100) 133 | # sp_length.Set(99.99) 134 | # new_mat_id = ElementId(414) 135 | # sp_mat.Set(new_mat_id) 136 | # sp_text.Set(str(1000)) 137 | # print('Setting parameters is complete.') 138 | # t.Commit() 139 | 140 | # ╔═╗╦ ╔═╗╔╗ ╔═╗╦ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗╔═╗ 141 | # ║ ╦║ ║ ║╠╩╗╠═╣║ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝╚═╗ 142 | # ╚═╝╩═╝╚═╝╚═╝╩ ╩╩═╝ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═╚═╝ GLOBAL PARAMETERS 143 | #==================================================================================================== 144 | # print('*** GLOBAL PARAMETERS ***') 145 | 146 | # GET ALL GLOBAL PARAMETERS 147 | # all_global_parameter_ids = GlobalParametersManager.GetAllGlobalParameters(doc) 148 | # 149 | # t = Transaction(doc,'Changing Global Parameters') 150 | # t.Start() 151 | 152 | # PRINT GLOBAL PARAMETERS DATA 153 | # for p_id in all_global_parameter_ids: 154 | # p = doc.GetElement(p_id) 155 | # print('Name: {}'.format(p.Name)) 156 | # print('GetDefinition: {}'.format(p.GetDefinition())) 157 | # print('GetFormula: {}'.format(p.GetFormula())) 158 | # print('GetValue: {}'.format(p.GetValue().Value)) 159 | # print('-'*50) 160 | 161 | # CHANGE GLOBAL PARAMETER VALUE OR FORMULA 162 | # new_value = StringParameterValue('New Value') 163 | # p.SetValue(new_value) 164 | # p.SetFormula('"New Formula"') 165 | 166 | 167 | # t.Commit() 168 | 169 | # ╔═╗╦ ╦╔═╗╔╦╗╔═╗╔╦╗ ╔╦╗╔═╗╔═╗╦ 170 | # ║ ║ ║╚═╗ ║ ║ ║║║║ ║ ║ ║║ ║║ 171 | # ╚═╝╚═╝╚═╝ ╩ ╚═╝╩ ╩ ╩ ╚═╝╚═╝╩═╝ 172 | #==================================================================================================== 173 | 174 | t = Transaction(doc,'Writing ElementIds to Mark parameter of Walls.') 175 | t.Start() 176 | 177 | # SET WALL ELEMENT-ID TO MARK 178 | all_walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements() 179 | 180 | for wall in all_walls: 181 | wall_mark = wall.get_Parameter(BuiltInParameter.ALL_MODEL_MARK) 182 | wall_mark.Set(str(wall.Id)) 183 | print(wall.Id) 184 | t.Commit() 185 | 186 | print('The script is complete. Comment ⌨ emoji in the comments if you following along.') 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/04 - FilteredElementCollector.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/04 - FilteredElementCollector.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/04 - FilteredElementCollector.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "04 - Samples: FilteredElementCollector" 3 | __helpurl__ = 'https://ko-fi.com/s/14b0b8e31c' 4 | __doc__ = """This script is from YouTube Tutorial about FilteredElementCollector 5 | You will learn how to use this class to get elements from your project. 6 | _____________________________________________________________________ 7 | Check out my E-Book on FilteredElementCollector and Filters on Ko_Fi page.""" 8 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 9 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 10 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 11 | # ================================================== 12 | # Regular + Autodesk 13 | from Autodesk.Revit.DB import * 14 | 15 | import clr 16 | clr.AddReference('System') 17 | from System.Collections.Generic import List 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 22 | # ================================================== 23 | doc = __revit__.ActiveUIDocument.Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | active_view = doc.ActiveView 28 | # ╔╦╗╔═╗╦╔╗╔ 29 | # ║║║╠═╣║║║║ 30 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 31 | # ================================================== 32 | 33 | # GET SIMPLE ELEMENTS 34 | all_rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements() 35 | all_walls = FilteredElementCollector(doc).OfClass(Wall).WhereElementIsNotElementType().ToElements() 36 | all_doors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements() 37 | all_windows = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsNotElementType().ToElements() 38 | 39 | # FILTER ELEMENTS 40 | all_views = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements() 41 | all_legends = [view for view in all_views if view.ViewType == ViewType.Legend] 42 | 43 | # GET ELEMENTS IN VIEW 44 | all_furn_in_view = FilteredElementCollector(doc, active_view.Id)\ 45 | .OfCategory(BuiltInCategory.OST_Furniture).WhereElementIsNotElementType().ToElements() 46 | 47 | # COMBINE MULTIPLE CATEGORIES - SIMPLE 48 | all_combined = list(all_rooms) + list(all_walls) + list(all_doors) 49 | # print(all_combined) 50 | 51 | # COMBINE MULTIPLE CATEGORIES - FILTERS 52 | categories = List[BuiltInCategory]([BuiltInCategory.OST_Walls, 53 | BuiltInCategory.OST_Floors, 54 | BuiltInCategory.OST_Roofs, 55 | BuiltInCategory.OST_Ceilings]) 56 | 57 | custom_filter = ElementMulticategoryFilter(categories) 58 | my_elements = FilteredElementCollector(doc).WherePasses(custom_filter).WhereElementIsElementType().ToElements() 59 | 60 | # WORKSET 61 | all_worksets = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset).ToWorksets() -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/05 - RevitAPI - CreateCopyDelete Elements.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/05 - RevitAPI - CreateCopyDelete Elements.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/05 - RevitAPI - CreateCopyDelete Elements.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "05 - Create/Delete/Copy Elements" 3 | __author__ = "Erik Frits" 4 | __version__ = "Version 1.0" 5 | __doc__ = """Version = 1.0 6 | Date = 18.09.2022 7 | _____________________________________________________________________ 8 | Description: 9 | Code from YouTube tutorial about Creating/Deleting/Copying Elements 10 | using Revit API. 11 | _____________________________________________________________________ 12 | Author: Erik Frits""" 13 | 14 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 15 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 16 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 17 | #==================================================================================================== 18 | from Autodesk.Revit.DB import * 19 | from Autodesk.Revit.DB.Structure import StructuralType 20 | 21 | #.NET IMPORTS 22 | import clr 23 | clr.AddReference('System') 24 | from System.Collections.Generic import List 25 | 26 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 27 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 28 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ 29 | #==================================================================================================== 30 | doc = __revit__.ActiveUIDocument.Document 31 | uidoc = __revit__.ActiveUIDocument 32 | app = __revit__.Application 33 | 34 | active_view = doc.ActiveView 35 | active_level = doc.ActiveView.GenLevel 36 | 37 | # ╔╦╗╔═╗╦╔╗╔ 38 | # ║║║╠═╣║║║║ 39 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 40 | #==================================================================================================== 41 | with Transaction(doc,__title__) as t: 42 | t.Start() 43 | #CHANGES HERE 44 | 45 | 46 | # ╔╦╗╔═╗═╗ ╦╔╦╗ 47 | # ║ ║╣ ╔╩╦╝ ║ 48 | # ╩ ╚═╝╩ ╚═ ╩ TEXT 49 | # ================================================== 50 | # ARGUMENTS 51 | # text_type_id = FilteredElementCollector(doc).OfClass(TextNoteType).FirstElementId() 52 | # pt = XYZ(0,0,0) 53 | # text = 'Hello BIM World!' 54 | # # CREATE TEXT NOTE 55 | # TextNote.Create(doc, active_view.Id, pt, text, text_type_id) 56 | 57 | # ╦═╗╔═╗╔═╗╔╦╗ 58 | # ╠╦╝║ ║║ ║║║║ 59 | # ╩╚═╚═╝╚═╝╩ ╩ ROOM 60 | #================================================== 61 | # # ARGUMENTS 62 | # pt = UV(10,0) 63 | # 64 | # # CREATE ROOM 65 | # room = doc.Create.NewRoom(active_level, pt) 66 | # 67 | # # CREATE ROOM TAG 68 | # room_link = LinkElementId(room.Id) 69 | # doc.Create.NewRoomTag(room_link, pt, active_view.Id ) 70 | 71 | # ╦ ╦╔╗╔╔═╗╔═╗ 72 | # ║ ║║║║║╣ ╚═╗ 73 | # ╩═╝╩╝╚╝╚═╝╚═╝ DETAIL LINES 74 | # ================================================== 75 | # ARGUMENTS 76 | # pt_start = XYZ(20,0,0) 77 | # pt_end = XYZ(20,5,0) 78 | # curve = Line.CreateBound(pt_start, pt_end) 79 | # 80 | # CREATE DETAIL LINE 81 | # detail_line = doc.Create.NewDetailCurve(active_view, curve) 82 | 83 | # ╦ ╦╔═╗╦ ╦ ╔═╗ 84 | # ║║║╠═╣║ ║ ╚═╗ 85 | # ╚╩╝╩ ╩╩═╝╩═╝╚═╝ WALLS 86 | #================================================== 87 | # # ARGUMENTS 88 | # pt_start = XYZ(30,0,0) 89 | # pt_end = XYZ(30,5,0) 90 | # curve = Line.CreateBound(pt_start, pt_end) 91 | # 92 | # # CREATE A WALL 93 | # wall = Wall.Create(doc, curve, active_level.Id, False) 94 | 95 | # ╦ ╦╦╔╗╔╔╦╗╔═╗╦ ╦╔═╗ 96 | # ║║║║║║║ ║║║ ║║║║╚═╗ 97 | # ╚╩╝╩╝╚╝═╩╝╚═╝╚╩╝╚═╝ WINDOWS 98 | #================================================== 99 | # # ARGUMENTS 100 | # host_wall = doc.GetElement(ElementId(779500)) 101 | # pt_start = XYZ(30,0,0) 102 | # pt_end = XYZ(30,5,0) 103 | # pt_mid = (pt_start + pt_end) /2 104 | # window_type = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows)\ 105 | # .WhereElementIsElementType().FirstElement() 106 | # 107 | # # CREATE A WINDOW 108 | # window = doc.Create.NewFamilyInstance(pt_mid, window_type, host_wall, StructuralType.NonStructural ) 109 | 110 | # ╔═╗╔═╗╔╦╗╦╦ ╦ ╦ ╦╔╗╔╔═╗╔╦╗╔═╗╔╗╔╔═╗╔═╗ 111 | # ╠╣ ╠═╣║║║║║ ╚╦╝ ║║║║╚═╗ ║ ╠═╣║║║║ ║╣ 112 | # ╚ ╩ ╩╩ ╩╩╩═╝╩ ╩╝╚╝╚═╝ ╩ ╩ ╩╝╚╝╚═╝╚═╝ FAMILY INSTANCE 113 | #================================================== 114 | # # EXTRA FUNCTION 115 | # def get_type_by_name(type_name): 116 | # """Extra Function to get Family Type by name.""" 117 | # # CREATE RULE 118 | # param_type = ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME) 119 | # f_param = ParameterValueProvider(param_type) 120 | # evaluator = FilterStringEquals() 121 | # f_rule = FilterStringRule(f_param, evaluator, type_name, True) # Revit 2023 does not need last argument! 122 | # 123 | # # CREATE FILTER 124 | # filter_type_name = ElementParameterFilter(f_rule) 125 | # 126 | # # GET ELEMENTS 127 | # return FilteredElementCollector(doc).WherePasses(filter_type_name).WhereElementIsElementType().FirstElement() 128 | # 129 | # # ARGUMENTS 130 | # pt = XYZ(40,5,0) 131 | # symbol = get_type_by_name('Placeholder - Type B') 132 | # 133 | # # CREATE AN ELEMENT 134 | # element = doc.Create.NewFamilyInstance(pt, symbol, StructuralType.NonStructural) 135 | 136 | 137 | # ╔═╗╦ ╦╔═╗╔═╗╔╦╗╔═╗ 138 | # ╚═╗╠═╣║╣ ║╣ ║ ╚═╗ 139 | # ╚═╝╩ ╩╚═╝╚═╝ ╩ ╚═╝ SHEETS 140 | #================================================== 141 | # # ARGUMENTS 142 | # title_block_id = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks)\ 143 | # .WhereElementIsNotElementType().FirstElementId() 144 | # 145 | # # CREATE SHEET 146 | # new_sheet = ViewSheet.Create(doc, title_block_id) 147 | # new_sheet.SheetNumber = 'Random Sheet Number' #<- Unique ! 148 | # new_sheet.Name = 'Random Name' 149 | 150 | # ╦ ╦╦╔═╗╦ ╦╔═╗ 151 | # ╚╗╔╝║║╣ ║║║╚═╗ 152 | # ╚╝ ╩╚═╝╚╩╝╚═╝ VIEWS 153 | #================================================== 154 | # # ARGUMENTS 155 | # all_view_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements() 156 | # view_3D_type = [vt for vt in all_view_types if vt.ViewFamily == ViewFamily.ThreeDimensional][0] 157 | # 158 | # # CREATE 3D VIEW 159 | # new_3D = View3D.CreateIsometric(doc, view_3D_type.Id) 160 | 161 | # ╦═╗╔═╗╔═╗╦╔═╗╔╗╔ 162 | # ╠╦╝║╣ ║ ╦║║ ║║║║ 163 | # ╩╚═╚═╝╚═╝╩╚═╝╝╚╝ REGION 164 | #================================================== 165 | # # ARGUMENTS 166 | # region_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType) 167 | # 168 | # # POINTS 169 | # pt_0 = XYZ(50, 0, 0) 170 | # pt_1 = XYZ(55, 0, 0) 171 | # pt_2 = XYZ(55, 5, 0) 172 | # pt_3 = XYZ(50, 5, 0) 173 | # 174 | # # LINES 175 | # l_0 = Line.CreateBound(pt_0, pt_1) 176 | # l_1 = Line.CreateBound(pt_1, pt_2) 177 | # l_2 = Line.CreateBound(pt_2, pt_3) 178 | # l_3 = Line.CreateBound(pt_3, pt_0) 179 | # 180 | # # BOUNDARY 181 | # boundary = CurveLoop() 182 | # boundary.Append(l_0) 183 | # boundary.Append(l_1) 184 | # boundary.Append(l_2) 185 | # boundary.Append(l_3) 186 | # 187 | # # LIST OF BOUNDARIES 188 | # list_boundaries = List[CurveLoop]() 189 | # list_boundaries.Add(boundary) 190 | # 191 | # # CREATE FILLED REGION 192 | # region = FilledRegion.Create(doc, region_type_id, active_view.Id, list_boundaries) 193 | 194 | # ╔═╗╦ ╔═╗╔═╗╦═╗ 195 | # ╠╣ ║ ║ ║║ ║╠╦╝ 196 | # ╚ ╩═╝╚═╝╚═╝╩╚═ FLOOR 197 | #================================================== 198 | # # ARGUMENTS 199 | # floor_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FloorType) 200 | # floor_type = doc.GetElement(floor_type_id) 201 | # 202 | # # POINTS 203 | # pt_0 = XYZ(60, 0, 0) 204 | # pt_1 = XYZ(65, 0, 0) 205 | # pt_2 = XYZ(65, 5, 0) 206 | # pt_3 = XYZ(60, 5, 0) 207 | # 208 | # # LINES 209 | # l_0 = Line.CreateBound(pt_0, pt_1) 210 | # l_1 = Line.CreateBound(pt_1, pt_2) 211 | # l_2 = Line.CreateBound(pt_2, pt_3) 212 | # l_3 = Line.CreateBound(pt_3, pt_0) 213 | # 214 | # # BOUNDARY 215 | # boundary = CurveArray() 216 | # boundary.Append(l_0) 217 | # boundary.Append(l_1) 218 | # boundary.Append(l_2) 219 | # boundary.Append(l_3) 220 | # 221 | # # CREATE FLOOR 222 | # new_floor = doc.Create.NewFloor(boundary, floor_type, active_level, False) 223 | 224 | # ╔═╗╔═╗╔═╗╦ ╦ ╔═╗╦ ╔═╗╔╦╗╔═╗╔╗╔╔╦╗╔═╗ 225 | # ║ ║ ║╠═╝╚╦╝ ║╣ ║ ║╣ ║║║║╣ ║║║ ║ ╚═╗ 226 | # ╚═╝╚═╝╩ ╩ ╚═╝╩═╝╚═╝╩ ╩╚═╝╝╚╝ ╩ ╚═╝ COPY ELEMENTS 227 | # ================================================== 228 | # # GET ELEMENTS TO COPY 229 | # all_floors_in_view = FilteredElementCollector(doc, active_view.Id).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElementIds() 230 | # elements_to_copy = List[ElementId](all_floors_in_view) 231 | # 232 | # # COPY ELEMENTS (Multiple Times) 233 | # for i in range(1,6): 234 | # vector = XYZ(2*i, 10*i, 0) 235 | # ElementTransformUtils.CopyElements(doc, elements_to_copy, vector) 236 | 237 | # ╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗ ╔═╗╦ ╔═╗╔╦╗╔═╗╔╗╔╔╦╗╔═╗ 238 | # ║║║╣ ║ ║╣ ║ ║╣ ║╣ ║ ║╣ ║║║║╣ ║║║ ║ ╚═╗ 239 | # ═╩╝╚═╝╩═╝╚═╝ ╩ ╚═╝ ╚═╝╩═╝╚═╝╩ ╩╚═╝╝╚╝ ╩ ╚═╝ DELETE ELEMENTS 240 | # ================================================== 241 | # # # GET ELEMENTS TO COPY 242 | # all_floors_in_view = FilteredElementCollector(doc, active_view.Id).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElementIds() 243 | # element_to_delete = List[ElementId](all_floors_in_view) 244 | # 245 | # # DELETE ELEMENTS 246 | # doc.Delete(element_to_delete) 247 | 248 | t.Commit() 249 | 250 | 251 | 252 | 253 | 254 | #⬇ IMPORTS 255 | from Autodesk.Revit.DB import * 256 | 257 | 258 | 259 | #📦 VARIABLES 260 | doc = __revit__.ActiveUIDocument.Document 261 | active_view = doc.ActiveView 262 | active_level = doc.ActiveView.GenLevel 263 | 264 | #🎴 ALL VIEW TYPES 265 | view_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements() 266 | 267 | #🔎 FILTER CERTAIN VIEW TYPES 268 | view_types_plans = [vt for vt in view_types if vt.ViewFamily == ViewFamily.FloorPlan] 269 | view_types_sections = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Section] 270 | view_types_3D = [vt for vt in view_types if vt.ViewFamily == ViewFamily.ThreeDimensional] 271 | view_types_legends = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Legend] 272 | view_types_drafting = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Drafting] 273 | view_types_elevations = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Elevation] 274 | view_types_ceil_views = [vt for vt in view_types if vt.ViewFamily == ViewFamily.CeilingPlan] 275 | view_types_structural = [vt for vt in view_types if vt.ViewFamily == ViewFamily.StructuralPlan] 276 | view_types_area = [vt for vt in view_types if vt.ViewFamily == ViewFamily.AreaPlan] 277 | view_types_sheet = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Sheet] 278 | 279 | 280 | 281 | 282 | def create_element_section(curve, origin, H=5,W=5,D=5, offset =0): 283 | #type:(Curve, XYZ, float,float,float,float) -> ViewSection 284 | """This function will generate a ViewSection with a special crop. 285 | :param curve: Curve for taking vector of orientation of the section. 286 | :param origin: XYZ Point from where all dimensions will be taken 287 | :param H: Height 288 | :param W: Width 289 | :param D: Depth 290 | :param offset: Offset from H,W,D to make a little more space 291 | :return: generated ViewSection""" 292 | Thanks_to = """Thanks to martin.marek for his Snippet. It saved me a lot of time! 293 | https://forum.dynamobim.com/t/create-section-view-of-the-wall-by-python/44986/6""" 294 | 295 | pt_start = curve.GetEndPoint(0) 296 | pt_end = curve.GetEndPoint(1) 297 | vector = pt_end - pt_start 298 | 299 | 300 | # SECTION - DIRECTION 301 | fc = -1 302 | if pt_start.X > pt_end.X or (pt_start.X == pt_end.X and pt_start.Y < pt_end.Y): 303 | fc = 1 304 | 305 | # SECTION - ORIENTATION 306 | curvedir = fc * vector.Normalize() 307 | 308 | t = Transform.Identity 309 | t.Origin = origin 310 | t.BasisX = curvedir 311 | t.BasisY = XYZ.BasisZ 312 | t.BasisZ = curvedir.CrossProduct(XYZ.BasisZ) 313 | 314 | # SECTION - CROPBOX 315 | sectionBox = BoundingBoxXYZ() 316 | sectionBox.Transform = t #apply orientation 317 | sectionBox.Min = XYZ(W*-0.5 -offset, 0 -offset, D*-0.5 -offset) 318 | sectionBox.Max = XYZ(W* 0.5 +offset, H +offset, D* 0.5 +offset) 319 | 320 | # SECTION - VIEWTYPE 321 | view_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements() 322 | SC_view_types = [v for v in view_types if v.ViewFamily == ViewFamily.Section] 323 | SC_Type = SC_view_types[0] 324 | 325 | # CREATE SECTION 326 | view_section = ViewSection.CreateSection(doc, SC_Type.Id, sectionBox) 327 | 328 | # ACTIVATE CROP 329 | view_section.get_Parameter(BuiltInParameter.VIEWER_CROP_REGION).Set(1) 330 | 331 | return view_section 332 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/06 - CopyElements.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/06 - CopyElements.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/06 - CopyElements.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "06 - Copy Elements" 3 | __doc__ = """Date = 22.10.2022 4 | _____________________________________________________________________ 5 | Description: 6 | Script from a YouTube Tutorial about copying Elements. 7 | _____________________________________________________________________ 8 | Author: Erik Frits""" 9 | 10 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 11 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 12 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 13 | #======================================================================================= 14 | from Autodesk.Revit.DB import * 15 | 16 | #pyRevit 17 | from pyrevit.forms import select_views 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ 22 | #======================================================================================= 23 | doc = __revit__.ActiveUIDocument.Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | #🟢 ╔═╗╔═╗╔═╗╦ ╦ ╦ ╦╦╔╦╗╦ ╦ ╦ ╦╔═╗╔═╗╔╦╗╔═╗╦═╗ 28 | #🟢 ║ ║ ║╠═╝╚╦╝ ║║║║ ║ ╠═╣ ╚╗╔╝║╣ ║ ║ ║ ║╠╦╝ 29 | #🟢 ╚═╝╚═╝╩ ╩ ╚╩╝╩ ╩ ╩ ╩ ╚╝ ╚═╝╚═╝ ╩ ╚═╝╩╚═ COPY WITH VECTOR 30 | #======================================================================================= 31 | # 👉 Get Walls 32 | wallsToCopy = FilteredElementCollector(doc)\ 33 | .OfCategory(BuiltInCategory.OST_Walls)\ 34 | .WhereElementIsNotElementType()\ 35 | .ToElementIds() 36 | 37 | #📐 Vector 38 | vector = XYZ(50, 50, 0) 39 | 40 | #🔓 Start Transaction 41 | t = Transaction(doc, __title__) 42 | t.Start() 43 | 44 | #✅ Copy Elements 45 | ElementTransformUtils.CopyElements(doc, wallsToCopy, vector) 46 | 47 | #🔒 End Transaction 48 | t.Commit() 49 | 50 | 51 | #🟡 ╔═╗╔═╗╔═╗╦ ╦ ╔╗ ╔═╗╔╦╗╦ ╦╔═╗╔═╗╔╗╔ ╦ ╦╦╔═╗╦ ╦╔═╗ 52 | #🟡 ║ ║ ║╠═╝╚╦╝ ╠╩╗║╣ ║ ║║║║╣ ║╣ ║║║ ╚╗╔╝║║╣ ║║║╚═╗ 53 | #🟡 ╚═╝╚═╝╩ ╩ ╚═╝╚═╝ ╩ ╚╩╝╚═╝╚═╝╝╚╝ ╚╝ ╩╚═╝╚╩╝╚═╝ COPY BETWEEN VIEWS 54 | #======================================================================================= 55 | 56 | #👉 Get TextNotes 57 | textToCopy = FilteredElementCollector(doc, doc.ActiveView.Id)\ 58 | .OfCategory(BuiltInCategory.OST_TextNotes)\ 59 | .WhereElementIsNotElementType()\ 60 | .ToElementIds() 61 | 62 | #👁️ ️Get Views 63 | src_view = doc.ActiveView 64 | dest_view = select_views(__title__,multiple=False) 65 | 66 | #⚙ Transform & Options 67 | transform = Transform.Identity 68 | opts = CopyPasteOptions() 69 | 70 | #🔓 Start Transaction 71 | t = Transaction(doc, __title__) 72 | t.Start() 73 | 74 | #✅ Copy Elements 75 | ElementTransformUtils.CopyElements(src_view, textToCopy, dest_view, transform, opts) 76 | 77 | #🔒 End Transaction 78 | t.Commit() 79 | 80 | 81 | #🟠 ╔═╗╔═╗╔═╗╦ ╦ ╔╗ ╔═╗╔╦╗╦ ╦╔═╗╔═╗╔╗╔ ╔═╗╦═╗╔═╗ ╦╔═╗╔═╗╔╦╗╔═╗ 82 | #🟠 ║ ║ ║╠═╝╚╦╝ ╠╩╗║╣ ║ ║║║║╣ ║╣ ║║║ ╠═╝╠╦╝║ ║ ║║╣ ║ ║ ╚═╗ 83 | #🟠 ╚═╝╚═╝╩ ╩ ╚═╝╚═╝ ╩ ╚╩╝╚═╝╚═╝╝╚╝ ╩ ╩╚═╚═╝╚╝╚═╝╚═╝ ╩ ╚═╝ COPY BETWEEN PROJECTS 84 | #======================================================================================= 85 | # 👉 Get Walls 86 | wallsToCopy = FilteredElementCollector(doc)\ 87 | .OfCategory(BuiltInCategory.OST_Walls)\ 88 | .WhereElementIsNotElementType()\ 89 | .ToElementIds() 90 | 91 | 92 | #🏠 Get all Docs 93 | all_docs = list(app.Documents) 94 | doc_A = all_docs[0] 95 | doc_B = all_docs[1] 96 | 97 | 98 | #⚙ Transform & Options 99 | transform = Transform.Identity 100 | opts = CopyPasteOptions() 101 | 102 | #🔓 Start Transaction 103 | t = Transaction(doc_B, __title__) 104 | t.Start() 105 | 106 | #✅ Copy Elements 107 | ElementTransformUtils.CopyElements(doc_A, wallsToCopy, doc_B, transform, opts) 108 | 109 | #🔒 End Transaction 110 | t.Commit() 111 | 112 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/07 - FurnitureRooms.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/07 - FurnitureRooms.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/07 - FurnitureRooms.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "07 - Furniture Rooms" 3 | __doc__ = """Date = 19.03.2023 4 | Get all Furniture and Plumbing elements and write Room's name 5 | if available to a comment Parameter. 6 | _____________________________________________________________________ 7 | Author: Erik Frits""" 8 | 9 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 10 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 11 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 12 | #================================================== 13 | from Autodesk.Revit.DB import * 14 | from Autodesk.Revit.UI import UIDocument, UIApplication 15 | 16 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 17 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 18 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 19 | #================================================== 20 | uidoc = __revit__.ActiveUIDocument #type: UIDocument 21 | doc = __revit__.ActiveUIDocument.Document #type: Document 22 | app = __revit__.Application #type: UIApplication 23 | 24 | all_phases = list(doc.Phases) 25 | phase = all_phases[-1] 26 | 27 | # ╔╦╗╔═╗╦╔╗╔ 28 | # ║║║╠═╣║║║║ 29 | # ╩ ╩╩ ╩╩╝╚╝ 30 | #================================================== 31 | 32 | #1️⃣ Get Elements 33 | all_furniture = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Furniture).WhereElementIsNotElementType().ToElements() 34 | all_f_systems = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_FurnitureSystems).WhereElementIsNotElementType().ToElements() 35 | all_plumbing = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PlumbingFixtures).WhereElementIsNotElementType().ToElements() 36 | 37 | all_elements = list(all_furniture) + list(all_f_systems) + list(all_plumbing) 38 | 39 | # 🔓 Start Transaction 40 | t = Transaction(doc, __title__) 41 | t.Start() 42 | 43 | #2️⃣ Iterate and get Rooms 44 | for el in all_elements: 45 | room = el.Room[phase] 46 | # print(room) 47 | if room: 48 | #3️⃣ Read Room Name and Number 49 | # room_name = Element.Name.GetValue(room) 50 | room_name = room.get_Parameter(BuiltInParameter.ROOM_NAME).AsString() 51 | room_number = room.Number 52 | 53 | #4️⃣ Get Element Parameters 54 | p_room_name = el.LookupParameter('Room Name') 55 | p_room_number = el.LookupParameter('Room Number') 56 | 57 | #5️⃣ Write Room Name and Number to Parameters 58 | if p_room_name: 59 | p_room_name.Set(room_name) 60 | 61 | if p_room_number: 62 | p_room_number.Set(room_number) 63 | 64 | t.Commit() 65 | 66 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/08 - CreateElementsLibrary.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/08 - CreateElementsLibrary.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/08 - CreateElementsLibrary.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "08 - Create Library of Elements" 3 | __doc__ = """Date = 22.10.2022 4 | _____________________________________________________________________ 5 | Description: 6 | Script from a video Tutorial for my Ko-Fi and Patreon supporters. 7 | _____________________________________________________________________ 8 | Author: Erik Frits""" 9 | __context__ = 'active-floor-plan' 10 | 11 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 12 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 13 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 14 | #==================================================================================================== 15 | from Autodesk.Revit.DB import * 16 | 17 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 18 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 19 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ 20 | #==================================================================================================== 21 | doc = __revit__.ActiveUIDocument.Document 22 | uidoc = __revit__.ActiveUIDocument 23 | app = __revit__.Application 24 | 25 | active_view = doc.ActiveView 26 | active_level = doc.ActiveView.GenLevel 27 | 28 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 29 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 30 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ 31 | #==================================================================================================== 32 | def create_text(origin, text_type): 33 | """Function to create TextNote at the given location. 34 | TextType Name is going to be used as a Text.""" 35 | text = text_type.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString() 36 | 37 | # CREATE TEXT NOTE 38 | txt = TextNote.Create(doc, active_view.Id, origin, text, text_type.Id) 39 | return txt 40 | 41 | def create_wall(origin, wall_type): 42 | """Function to create a Wall at the given location.""" 43 | pt_start = origin 44 | pt_end = XYZ(origin.X + 2, origin.Y, origin.Z) 45 | curve = Line.CreateBound(pt_start, pt_end) 46 | 47 | H = 10 48 | O = 0 49 | flip = False 50 | struc = False 51 | 52 | wall = Wall.Create(doc, curve, wall_type.Id, active_level.Id, H, O, flip, struc) 53 | return wall 54 | 55 | 56 | def create_floor(origin, floor_type): 57 | """Function to create a Floor at the given location.""" 58 | # POINTS 59 | pt_0 = origin 60 | pt_1 = XYZ(origin.X+1 , origin.Y , origin.Z) 61 | pt_2 = XYZ(origin.X+1 , origin.Y+1 , origin.Z) 62 | pt_3 = XYZ(origin.X , origin.Y+1 , origin.Z) 63 | 64 | # LINES 65 | l_0 = Line.CreateBound(pt_0, pt_1) 66 | l_1 = Line.CreateBound(pt_1, pt_2) 67 | l_2 = Line.CreateBound(pt_2, pt_3) 68 | l_3 = Line.CreateBound(pt_3, pt_0) 69 | 70 | # BOUNDARY 71 | boundary = CurveArray() 72 | boundary.Append(l_0) 73 | boundary.Append(l_1) 74 | boundary.Append(l_2) 75 | boundary.Append(l_3) 76 | 77 | # CREATE FLOOR 78 | new_floor = doc.Create.NewFloor(boundary, floor_type, active_level, False) 79 | return new_floor 80 | 81 | # ╔╦╗╔═╗╦╔╗╔ 82 | # ║║║╠═╣║║║║ 83 | # ╩ ╩╩ ╩╩╝╚╝ 84 | #==================================================================================================== 85 | # Get Types 86 | all_walls_types = FilteredElementCollector(doc).OfClass(WallType).ToElements() 87 | all_floors_types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).OfClass(FloorType).ToElements() 88 | all_text_types = FilteredElementCollector(doc).OfClass(TextNoteType).ToElements() 89 | 90 | #🔵 ORIGIN 91 | X = 0 92 | Y = 0 93 | Z = 0 94 | 95 | 96 | #🔓 Transaction - Start 97 | t = Transaction(doc, __title__) 98 | t.Start() 99 | 100 | 101 | #✅ Create TextTypes 102 | for txt_type in all_text_types: 103 | origin = XYZ(X,Y,Z) 104 | create_text(origin, txt_type) 105 | Y -= 2 106 | 107 | X += 15 108 | Y = 0 109 | 110 | #✅ Create WallType 111 | for wall_type in all_walls_types: 112 | origin = XYZ(X,Y,Z) 113 | create_wall(origin, wall_type) 114 | Y -= 2 115 | 116 | X += 15 117 | Y = 0 118 | 119 | #✅ Create FloorType 120 | for floor_type in all_floors_types: 121 | origin = XYZ(X,Y,Z) 122 | create_floor(origin, floor_type) 123 | Y -= 2 124 | 125 | 126 | #🔒 Transaction - Commit 127 | t.Commit() 128 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/09 - RandomizeParameter.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/09 - RandomizeParameter.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/09 - RandomizeParameter.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "09 - Randomize Parameter (+ Custom UI)" 3 | __doc__ = """Date = 22.04.2023 4 | Randomize Parameter Values for specific Families 5 | _____________________________________________________________________ 6 | Author: Erik Frits""" 7 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 8 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 9 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 10 | #================================================== 11 | import random 12 | from Autodesk.Revit.DB import * 13 | from Autodesk.Revit.UI import UIDocument, UIApplication 14 | 15 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 16 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 17 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 18 | #================================================== 19 | uidoc = __revit__.ActiveUIDocument #type: UIDocument 20 | doc = __revit__.ActiveUIDocument.Document #type: Document 21 | app = __revit__.Application #type: UIApplication 22 | rvt_year = int(app.VersionNumber) 23 | 24 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 25 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 26 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS 27 | #================================================== 28 | def get_elements_by_type_name(type_name): 29 | """Function to get Elements by Type Name.""" 30 | 31 | # CREATE RULE 32 | param_id = ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME) 33 | f_param = ParameterValueProvider(param_id) 34 | f_evaluator = FilterStringEquals() 35 | f_rule = FilterStringRule(f_param, f_evaluator , type_name, True) 36 | # Revit 2023 does not need last argument in f_rule! 37 | 38 | # CREATE FILTER 39 | filter_type_name = ElementParameterFilter(f_rule) 40 | 41 | # GET ELEMENTS 42 | return FilteredElementCollector(doc).WherePasses(filter_type_name)\ 43 | .WhereElementIsNotElementType().ToElements() 44 | 45 | 46 | 47 | def get_elements_by_family_name(family_name): 48 | """Function to get Elements by Family Name.""" 49 | 50 | # CREATE RULE 51 | param_id = ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME) 52 | f_param = ParameterValueProvider(param_id) 53 | f_evaluator = FilterStringEquals() 54 | f_rule = FilterStringRule(f_param, f_evaluator , family_name, True) 55 | # Revit 2023 does not need last argument in f_rule! 56 | 57 | # CREATE FILTER 58 | filter_family_name = ElementParameterFilter(f_rule) 59 | 60 | # GET ELEMENTS 61 | return FilteredElementCollector(doc).WherePasses(filter_family_name)\ 62 | .WhereElementIsNotElementType().ToElements() 63 | 64 | 65 | def convert_internal_units(value, get_internal = True, units='m'): 66 | #type: (float, bool, str) -> float 67 | """Function to convert Internal units to meters or vice versa. 68 | :param value: Value to convert 69 | :param get_internal: True to get internal units, False to get Meters 70 | :param units: Select desired Units: ['m', 'm2'] 71 | :return: Length in Internal units or Meters.""" 72 | 73 | if rvt_year >= 2021: 74 | from Autodesk.Revit.DB import UnitTypeId 75 | if units == 'm' : units = UnitTypeId.Meters 76 | elif units == "m2": units = UnitTypeId.SquareMeters 77 | elif units == 'cm': units = UnitTypeId.Centimeters 78 | else: 79 | from Autodesk.Revit.DB import DisplayUnitType 80 | if units == 'm' : units = DisplayUnitType.DUT_METERS 81 | elif units == "m2": units = DisplayUnitType.DUT_SQUARE_METERS 82 | elif units == "cm": units = DisplayUnitType.DUT_CENTIMETERS 83 | 84 | if get_internal: 85 | return UnitUtils.ConvertToInternalUnits(value, units) 86 | return UnitUtils.ConvertFromInternalUnits(value, units) 87 | 88 | def random_step(_min, _max, _step): 89 | return random.randrange(_min, _max+1, _step) 90 | 91 | 92 | # ╔╦╗╔═╗╦╔╗╔ 93 | # ║║║╠═╣║║║║ 94 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 95 | #================================================== 96 | 97 | # 1️⃣ Variables 98 | # family_name = 'Vertical Blade' 99 | # type_name = 'Vertical Blade' 100 | # param_name = 'Tiefe' 101 | # _min = 40 102 | # _max = 250 103 | # _step = 10 104 | 105 | # 🔷 Bonus: Custom UI 106 | from rpw.ui.forms import (FlexForm, Label, ComboBox, TextBox, TextBox,Separator, Button, CheckBox) 107 | 108 | # Define UI Components 109 | components = [Label("Element's Type Name:"), TextBox('type_name', Text="Vertical Blade"), 110 | Label('Parameter Name:'), TextBox('param_name', Text="Tiefe"), 111 | Separator(), 112 | Label('Min Value(in cm):'), TextBox('_min', Text="40"), 113 | Label('Max Value(in cm):'), TextBox('_max', Text="250"), 114 | Label('Step Value(in cm):'), TextBox('_step', Text="10"), 115 | Separator(), 116 | Button('Select')] 117 | 118 | # Create UI Form + Show it 119 | form = FlexForm(__title__, components) 120 | form.show() 121 | 122 | # Get All Values (as dict) 123 | values = form.values 124 | 125 | # Read Values 126 | type_name = values['type_name'] 127 | param_name = values['param_name'] 128 | _min = float(values['_min']) 129 | _max = float(values['_max']) 130 | _step = float(values['_step']) 131 | 132 | 133 | 134 | # 2️⃣ Get Elements 135 | elements = get_elements_by_type_name(type_name) 136 | # elements = get_elements_by_family_name(family_name) 137 | 138 | 139 | # 3️⃣ Write Random Parmaeter Values 140 | 141 | t = Transaction(doc, __title__) 142 | t.Start() #🔓 143 | 144 | for el in elements: 145 | p = el.LookupParameter(param_name) 146 | if p: 147 | value_cm = random_step(_min, _max, _step) 148 | value_ft = convert_internal_units(value_cm, get_internal=True, units='cm') 149 | p.Set(value_ft) 150 | 151 | t.Commit() #🔒 152 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/10 - ElementParameterFilter.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/10 - ElementParameterFilter.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/10 - ElementParameterFilter.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "10 - ElementParameterFilter" 3 | __doc__ = """Version = 1.0 4 | Date = 11.11.2023 5 | _____________________________________________________________________ 6 | Description: 7 | Example of using ElementParameterFilter. 8 | - Get Element by Type Name 9 | - Get Element by Family Name 10 | - Get Walls higher than x Meters 11 | _____________________________________________________________________ 12 | Author: Erik Frits""" 13 | 14 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 15 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 16 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 17 | # ================================================== 18 | # Regular + Autodesk 19 | from Autodesk.Revit.DB import * 20 | 21 | # .NET Imports 22 | import clr 23 | clr.AddReference("System") 24 | from System.Collections.Generic import List 25 | 26 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 27 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 28 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 29 | # ================================================== 30 | doc = __revit__.ActiveUIDocument.Document 31 | uidoc = __revit__.ActiveUIDocument 32 | app = __revit__.Application 33 | 34 | 35 | # ╔╦╗╔═╗╦╔╗╔ 36 | # ║║║╠═╣║║║║ 37 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 38 | # ================================================== 39 | # 40 | # #1️⃣ Parameter 41 | # p_fam_id = ElementId(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM) 42 | # f_param = ParameterValueProvider(p_fam_id) 43 | # 44 | # #2️⃣ Evaluator 45 | # evaluator = FilterStringContains() 46 | # 47 | # #3️⃣ Value 48 | # value = 'FE TÜR' 49 | # 50 | # #4️⃣ Rule 51 | # rvt_year = int(app.VersionNumber) 52 | # if rvt_year >= 2023: 53 | # f_rule = FilterStringRule(f_param, evaluator, value) 54 | # else: 55 | # f_rule = FilterStringRule(f_param, evaluator, value, False) 56 | # 57 | # 58 | # #5️⃣ Filter 59 | # filter_fam_name = ElementParameterFilter(f_rule) 60 | # 61 | # #6️⃣ Apply Filter to FEC 62 | # element_ids = FilteredElementCollector(doc)\ 63 | # .OfCategory(BuiltInCategory.OST_Windows)\ 64 | # .WherePasses(filter_fam_name)\ 65 | # .WhereElementIsNotElementType()\ 66 | # .ToElementIds() 67 | # 68 | # #👉 Select Elements 69 | # uidoc.Selection.SetElementIds(element_ids) 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | def get_elements_by_family_name(family_name): 82 | """Function to get Elements by Family Name""" 83 | #1️⃣ Parameter 84 | p_fam_id = ElementId(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM) 85 | f_param = ParameterValueProvider(p_fam_id) 86 | 87 | #2️⃣ Evaluator 88 | evaluator = FilterStringEquals() 89 | 90 | #3️⃣ Value 91 | value = family_name 92 | 93 | #4️⃣ Rule 94 | rvt_year = int(app.VersionNumber) 95 | if rvt_year >= 2023: 96 | f_rule = FilterStringRule(f_param, evaluator, value) 97 | else: 98 | f_rule = FilterStringRule(f_param, evaluator, value, False) 99 | 100 | 101 | #5️⃣ Filter 102 | filter_fam_name = ElementParameterFilter(f_rule) 103 | 104 | #6️⃣ Apply Filter to FEC 105 | return FilteredElementCollector(doc)\ 106 | .WherePasses(filter_fam_name)\ 107 | .WhereElementIsNotElementType()\ 108 | .ToElements() 109 | 110 | 111 | def get_elements_by_type_name(type_name): 112 | """Function to get Elements by Family Name""" 113 | #1️⃣ Parameter 114 | p_type_id = ElementId(BuiltInParameter.SYMBOL_NAME_PARAM) 115 | f_param = ParameterValueProvider(p_type_id) 116 | 117 | #2️⃣ Evaluator 118 | evaluator = FilterStringEquals() 119 | 120 | #3️⃣ Value 121 | value = type_name 122 | 123 | #4️⃣ Rule 124 | rvt_year = int(app.VersionNumber) 125 | if rvt_year >= 2023: 126 | f_rule = FilterStringRule(f_param, evaluator, value) 127 | else: 128 | f_rule = FilterStringRule(f_param, evaluator, value, False) 129 | 130 | 131 | #5️⃣ Filter 132 | filter_fam_name = ElementParameterFilter(f_rule) 133 | 134 | #6️⃣ Apply Filter to FEC 135 | return FilteredElementCollector(doc)\ 136 | .WherePasses(filter_fam_name)\ 137 | .WhereElementIsNotElementType()\ 138 | .ToElements() 139 | 140 | # MAIN 141 | elements = get_elements_by_type_name('2000 x 2250') 142 | el_ids = [el.Id for el in elements] 143 | List_el_ids = List[ElementId](el_ids) 144 | 145 | uidoc.Selection.SetElementIds(List_el_ids) 146 | 147 | 148 | # ╔═╗╦ ╦╔═╗╦═╗╔═╗╔╦╗ ╔═╗╔═╗╦═╗╔═╗╔╦╗╔═╗╔╦╗╔═╗╦═╗╔═╗ 149 | # ╚═╗╠═╣╠═╣╠╦╝║╣ ║║ ╠═╝╠═╣╠╦╝╠═╣║║║║╣ ║ ║╣ ╠╦╝╚═╗ 150 | # ╚═╝╩ ╩╩ ╩╩╚═╚═╝═╩╝ ╩ ╩ ╩╩╚═╩ ╩╩ ╩╚═╝ ╩ ╚═╝╩╚═╚═╝ 151 | 152 | def get_elements_by_shared_p_value(s_param_name, value): 153 | """Function to get Elements by Family Name""" 154 | #1️⃣Shared Parameter 155 | rule = ParameterFilterRuleFactory.CreateSharedParameterApplicableRule(s_param_name) 156 | filter = ElementParameterFilter(rule) 157 | 158 | p_type_id = ElementId(BuiltInParameter.SYMBOL_NAME_PARAM) 159 | f_param = ParameterValueProvider(p_type_id) 160 | 161 | #2️⃣ Evaluator 162 | evaluator = FilterStringEquals() 163 | 164 | #3️⃣ Value 165 | value = value 166 | 167 | #4️⃣ Rule 168 | rvt_year = int(app.VersionNumber) 169 | if rvt_year >= 2023: 170 | f_rule = FilterStringRule(f_param, evaluator, value) 171 | else: 172 | f_rule = FilterStringRule(f_param, evaluator, value, False) 173 | 174 | 175 | #5️⃣ Filter 176 | filter_fam_name = ElementParameterFilter(f_rule) 177 | 178 | #6️⃣ Apply Filter to FEC 179 | return FilteredElementCollector(doc)\ 180 | .WherePasses(filter_fam_name)\ 181 | .WhereElementIsNotElementType()\ 182 | .ToElements() 183 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/11 - GetDefaultTypes.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/11 - GetDefaultTypes.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/11 - GetDefaultTypes.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "11 - Get Default Element Types" 3 | __doc__ = """Version = 1.0 4 | Date = 15.01.2024 5 | _____________________________________________________________________ 6 | Description: 7 | Learn How to get Default Element Types with Revit API. 8 | 9 | Happy Coding! 10 | _____________________________________________________________________ 11 | Author: Erik Frits""" 12 | 13 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 14 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 15 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 16 | # ================================================== 17 | from Autodesk.Revit.DB import * 18 | 19 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 20 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 21 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 22 | # ================================================== 23 | doc = __revit__.ActiveUIDocument.Document #type: Document 24 | uidoc = __revit__.ActiveUIDocument 25 | app = __revit__.Application 26 | 27 | # ╔╦╗╔═╗╦╔╗╔ 28 | # ║║║╠═╣║║║║ 29 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 30 | # ================================================== 31 | 32 | #1. Get Types of Native Families (GetDefaultElementTypeId ) 33 | wall_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.WallType) 34 | floor_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FloorType) 35 | view_plan_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.ViewTypeFloorPlan) 36 | region_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType) 37 | 38 | # Convert to Elements 39 | wall_type = doc.GetElement(wall_type_id) 40 | floor_type = doc.GetElement(floor_type_id) 41 | view_plan_type = doc.GetElement(view_plan_type_id) 42 | region_type = doc.GetElement(region_type_id) 43 | 44 | # Display Results 45 | print(Element.Name.GetValue(wall_type)) 46 | print(Element.Name.GetValue(floor_type)) 47 | print(Element.Name.GetValue(view_plan_type)) 48 | print(Element.Name.GetValue(region_type)) 49 | 50 | 51 | #2. Get Types of Loaded Families (GetDefaultFamilyTypeId ) 52 | door_type_id = doc.GetDefaultFamilyTypeId(ElementId(BuiltInCategory.OST_Doors)) 53 | win_type_id = doc.GetDefaultFamilyTypeId(ElementId(BuiltInCategory.OST_Windows)) 54 | gen_model_type_id = doc.GetDefaultFamilyTypeId(ElementId(BuiltInCategory.OST_GenericModel)) 55 | 56 | door_type = doc.GetElement(door_type_id) 57 | win_type = doc.GetElement(win_type_id) 58 | gen_model_type = doc.GetElement(gen_model_type_id) 59 | 60 | # Display Results 61 | print(Element.Name.GetValue(door_type)) 62 | print(Element.Name.GetValue(win_type)) 63 | print(Element.Name.GetValue(gen_model_type)) -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2023.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_01_AutomateWindowSections.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_01_AutomateWindowSections.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_01_AutomateWindowSections.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "1 - Tutorial Automate Sections" 3 | __doc__ = """Date = 30.01.2024 4 | _____________________________________________________________________ 5 | Description: 6 | Tutorial on how to Create Sections for all Window Types. 7 | - Elevation Section 8 | - Cross Section 9 | - Plan Section (Yes, we can create PlansViews with sections) 10 | 11 | _____________________________________________________________________ 12 | Author: Erik Frits""" 13 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 14 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 15 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 16 | #================================================== 17 | from Autodesk.Revit.DB import * 18 | from pyrevit import forms 19 | 20 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 21 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 22 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 23 | #================================================== 24 | uidoc = __revit__.ActiveUIDocument 25 | doc = __revit__.ActiveUIDocument.Document #type: Document 26 | app = __revit__.Application 27 | 28 | # ╔╦╗╔═╗╦╔╗╔ 29 | # ║║║╠═╣║║║║ 30 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 31 | #================================================== 32 | #👉 Get and Sort Window Instances of Each Type 33 | windows = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsNotElementType().ToElements() 34 | 35 | dict_windows = {} 36 | for win in windows: 37 | family_name = win.Symbol.Family.Name 38 | type_name = Element.Name.GetValue(win.Symbol) 39 | key_name = '{}_{}'.format(family_name, type_name) 40 | 41 | host = win.Host 42 | if type(host) == Wall: 43 | dict_windows[key_name] = win 44 | else: 45 | print('Unsupported Host for Window: {} [{}]'.format(key_name, win.Id)) 46 | 47 | # #👀 Preview Dict Windows 48 | # for k,v in dict_windows.items(): 49 | # print(k,v) 50 | 51 | #🔏 Create Transaction to Modify Project 52 | t = Transaction(doc, 'Generate Window Sections') 53 | t.Start() #🔓 54 | 55 | 56 | 57 | 58 | 59 | #🎯 Create Section 60 | for window_name, window in dict_windows.items(): 61 | try: 62 | #1️⃣ Get Window Origin Point 63 | win_origin = window.Location.Point #type: XYZ 64 | 65 | #2️⃣ Calculate Vector based on the Wall 66 | host_wall = window.Host 67 | curve = host_wall.Location.Curve #type: Curve 68 | pt_start = curve.GetEndPoint(0) #type: XYZ 69 | pt_end = curve.GetEndPoint(1) #type: XYZ 70 | vector = pt_end - pt_start #type: XYZ 71 | 72 | #3️⃣ Get Window Size 73 | win_width = window.Symbol.get_Parameter(BuiltInParameter.GENERIC_WIDTH).AsDouble() 74 | cm_40 = UnitUtils.ConvertToInternalUnits(40, UnitTypeId.Centimeters) #40cm (Revit API takes unit in FEET!) 75 | win_depth = cm_40 76 | offset = cm_40 77 | win_height = window.Symbol.get_Parameter(BuiltInParameter.CASEWORK_HEIGHT).AsDouble() # ADJUST TO YOUR PARAMETERS! 78 | if not win_height: 79 | win_height = window.Symbol.LookupParameter('Höhe ab FBOK').AsDouble() # ADJUST TO YOUR PARAMETERS! 80 | 81 | # ╔╦╗╦═╗╔═╗╔╗╔╔═╗╔═╗╔═╗╦═╗╔╦╗ 82 | # ║ ╠╦╝╠═╣║║║╚═╗╠╣ ║ ║╠╦╝║║║ 83 | # ╩ ╩╚═╩ ╩╝╚╝╚═╝╚ ╚═╝╩╚═╩ ╩ 84 | # ================================================== 85 | 86 | # 🪟 TRANSFORMATION - ELEVATION SECTION 87 | # 4️⃣🅰️ Create Transform (Origin point + X,Y,Z Vectors) 88 | 89 | # TRANSFORMATION - ELEVATION 90 | trans = Transform.Identity # Create Instance of Transform 91 | trans.Origin = win_origin # Set Origin Point (Window Insertion Point) 92 | 93 | vector = vector.Normalize() # * -1/1 Multiply Vector to flip Section if necessary! 94 | 95 | trans.BasisX = vector 96 | trans.BasisY = XYZ.BasisZ 97 | trans.BasisZ = vector.CrossProduct(XYZ.BasisZ) #The cross product is defined as the vector which is perpendicular to both vectors 98 | # ================================================== 99 | 100 | # #🪟 TRANSFORMATION - CROSS SECTION 101 | # #4️⃣🅱️ Create Transform (Origin point + X,Y,Z Vectors) 102 | # trans = Transform.Identity # Create Instance of Transform 103 | # trans.Origin = win_origin # Set Origin Point (Window Insertion Point) 104 | # 105 | # vector = vector.Normalize() # * -1/1 Multiply Vector to flip Section if necessary! 106 | # 107 | # vector_cross = vector.CrossProduct(XYZ.BasisZ) 108 | # 109 | # trans.BasisX = vector_cross 110 | # trans.BasisY = XYZ.BasisZ 111 | # trans.BasisZ = vector_cross.CrossProduct(XYZ.BasisZ) 112 | # # ================================================== 113 | 114 | # #🪟 TRANSFORMATION - SECTION PLAN 115 | # #4️⃣©️ Create Transform (Origin point + X,Y,Z Vectors) 116 | # trans = Transform.Identity # Create Instance of Transform 117 | # trans.Origin = win_origin # Set Origin Point (Window Insertion Point) 118 | # 119 | # # Create Transform for PlanSection (XYZ Vectors) 🤦‍♂️ Yes, Section can be used to look down like Plans... 120 | # vector = vector.Normalize() 121 | # trans.BasisX = vector 122 | # trans.BasisY = -XYZ.BasisZ.CrossProduct(vector).Normalize() 123 | # trans.BasisZ = -XYZ.BasisZ 124 | 125 | # ================================================== 126 | 127 | #5️⃣ Create SectionBox 128 | section_box = BoundingBoxXYZ() # origin 0,0,0 129 | 130 | half = win_width/2 131 | section_box.Min = XYZ(-half - offset , 0 - offset , -win_depth) 132 | section_box.Max = XYZ(half + offset , win_height + offset , win_depth) 133 | #💡 XYZ(X - Left/Right , Y - Up/Down , Z - Forward/Backwards) 134 | 135 | section_box.Transform = trans # Apply Transform (Origin + XYZ Vectors) 136 | 137 | #6️⃣ Create Section View 138 | section_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.ViewTypeSection) 139 | window_elevation = ViewSection.CreateSection(doc, section_type_id, section_box) 140 | 141 | # 7️⃣ New Name 142 | new_name = 'py_{} (Plan)'.format(window_name) 143 | 144 | for i in range(10): 145 | try: 146 | window_elevation.Name = new_name 147 | print('✅ Created Section: {}'.format(new_name)) 148 | break 149 | except: 150 | new_name += '*' 151 | 152 | except: 153 | import traceback 154 | print('---\n❌ERROR:') 155 | print(traceback.format_exc()) 156 | 157 | t.Commit() # 🔒 -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_01_AutomateWindowSections.pushbutton/temp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "Tutorial Create Sections: Windows" 3 | __doc__ = """Date = 29.01.2024 4 | _____________________________________________________________________ 5 | Description: 6 | Create sections for all window types. 7 | _____________________________________________________________________ 8 | Author: Erik Frits""" 9 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 10 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 11 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 12 | #================================================== 13 | from Autodesk.Revit.DB import * 14 | from pyrevit import forms 15 | 16 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 17 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 18 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 19 | #================================================== 20 | uidoc = __revit__.ActiveUIDocument 21 | doc = __revit__.ActiveUIDocument.Document #type: Document 22 | app = __revit__.Application 23 | 24 | 25 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 26 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 27 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS 28 | #================================================== 29 | 30 | 31 | # ╔╦╗╔═╗╦╔╗╔ 32 | # ║║║╠═╣║║║║ 33 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 34 | #================================================== 35 | 36 | #👉 Get Window Instances of Each Type 37 | windows = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsNotElementType().ToElements() 38 | dict_windows = {Element.Name.GetValue(win.Symbol): win for win in windows if type(win.Host) == Wall} # Add Snippet on Screen explaining Comprehension 39 | 40 | #👀 Preview Dict 41 | # for k,v in dict_windows.items(): 42 | # print(k,v) 43 | 44 | 45 | #🔏 Create Transaction to Modify Project 46 | t = Transaction(doc, 'Generate Window Sections') 47 | t.Start() #🔓 48 | 49 | 50 | #🎯 Create Sections 51 | for type_name, window in dict_windows.items(): 52 | try: 53 | 54 | #1️⃣ Get Window Origin Point 55 | win_origin = window.Location.Point #type: XYZ 56 | 57 | #2️⃣ Calculate Vector based on Wall 58 | host_wall = window.Host 59 | curve = host_wall.Location.Curve #type: Curve 60 | pt_start = curve.GetEndPoint(0) #type: XYZ 61 | pt_end = curve.GetEndPoint(1) #type: XYZ 62 | vector = pt_end - pt_start #type: XYZ 63 | 64 | #3️⃣ Get Window Size 65 | try: 66 | win_height = window.Symbol.get_Parameter(BuiltInParameter.CASEWORK_HEIGHT).AsDouble() # Not all windows use it. 67 | if not win_height: # Alternative Height parameter 68 | win_height = window.Symbol.LookupParameter('Höhe ab FBOK').AsDouble() 69 | except: pass 70 | win_width = window.Symbol.get_Parameter(BuiltInParameter.GENERIC_WIDTH).AsDouble() 71 | offset = UnitUtils.ConvertToInternalUnits(40, UnitTypeId.Centimeters) #40cm 72 | win_depth = 2 73 | 74 | print(UnitUtils.ConvertFromInternalUnits(win_width, UnitTypeId.Centimeters)) 75 | print(UnitUtils.ConvertFromInternalUnits(win_height, UnitTypeId.Centimeters)) 76 | 77 | #4️⃣🅰️ Define Transform (Location + Rotation) 78 | trans = Transform.Identity # Create Instance of Transform 79 | trans.Origin = win_origin # Set Origin Point 80 | 81 | 82 | #4️⃣🅱️ Set directions of X,Y,Z Axis of Transform 83 | vector = vector.Normalize() * -1 # Normalized indicates that the length of this vector equals one (a unit vector). 84 | 85 | #❇️ Create Elevation Transform 86 | trans.BasisX = vector 87 | trans.BasisY = XYZ.BasisZ 88 | trans.BasisZ = vector.CrossProduct(XYZ.BasisZ) #Sets the Z-axis to be perpendicular to both curvedir and the 89 | # vertical axis (essentially pointing in or out of the wall). 90 | 91 | # 92 | # #❇️ Create Cross Section Transform 93 | # # Calculate Window's Normal Vector (Perpendicular to the Window Plane) 94 | # vector_cross = vector.CrossProduct(XYZ.BasisZ).Normalize() 95 | # 96 | # # Align BasisX or BasisY with the Window's Normal Vector 97 | # trans.BasisX = vector_cross # Aligned with the window's normal 98 | # trans.BasisY = XYZ.BasisZ # Vertical 99 | # trans.BasisZ = vector_cross.CrossProduct(XYZ.BasisZ) # Perpendicular to both 100 | 101 | 102 | # #❇️ Create FloorPlan(Section) Transform 103 | # 104 | # # Assuming XYZ is a class with standard basis vectors and trans is your transformation object 105 | # vector = vector.Normalize() 106 | # 107 | # # Set Z-axis to global up direction (perpendicular to floor) 108 | # trans.BasisZ = XYZ.BasisZ 109 | # 110 | # # Set X-axis based on building's main direction or a default 111 | # trans.BasisX = vector 112 | # 113 | # # Calculate Y-axis as perpendicular to both X-axis and Z-axis 114 | # # Ensure it is normalized to maintain the unit vector property 115 | # trans.BasisY = trans.BasisZ.CrossProduct(trans.BasisX).Normalize() 116 | # 117 | # # Verify that all axes are perpendicular to each other 118 | # # If not, adjust mainDirection or use a different approach to calculate BasisX and BasisY 119 | 120 | 121 | 122 | #5️⃣ Create SectionBox (Add Dimensions + Apply Transform) 123 | section_box = BoundingBoxXYZ() #0,0,0 124 | half_w = win_width/2 125 | section_box.Min = XYZ(-half_w - offset, 0 - offset, -2) # z - Depth Start 126 | section_box.Max = XYZ(half_w + offset, win_height + offset, win_depth) # z - Depth End 127 | # 💡 128 | # X - Left/Right 129 | # Y - Up/Down 130 | # Z - Depth (Forward, Backwards) 131 | 132 | section_box.Transform = trans 133 | 134 | 135 | #6️⃣ Create Section View 136 | view_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.ViewTypeSection) # Default Section Type 137 | window_section = ViewSection.CreateSection(doc, view_type_id, section_box) 138 | 139 | #7️⃣ Rename View 140 | win_family_name = window.Symbol.Family.Name 141 | win_type_name = Element.Name.GetValue(window.Symbol) 142 | new_name = "py_{}_{}".format(win_family_name, win_type_name) 143 | 144 | for i in range(10): 145 | try: 146 | window_section.Name = new_name 147 | print(window.Id, new_name) 148 | break 149 | except: 150 | new_name += '*' 151 | except: 152 | import traceback 153 | print('---\nERROR:') 154 | print(traceback.format_exc()) 155 | 156 | t.Commit() #🔒 157 | 158 | 159 | 160 | uidoc.ActiveView = window_section -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_02_PlaceViewsOnSheets.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_02_PlaceViewsOnSheets.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_02_PlaceViewsOnSheets.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "2 - Automate Views on Sheets" 3 | __doc__ = """Date = 12.02.2024 4 | _____________________________________________________________________ 5 | Description: 6 | Tutorials on how to Place Views on New Sheets. 7 | _____________________________________________________________________ 8 | Author: Erik Frits""" 9 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 10 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 11 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 12 | #================================================== 13 | from Autodesk.Revit.DB import * 14 | 15 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 16 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 17 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 18 | #================================================== 19 | doc = __revit__.ActiveUIDocument.Document #type: Document 20 | 21 | # Global 22 | default_title_block_id = doc.GetDefaultFamilyTypeId(ElementId(BuiltInCategory.OST_TitleBlocks)) 23 | 24 | 25 | # ╔╦╗╔═╗╦╔╗╔ 26 | # ║║║╠═╣║║║║ 27 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 28 | #================================================== 29 | 30 | # 📦 Get All Views + Filter 31 | all_views = FilteredElementCollector(doc).OfClass(View).WhereElementIsNotElementType().ToElements() 32 | views_to_place = [view for view in all_views if 'py_' in view.Name] 33 | 34 | # ♻️ Sort Views for Placing on Sheets 35 | from collections import defaultdict 36 | dict_views = defaultdict(dict) 37 | 38 | #🎯 Desired Dict Structure 39 | # dict_views = {'VIEW_NAME' : {'Plan': None, 40 | # 'Elevation': None, 41 | # 'Cross': None}, 42 | # } 43 | 44 | # 👇 Sort Views to Place 45 | for view in views_to_place: 46 | try: 47 | view_name = view.Name.replace('py_', '') #Remove py_ prefix 48 | win_name = view_name.split(' (')[0] 49 | 50 | if '(Plan)' in view.Name: dict_views[win_name]['Plan'] = view 51 | elif '(Cross)' in view.Name: dict_views[win_name]['Cross'] = view 52 | elif '(Elevation)' in view.Name: dict_views[win_name]['Elevation'] = view 53 | 54 | except: 55 | pass 56 | 57 | #👀 Preview Results 58 | # for win_name, dict_win_views in dict_views.items(): 59 | # print(win_name) 60 | # for view in dict_win_views.values(): 61 | # print('- {}'.format(view.Name)) 62 | # print('-'*50) 63 | 64 | 65 | #🔏 Transaction to Make changes 66 | t = Transaction(doc, 'Create Window Sheets') 67 | t.Start() #🔓 68 | 69 | 70 | 71 | # 📰 Iterate and Create New Sheet 72 | counter = 0 73 | for win_name, dict_win_views in dict_views.items(): 74 | #🪟 Get Plan/Cross/Elevation Views 75 | plan = dict_win_views['Plan'] 76 | elev = dict_win_views['Elevation'] 77 | cros = dict_win_views['Cross'] 78 | 79 | # ⚠️ Handle Errors during view placement (SubTransaction) 80 | # SubTransaction Will allow creation of new Section only if we can place them 81 | # Otherwise this step will be rollbacked for this iteration 82 | st = SubTransaction(doc) 83 | st.Start() 84 | 85 | 86 | #📰 Create new ViewSheet 87 | new_sheet = ViewSheet.Create(doc, default_title_block_id) 88 | 89 | #💡 Check if possible to place views 90 | if Viewport.CanAddViewToSheet(doc, new_sheet.Id, plan.Id) and \ 91 | Viewport.CanAddViewToSheet(doc, new_sheet.Id, elev.Id) and \ 92 | Viewport.CanAddViewToSheet(doc, new_sheet.Id, cros.Id): 93 | st.Commit() 94 | else: 95 | st.RollBack() 96 | print('❌ The following window sections already placed: {}'.format(win_name)) 97 | continue 98 | 99 | # ⏺️ Define position for placing views 100 | pt_plan = XYZ(-0.4, 0.3, 0) 101 | pt_cros = XYZ(-0.15, 0.75, 0) 102 | pt_elev = XYZ(-0.4, 0.75, 0) 103 | 104 | # 🖼️ Place Views on Sheets 105 | vp_plan = Viewport.Create(doc, new_sheet.Id, plan.Id, pt_plan) 106 | vp_cros = Viewport.Create(doc, new_sheet.Id, cros.Id, pt_cros) 107 | vp_elev = Viewport.Create(doc, new_sheet.Id, elev.Id, pt_elev) 108 | print('✅ Created New Sheet for Window: {}'.format(win_name)) 109 | 110 | # 📝 Rename Sheets 111 | try: 112 | new_sheet.SheetNumber = 'Window - {}'.format(win_name) 113 | new_sheet.Name = '' 114 | except: 115 | pass 116 | 117 | # # 📛️ Temp Counter 118 | # counter +=1 119 | # if counter > 10: 120 | # break 121 | 122 | 123 | t.Commit() #🔒 124 | 125 | 126 | 127 | 128 | 129 | # 🎯 And this will create Hundreds of New Sheets for our Window Sections! -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_03_ConvertCoordinates.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_03_ConvertCoordinates.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_03_ConvertCoordinates.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = '3 - CoordSystems' 3 | 4 | # Imports 5 | from Autodesk.Revit.DB import * 6 | 7 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 8 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 9 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 10 | #-------------------------------------------------- 11 | uidoc = __revit__.ActiveUIDocument 12 | doc = __revit__.ActiveUIDocument.Document #type: Document 13 | 14 | # ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ 15 | # ╠╣ ║ ║║║║║ ║ ║║ ║║║║╚═╗ 16 | # ╚ ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ Functions 17 | #-------------------------------------------------- 18 | def convert_internal_units(value, get_internal=True): 19 | # type: (float, bool) -> float 20 | """Function to convert Internal units to meters or vice versa. 21 | :param value: Value to convert 22 | :param get_internal: True - Convert TO Internal / Flase - Convert FROM Internal 23 | :return: Length in Internal units or Meters.""" 24 | if get_internal: 25 | return UnitUtils.ConvertToInternalUnits(value, UnitTypeId.Meters) 26 | return UnitUtils.ConvertFromInternalUnits(value, UnitTypeId.Meters) 27 | 28 | 29 | # ╔═╗╦ ╔═╗╔═╗╔═╗ 30 | # ║ ║ ╠═╣╚═╗╚═╗ 31 | # ╚═╝╩═╝╩ ╩╚═╝╚═╝ CLASS 32 | #-------------------------------------------------- 33 | class PointConverter: 34 | pt_internal = None 35 | pt_survey = None 36 | pt_project = None 37 | 38 | def __init__(self, x, y, z, coord_sys='internal', input_units = 'm'): 39 | # type:( float, float, float, str, str) 40 | """ PointConverter - Convert coordinate into desired coordinate system. 41 | Args: 42 | x : Float in meters representing the x-coordinate. 43 | y : Float in meters representing the y-coordinate. 44 | z : Float in meters representing the z-coordinate. 45 | coord_sys : Coordinate System of provided coordinates. 46 | Possible values: 'internal'/'project'/'survey' 47 | input_units : Float in meters representing the z-coordinate. 48 | Possible Values: 'm' / 'ft' """ 49 | 50 | # Get Systems Transform 51 | srvTrans = self.GetSurveyTransform() 52 | projTrans = self.GetProjectTransform() 53 | 54 | 55 | # Convert to Internal Units 56 | if input_units == 'm': 57 | x = convert_internal_units(x, get_internal=True) # Convert Units to Internal 58 | y = convert_internal_units(y, get_internal=True) # Convert Units to Internal 59 | z = convert_internal_units(z, get_internal=True) # Convert Units to Internal 60 | 61 | # 1️⃣INTERNAL COORDINATE SYSTEM 62 | if coord_sys.lower() == 'internal': 63 | self.pt_internal = XYZ(x, y, z) 64 | self.pt_survey = self.ApplyInverseTransformation(srvTrans , self.pt_internal) 65 | self.pt_project = self.ApplyInverseTransformation(projTrans, self.pt_internal) 66 | 67 | # 2️⃣PROJECT COORDINATE SYSTEM 68 | elif coord_sys.lower() == 'project': 69 | self.pt_project = XYZ(x, y, z) 70 | self.pt_internal = self.ApplyTransformation(projTrans, self.pt_project) 71 | self.pt_survey = self.ApplyInverseTransformation(srvTrans, self.pt_internal) 72 | 73 | # 3️⃣SURVEY COORDINATE SYSTEM 74 | elif coord_sys.lower() == 'survey': 75 | self.pt_survey = XYZ(x, y, z) 76 | self.pt_internal = self.ApplyTransformation(srvTrans, self.pt_survey) 77 | self.pt_project = self.ApplyInverseTransformation(projTrans, self.pt_internal) 78 | 79 | else: raise Exception("Wrong argument value for 'coord_sys' in PointConverter class.") 80 | 81 | #⛑ HELPING METHODS 82 | def GetSurveyTransform(self): 83 | """Gets the Active Project Locations Transform (Survey).""" 84 | return doc.ActiveProjectLocation.GetTotalTransform() 85 | 86 | def GetProjectTransform(self): 87 | """Get the Project Base Points Transform.""" 88 | basePtLoc = next((l for l in FilteredElementCollector(doc) \ 89 | .OfClass(ProjectLocation) \ 90 | .WhereElementIsNotElementType() \ 91 | .ToElements() if l.Name in ['Project', 'Projekt']), None) 92 | return basePtLoc.GetTotalTransform() 93 | 94 | def ApplyInverseTransformation(self, t, pt): 95 | """Applies the inverse transformation of 96 | the given Transform to the given point.""" 97 | return t.Inverse.OfPoint(pt) 98 | 99 | def ApplyTransformation(self, t, pt): 100 | """Applies the transformation of 101 | the given Transform to the given point.""" 102 | return t.OfPoint(pt) 103 | 104 | # ╔╦╗╔═╗╦╔╗╔ 105 | # ║║║╠═╣║║║║ 106 | # ╩ ╩╩ ╩╩╝╚╝ 107 | # EXAMPLE ON HOW TO USE: 108 | 109 | # 😉 Helper Function 110 | def print_coord_in_m(pt, prefix=""): 111 | #type: (XYZ, str) 112 | """Helper Function to display Point Coordinates 113 | in Meters to compare to Coordinates displayed in Revit.""" 114 | x = round(convert_internal_units(pt.X, get_internal=False), 4) 115 | y = round(convert_internal_units(pt.Y, get_internal=False), 4) 116 | z = round(convert_internal_units(pt.Z, get_internal=False), 4) 117 | # print(prefix, 'N/S:{}'.format(y), 'E/W:{}'.format(x), 'Elev:{}'.format(z)) 118 | print(prefix, 'X:{}'.format(x), 'Y:{}'.format(y), 'Z:{}'.format(z)) 119 | # -------------------------------------------------------------- 120 | 121 | # 1️⃣ Define Coordinates Manually 122 | # X = 0 # EW Coordinate 123 | # Y = 0 # NS Coordinate 124 | # Z = 0 # Elevation 125 | 126 | # 1️⃣ Pick Point 127 | picked_point = uidoc.Selection.PickPoint() 128 | X = picked_point.X 129 | Y = picked_point.Y 130 | Z = picked_point.Z 131 | 132 | # 2️⃣ Create PointConverter instance 133 | converter = PointConverter(X, Y, Z, coord_sys='internal', input_units='ft') 134 | 135 | # 3️⃣ Converted Points 136 | pt_internal = converter.pt_internal 137 | pt_project = converter.pt_project 138 | pt_survey = converter.pt_survey 139 | 140 | # 👀 Display Results 141 | print_coord_in_m(pt_internal, prefix='Internal: ') 142 | print_coord_in_m(pt_project, prefix='Project: ') 143 | print_coord_in_m(pt_survey, prefix='Survey: ') 144 | 145 | Author = 'Erik Frits' -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_04_pyRevitLinkify.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_04_pyRevitLinkify.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_04_pyRevitLinkify.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = '4 - pyRevit Linkify' 3 | 4 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 5 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 6 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ 7 | from Autodesk.Revit.DB import * 8 | from pyrevit import script 9 | 10 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 11 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 12 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 13 | #-------------------------------------------------- 14 | uidoc = __revit__.ActiveUIDocument 15 | doc = __revit__.ActiveUIDocument.Document #type: Document 16 | output = script.get_output() 17 | # ╔╦╗╔═╗╦╔╗╔ 18 | # ║║║╠═╣║║║║ 19 | # ╩ ╩╩ ╩╩╝╚╝ 20 | 21 | 22 | # 1️⃣ Linkify Single - Walls 23 | all_walls = FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(Wall).ToElements() 24 | 25 | for wall in all_walls: 26 | linkify_wall = output.linkify(wall.Id, wall.Name) 27 | print(linkify_wall) 28 | #-------------------------------------------------- 29 | 30 | #2️⃣ Linkify Multiple - Walls 31 | all_walls = FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(Wall).ToElements() 32 | wall_ids = [wall.Id for wall in all_walls] 33 | linkify_walls = output.linkify(wall_ids, 'Walls {}'.format(len(wall_ids))) 34 | print(linkify_walls) 35 | #-------------------------------------------------- 36 | 37 | #3️⃣ Limit ~100-150 elements 38 | all_walls = FilteredElementCollector(doc).OfClass(Wall).ToElements() 39 | wall_ids = [wall.Id for wall in all_walls] 40 | linkify_walls = output.linkify(wall_ids, 'Walls {}'.format(len(wall_ids))) 41 | print('Here are all the walls in the project: {}'.format(linkify_walls)) 42 | #------------------------------------------------ 43 | 44 | # 4️⃣ Linkify - Views 45 | # all_views_and_vt = FilteredElementCollector(doc).OfClass(ViewPlan).ToElements() 46 | # all_views = [view for view in all_views_and_vt if not view.IsTemplate] 47 | # 48 | # for view in all_views: 49 | # linkify_view = output.linkify(view.Id, 'View: {}'.format(view.Name)) 50 | # print(linkify_view) 51 | # ----------------------------------------------- 52 | 53 | #5️⃣ Bonus Example: Analyze Warnings 54 | def get_sorted_warnings(): 55 | """Function to get All Warnings in the project and sort them by their description 56 | :return: dict of warnings {warn_description : list_of_warnings}""" 57 | from collections import defaultdict 58 | 59 | dict_all_warnings = defaultdict(list) 60 | for w in doc.GetWarnings(): 61 | description = w.GetDescriptionText() 62 | dict_all_warnings[description].append(w) 63 | return dict_all_warnings 64 | 65 | # Get + Sort Warnings 66 | dict_all_warnings = get_sorted_warnings() 67 | 68 | for descr, list_warnings in dict_all_warnings.items(): 69 | table_data = [] 70 | 71 | for warn in list_warnings: 72 | 73 | # print(warn) 74 | element_ids = list(warn.GetFailingElements()) + list(warn.GetAdditionalElements()) 75 | last_modified_by = {WorksharingUtils.GetWorksharingTooltipInfo(doc, el_id).LastChangedBy for el_id in element_ids} 76 | last_modified_by = ', '.join(last_modified_by) 77 | 78 | # Linkify 79 | title = 'Select' 80 | warn_linkify = output.linkify(element_ids, title) 81 | 82 | # Create a Row of Data 83 | row = [descr, last_modified_by, str(len(element_ids)), warn_linkify] 84 | table_data.append(row) 85 | output.print_table(table_data=table_data, 86 | title =descr, 87 | columns=['Warning Description', 'Last Modified By:', 'Elements', 'Linkify'], 88 | formats=['**{}**', '*{}*', '', '']) 89 | 90 | 91 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_05_PurgeViewFilters.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_05_PurgeViewFilters.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_05_PurgeViewFilters.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "5 - Purge Unused View Filters" 3 | __doc__ = """Version = 1.0 4 | Date = 24.06.2024 5 | _____________________________________________________________________ 6 | Description: 7 | Purge Unused View Filters from your Revit Project. 8 | _____________________________________________________________________ 9 | How-To: 10 | - Click the Button 11 | - Select unused View Filters to purge 12 | _____________________________________________________________________ 13 | Last update: 14 | - [24.06.2024] - V1.0 RELEASE 15 | _____________________________________________________________________ 16 | Author: Erik Frits from LearnRevitAPI.com""" 17 | 18 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 19 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 20 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 21 | # ================================================== 22 | from Autodesk.Revit.DB import * 23 | 24 | # pyRevit 25 | from pyrevit import forms 26 | 27 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 28 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 29 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 30 | # ================================================== 31 | doc = __revit__.ActiveUIDocument.Document 32 | uidoc = __revit__.ActiveUIDocument 33 | 34 | # ╔╦╗╔═╗╦╔╗╔ 35 | # ║║║╠═╣║║║║ 36 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 37 | # ================================================== 38 | # 1️⃣ Get Views and Filters 39 | # all_filter_ids = FilteredElementCollector(doc).OfClass(FilterElement).ToElementIds() #Parameter + Selection 40 | # all_sel_filter_ids = FilteredElementCollector(doc).OfClass(SelectionFilterElement).ToElementIds() 41 | all_param_filter_ids = FilteredElementCollector(doc).OfClass(ParameterFilterElement).ToElementIds() 42 | all_views_and_vt = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements() 43 | 44 | 45 | #2️⃣ Find Used ViewFilters 46 | used_filter_ids = [] 47 | 48 | for view in all_views_and_vt: 49 | view_filter_ids = view.GetFilters() 50 | 51 | for view_filter_id in view_filter_ids: 52 | if view_filter_id not in used_filter_ids: 53 | used_filter_ids.append(view_filter_id) 54 | 55 | #3️⃣ Get Unused ViewFilters 56 | unused_filter_ids = set(all_param_filter_ids) - set(used_filter_ids) 57 | unused_filters = [doc.GetElement(f_id) for f_id in unused_filter_ids] 58 | 59 | #✅ Check if Unused Filters in Project 60 | if not unused_filters: 61 | forms.alert('There are no Unused View Filters in the project. Please try again',title=__title__, exitscript=True) 62 | 63 | #👉 Select View Filters to Delete 64 | filters_to_del = forms.SelectFromList.show(unused_filters, 65 | multiselect=True, 66 | name_attr='Name', 67 | button_name='Select Unused View Filters To Delete.') 68 | 69 | 70 | #✅ Check Selection 71 | if not filters_to_del: 72 | forms.alert('No Unused View Filters were selected. Please try again',title=__title__, exitscript=True) 73 | 74 | 75 | with Transaction(doc, 'Purge Unused ViewFilters') as t: 76 | t.Start() #🔓 77 | 78 | for fil in filters_to_del: 79 | try: 80 | f_name = fil.Name 81 | doc.Delete(fil.Id) 82 | print('✔️ Deleted ViewFilter: {}'.format(f_name)) 83 | except Exception as e: 84 | print("✖️ Couldn't Delete View Filter: {}".format(f_name)) 85 | print('----- Error Message: {}'.format(e)) 86 | 87 | t.Commit() #🔒 88 | 89 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_06_PurgeViewTemplates.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_06_PurgeViewTemplates.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_06_PurgeViewTemplates.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __title__ = "6 - Purge Unused View Templates" 3 | __doc__ = """Version = 1.0 4 | Date = 24.06.2024 5 | _____________________________________________________________________ 6 | Description: 7 | Purge Unused View Templates from your Revit Project. 8 | _____________________________________________________________________ 9 | How-To: 10 | - Click the Button 11 | - Select unused View Templates to purge 12 | _____________________________________________________________________ 13 | Last update: 14 | - [28.06.2024] - V1.0 RELEASE 15 | _____________________________________________________________________ 16 | Author: Erik Frits from LearnRevitAPI.com""" 17 | 18 | # ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗ 19 | # ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗ 20 | # ╩╩ ╩╩ ╚═╝╩╚═ ╩ ╚═╝ IMPORTS 21 | # ================================================== 22 | from Autodesk.Revit.DB import * 23 | 24 | # pyRevit 25 | from pyrevit import forms, script 26 | 27 | # ╦ ╦╔═╗╦═╗╦╔═╗╔╗ ╦ ╔═╗╔═╗ 28 | # ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║ ║╣ ╚═╗ 29 | # ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES 30 | # ================================================== 31 | doc = __revit__.ActiveUIDocument.Document 32 | uidoc = __revit__.ActiveUIDocument 33 | output = script.get_output() 34 | 35 | # ╔╦╗╔═╗╦╔╗╔ 36 | # ║║║╠═╣║║║║ 37 | # ╩ ╩╩ ╩╩╝╚╝ MAIN 38 | # ================================================== 39 | #👉 Get Views and ViewTemplates 40 | all_view_and_vt = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements() 41 | all_views = [v for v in all_view_and_vt if not v.IsTemplate] 42 | all_vt_ids = [v.Id for v in all_view_and_vt if v.IsTemplate] 43 | 44 | 45 | #🔬 Get Used ViewTemplates 46 | used_vt_ids = [] 47 | 48 | for view in all_views: 49 | vt_id = view.ViewTemplateId 50 | if vt_id != ElementId(-1): 51 | if vt_id not in used_vt_ids: 52 | used_vt_ids.append(vt_id) 53 | 54 | # Get All Unused ViewTemplates 55 | unused_vt_ids = set(all_vt_ids) - set(used_vt_ids) 56 | unused_vts = [doc.GetElement(vt_id) for vt_id in unused_vt_ids] 57 | 58 | # ✅ Ensure Unused ViewTemplates 59 | if not unused_vt_ids: 60 | forms.alert('There are no unused ViewTemplates in the project. Please try again.',title=__title__, exitscript=True) 61 | 62 | #🔎 Select ViewTemplates to Purge 63 | vt_to_del = forms.SelectFromList.show(unused_vts, 64 | multiselect=True, 65 | name_attr='Name', 66 | button_name='Select Unused ViewTemplates to Purge') 67 | 68 | # ✅ Ensure ViewTemplates were selected 69 | if not vt_to_del: 70 | forms.alert('There were no ViewTemplates Selected. Please try again.',title=__title__, exitscript=True) 71 | 72 | #👀 Print ViewTemplates Report 73 | output.print_md('### There were {}/{} Unused ViewTemplates in the project.'.format(len(unused_vt_ids), len(all_vt_ids))) 74 | output.print_md('---') 75 | 76 | #🔥 Purge ViewTemplates 77 | t = Transaction(doc, 'Purge ViewTemplates') 78 | t.Start() #🔓 79 | 80 | deleted = 0 81 | for vt in vt_to_del: 82 | try: 83 | vt_name = vt.Name 84 | doc.Delete(vt.Id) 85 | output.print_md('🔥Purged ViewTemplate: **{}**'.format(vt_name)) 86 | deleted += 1 87 | except Exception as e: 88 | print("✖️ Couldn't delete ViewTempalte: {} due to {}".format(vt_name, e)) 89 | 90 | t.Commit() #🔒 91 | 92 | #👀 Create Final print statement 93 | output.print_md('---') 94 | output.print_md('*Script Execution has finished. {} ViewTemplates were purged.*'.format(deleted)) 95 | 96 | #⌨️ Happy Coding! -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_07_MorePythonPackages.pushbutton/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_07_MorePythonPackages.pushbutton/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/24_07_MorePythonPackages.pushbutton/script.py: -------------------------------------------------------------------------------- 1 | #!python3 2 | __title__ = "7 - Install More Python Packages" 3 | __doc__ = """Version = 1.0 4 | Date = 24.06.2024 5 | _____________________________________________________________________ 6 | Description: 7 | Learn how to use more python3 packages in pyRevit like: 8 | numpy, pandas, openpyxl and many more! 9 | _____________________________________________________________________ 10 | Author: Erik Frits from LearnRevitAPI.com""" 11 | 12 | #_____________________________________________________________________ 13 | # ╔╦╗╔═╗╦╔╗╔ 14 | # ║║║╠═╣║║║║ 15 | # ╩ ╩╩ ╩╩╝╚╝ 16 | 17 | 18 | # # # Check python version 19 | import sys 20 | print("Python version:", sys.version) 21 | # print("Version info:", sys.version_info) 22 | 23 | import sys 24 | sys.path.append(r'C:\Users\Lenny 16 Inch\AppData\Local\Programs\Python\Python38\Lib\site-packages') 25 | sys.path.append(r'C:\Users\Lenny 16 Inch\AppData\Local\Programs\Python\Python38\Lib') 26 | sys.path.append(r'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38\\DLLs') 27 | sys.path.append(r'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38') 28 | 29 | # 'C:\\Users\\Lenny 16 Inch', 30 | # 'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip', 31 | # 'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38\\DLLs', 32 | # 'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38\\lib', 33 | # 'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38', 34 | # 'C:\\Users\\Lenny 16 Inch\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages', 35 | 36 | 37 | 38 | 39 | #_____________________________________________________________________ 40 | #🟧 Numpy 41 | import numpy as np 42 | 43 | arr = np.array([1, 2, 3, 4, 5]) 44 | print(arr) 45 | print(type(arr)) 46 | 47 | #_____________________________________________________________________ 48 | #🟧 PANDAS 49 | import pandas as pd 50 | 51 | df = pd.DataFrame({ 52 | 'A': [1, 2, 3], 53 | 'B': [4, 5, 6] 54 | }) 55 | print(df) 56 | #_____________________________________________________________________ 57 | #🟧 OPENPYXL 58 | from openpyxl import Workbook 59 | 60 | wb = Workbook() 61 | print(wb) 62 | 63 | #_____________________________________________________________________ 64 | #🟧 Autodesk 65 | from Autodesk.Revit.DB import * 66 | doc = __revit__.ActiveUIDocument.Document #type:Document 67 | 68 | 69 | walls = FilteredElementCollector(doc).OfClass(Wall).ToElements() 70 | print(walls) 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/EF-Tutor.tab/Tutorials.panel/YouTubeLessons_2024.pulldown/icon.png -------------------------------------------------------------------------------- /EF-Tutor.tab/bundle.yaml: -------------------------------------------------------------------------------- 1 | layout: 2 | - Resources 3 | - Tutorials 4 | - Dev -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EF-Tutor 2 | pyRevit extension from my YouTube Tutorials. 3 | -------------------------------------------------------------------------------- /extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "builtin": "False", 3 | "default_enabled": "True", 4 | "type": "extension", 5 | "rocket_mode_compatible": "False", 6 | "name": "EF-Tutor", 7 | "description": "Extension from RevitAPI + python series by Erik Frits.", 8 | "author": "Erik Frits", 9 | "author_profile": "https://github.com/ErikFrits", 10 | "url": "https://github.com/ErikFrits/EF-Tutor.git", 11 | "website": "https://www.youtube.com/c/ErikFrits", 12 | "image": "", 13 | "dependencies": [] 14 | } -------------------------------------------------------------------------------- /hooks/hooks-archive/doc-updater.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | #⬇️ Imports 4 | from datetime import datetime 5 | from Autodesk.Revit.DB import (BuiltInCategory, 6 | BuiltInParameter, 7 | UnitUtils, 8 | UnitTypeId, 9 | ElementId, 10 | WorksharingUtils, 11 | FamilyInstance) 12 | 13 | #📦 Variables 14 | sender = __eventsender__ 15 | args = __eventargs__ 16 | 17 | doc = args.GetDocument() 18 | 19 | #👉 Get ElementIds for Modified/Deleted/New 20 | modified_el_ids = args.GetModifiedElementIds() 21 | deleted_el_ids = args.GetDeletedElementIds() 22 | new_el_ids = args.GetAddedElementIds() 23 | 24 | modified_el = [doc.GetElement(e_id) for e_id in modified_el_ids] 25 | 26 | 27 | 28 | #🎯 IUpdater - Modified Elements 29 | allowed_cats = [ElementId(BuiltInCategory.OST_Windows), ElementId(BuiltInCategory.OST_Doors)] 30 | for el in modified_el: 31 | if type(el) != FamilyInstance: 32 | continue 33 | 34 | if el.Category.Id in allowed_cats: 35 | 36 | try: 37 | 38 | #1️⃣ Update XYZ Coordinates in Meters 39 | p_com = el.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS) 40 | 41 | pt = el.Location.Point 42 | x = round(UnitUtils.ConvertFromInternalUnits(pt.X, UnitTypeId.Meters), 2) 43 | y = round(UnitUtils.ConvertFromInternalUnits(pt.Y, UnitTypeId.Meters), 2) 44 | z = round(UnitUtils.ConvertFromInternalUnits(pt.Z, UnitTypeId.Meters), 2) 45 | 46 | coord = "{}, {}, {}".format(x,y,z) 47 | p_com.Set(coord) 48 | 49 | 50 | #2️⃣ Add Timestamp to Edited Elements 51 | # Get Time and UserName 52 | timestamp = datetime.now() 53 | f_timestamp = timestamp.strftime("%Y-%m-%d %H-%M-%S") 54 | 55 | wti = WorksharingUtils.GetWorksharingTooltipInfo(doc, el.Id) 56 | last = wti.LastChangedBy 57 | 58 | # Change Value 59 | value = "{} (at {})".format(last, f_timestamp) 60 | p_last = el.LookupParameter('LastModifiedBy') 61 | if p_last: 62 | p_last.Set(value) 63 | 64 | 65 | #3️⃣ Update Mirror State 66 | value = 'Mirrored' if el.Mirrored else 'Not Mirrored' 67 | p_mirrored = el.LookupParameter('IsMirrored') 68 | 69 | if p_mirrored: 70 | p_mirrored.Set(value) 71 | 72 | except: 73 | #import traceback 74 | #print(traceback.format_exc()) 75 | pass 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /lib/Snippets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/lib/Snippets/__init__.py -------------------------------------------------------------------------------- /lib/Snippets/_convert.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # IMPORTS 4 | from Autodesk.Revit.DB import * # Import everything from DB (Very good for beginners and development) 5 | 6 | # VARIABLES 7 | app = __revit__.Application 8 | 9 | # FUNCTIONS 10 | def convert_internal_to_m(length): 11 | """Function to convert internal units to meters. 12 | :param length: Length in internal Revit Units 13 | :return: Length in Meters, rounded to 2nd digit""" 14 | rvt_year = int(app.VersionNumber) 15 | 16 | # RVT < 2022 17 | if rvt_year < 2022: 18 | return UnitUtils.Convert(length, 19 | DisplayUnitType.DUT_DECIMAL_FEET, 20 | DisplayUnitType.DUT_METERS) # Change to any other unit here... 21 | # RVT >= 2022 22 | else: 23 | return UnitUtils.ConvertFromInternalUnits(length, 24 | UnitTypeId.Meters) -------------------------------------------------------------------------------- /lib/Snippets/_selection.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # IMPORTS 4 | from Autodesk.Revit.DB import * 5 | 6 | # VARIABLES 7 | uidoc = __revit__.ActiveUIDocument 8 | doc = __revit__.ActiveUIDocument.Document 9 | 10 | # FUNCTIONS 11 | 12 | def get_selected_elements(uidoc): 13 | """This function will return elements that are currently selected in Revit UI 14 | :param uidoc: uidoc where elements are selected. 15 | :return: List of selected elements""" 16 | return [uidoc.Document.GetElement(elem_id) for elem_id in uidoc.Selection.GetElementIds()] 17 | -------------------------------------------------------------------------------- /lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErikFrits/EF-Tutor/2e5ce53d971eeadcc9ef6e1457da5c6a10a96303/lib/__init__.py --------------------------------------------------------------------------------