-
Notifications
You must be signed in to change notification settings - Fork 16
Home
Code sample provided in this repository fall into one of two categories:
- Reading and exporting model data without affecting the actual Revit model (script file name starts with: 'Report')
- Modifying the Revit model (script file name starts with 'Modify')
All python sample scripts can be used with either the GUI version of the batch processor (BatchRvtGUI.exe) or the command line (BatchRvt.exe) version.
Python files starting with:
- Pre_ are scripts executed as the pre processing step
- Post_ are scripts executed as the post processing step
Pre and Post processing are available in the User Interface once Show Advanced Options is checked.
Batch scripts located in the /BAT directory assume that the command line version of the batch processor is used. These scripts demonstrate how to:
- Run multiple sessions of the batch processor in parallel running the same task script on a number of files: modify parallel simple
Used cases: Simple tasks, which do not require any post processing, applied to a bigger number of files needs to be sped up. The sample shows how to start 2 processes but it could be any number of sessions your hardware (RAM) supports. Note the few second wait in between batch processor instances being started: this allows for separate log files per instance.
- Run multiple chained sessions of the batch processor in parallel with a post process executed outside the batch processor environment modify parallel in sequence with post process
Use cases: in scenarios where multiple steps need to be applied to Revit files which cannot be done in one step. i.e. Step 1) A revision is created and added to a splash screen (executed in parallel running sessions in batch processor to speed things up), followed by step 2, which only starts when step 1 for all parallel running instances of batch processor is completed. Step 2 may for instance detach same models and prepare them for distribution. After all instances of the batch processor have completed step 2, a post process is started. This is done outside the batch processor interface since it can not be guaranteed which instance of the batch processor finishes last and is therefore the one which could be running the post process.
- Run multiple chained sessions of the batch processor in parallel with a pre and post process executed outside the batch processor environment modify parallel with pre and post process
Use cases: in scenarios where a pre process requires a separate user interface to allow for input (i.e. a file selection) followed by multiple steps needing to be applied to Revit files which cannot be done in one step. This is than followed by a post process script executed after all parallel running task processes are finished.
These scripts located in the /UI folder show, as a sample, a task file selection user interface which currently needs to be run as a separate pre process outside of batch processor.
Batch file sample is provided above.
Typically the sample scripts provided here follow this structure:
- GPL License block
- Short description of what the script does
- import statements block
- debug flag: I use the Revit Python Shell to debug scripts. Since the modules associated with the batch processor are not available in my version of that environment I needed a way to disable import statements associated with the Revit batch processor.
# flag whether this runs in debug or not
debug_ = False- Path and import of libraries these sample scripts rely on. In the moment I have multiple copies of these scripts and their libraries scattered around multiple project location. Not ideal, but it allows for customisation and tinkering without introducing breaking changes to all project versions.
# set path to common library
import sys
sys.path.append(commonlibraryDebugLocation_)
# import common library
import Common as com
from Common import *- Another import block (could probably be moved to the top one)
- Output method (My Python knowledge is not that advanced and I struggled to move this code into a separate library without creating dependency problems)
- My code section: contains utility methods specific to this task script.
# -------------
# my code here:
# -------------- Main section: Usually entry point or method of script.
# -------------
# main:
# -------------The sample scripts provided make use of some utility libraries. A list of currently used libraries and their content is below:
| Name | Content |
|---|---|
| Common | Utility functions covering: transactions, view selection and deletion, element worksets and deletion, Revit and CAD links reload and deletion, Revit file Syncing, saving and file names |
| CommonPost | Utility functions covering: general file modifications (copy, delete, rename), date stamps, combine text files |
| RevitExport | Utilities to export to IFC: built in and 3rd party, Export to NWC |
| RevitSharedParameterAdd | Utilities to add shared parameters to Revit project files |
| SolibriIFCOptimizer | Utilities to run Solibri IFC optimizer |
| RevitFamilyUtils | Utilities to load families, filter family symbols |
| RevitFamilyLoadOption | Class used by Revit Family Utils module |
| Result | Class storing the outcome of a method as true or false, any user readable message to go with it and any object needing returning |