-
Notifications
You must be signed in to change notification settings - Fork 11
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
Useful when a simple task, which does 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
Useful when 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.
These scripts show as a sample a task file selection user interface which currently needs to be run before the batch processor process. Batch file sample to be provided soon.
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 | TBC |
CommonPost | TBC |
RevitExport | TBC |
RevitSharedParameterAdd | TBC |
SolibriIFCOptimizer | TBC |
RevitFamilyUtils | TBC |
RevitFamilyLoadOption | TBC |
Result | TBC |