viktor.external.revit
RevitAnalysis
- class viktor.external.revit.RevitAnalysis(script=None, script_key='', files=None, output_filenames=None)
Bases:
PythonAnalysis
New in 14.17.0RevitAnalysis can be used to evaluate a revit-python script on third-party infrastructure. The script is expected to be blocking, i.e. if the script is invoked from command prompt, it should wait until the executable is finished. The default behaviour, is that the python script is defined within the app and send to the worker to be executed on third-party infrastructure. If desired (due to security considerations) the worker can be configured to only run local scripts. These scripts must be defined the in worker configuration file and can be selected through the script_key.
Usage:
script = vkt.File.from_path(Path(__file__).parent / "run_revit.py") files = [ ('input1.txt', file1), ('input2.txt', file2) ] analysis = RevitAnalysis(script=script, files=files, output_filenames=["output.txt"]) analysis.execute(timeout=60) output_file = analysis.get_output_file("output.txt", as_file=True)
Exceptions which can be raised during calculation:
viktor.errors.LicenseError
: no license availableviktor.errors.ExecutionError
: generic error. Error message provides more information
- Parameters:
script (
File
) – Script file that is transferred to the working directory on the server.script_key (
str
) – The key of the script that needs to be run. Only use this when the worker is configured to run local scripts. This key should be present in the configuration file of the worker.files (
List
[Tuple
[str
,Union
[BytesIO
,File
]]]) – Additional files that are transferred to the working directory on the server. Each file is a tuple containing the content and the filename which is used to save on the infrastructure.output_filenames (
List
[str
]) – A list of filenames (including extension) that are to be transferred back to the app. This filename is relative to the working directory.
Either one of ‘script’ or ‘script_key’ should be defined.
- Raises:
ValueError – when neither ‘script’ or ‘script_key’ is included OR when both are included.