framework
Provide access to DotNet Framework.
Examples:
Attributes
ASSEMBLY_FILE_TYPE = 'dll'
module-attribute
ASSEMBLY_FILE_EXT = '.dll'
module-attribute
ipy_assmname = '{prefix}IronPython'.format(prefix=eng.EnginePrefix)
module-attribute
ipy_dllpath = op.join(eng.EnginePath, ipy_assmname + ASSEMBLY_FILE_EXT)
module-attribute
wpf_assmname = '{prefix}IronPython.Wpf'.format(prefix=eng.EnginePrefix)
module-attribute
wpf_dllpath = op.join(eng.EnginePath, wpf_assmname + ASSEMBLY_FILE_EXT)
module-attribute
sqlite3_assmname = '{prefix}IronPython.SQLite'.format(prefix=eng.EnginePrefix)
module-attribute
sqlite3_dllpath = op.join(eng.EnginePath, sqlite3_assmname + ASSEMBLY_FILE_EXT)
module-attribute
Functions:
to_clr_list(item_type, iterable)
Build a List[item_type] from any Python iterable, on either engine.
List[T](some_python_list) is the obvious spelling and it only works on
IronPython. Under pythonnet the single-argument constructor cannot convert a
Python list to IEnumerable<T], so overload resolution falls through to
List(int capacity) and raises::
TypeError: No method matches given arguments for List`1..ctor: (<class 'list'>)
which surfaces from the Revit API call that consumed the list rather than
from here, so the traceback points at the caller and hides the cause. Filling
the list through Add needs no conversion and behaves the same on both
engines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_type
|
type
|
The CLR element type, e.g. |
required |
iterable
|
iterable
|
Values to add, in order. |
required |
Returns:
| Type | Description |
|---|---|
|
System.Collections.Generic.List[item_type] |
Source code in pyrevitlib/pyrevit/framework.py
get_type(fw_object)
get_dll_file(assembly_name)
add_reference_to_file(asm_file)
Make a .NET assembly file available for import on any engine.
Engine-portable replacement for IronPython's
clr.AddReferenceToFileAndPath, which does not exist under
CPython/pythonnet. Accepts a path with or without the .dll
extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asm_file
|
str
|
path to the assembly file |
required |
Returns:
| Type | Description |
|---|---|
Assembly | None
|
the loaded assembly; None under IronPython |
Note: IronPython's clr.AddReferenceToFileAndPath appends the
assembly's own folder to sys.path on every call, so referencing
several assemblies from the same folder would otherwise list that
folder once per assembly. #3687.