runtime
Module that compiles the base DLL on load.
Attributes
mlogger = logger.get_logger(__name__)
module-attribute
INTERFACE_TYPES_DIR = RUNTIME_DIR
module-attribute
DOTNET_DIR = op.join(os.getenv('windir'), 'Microsoft.NET', 'Framework')
module-attribute
DOTNET64_DIR = op.join(os.getenv('windir'), 'Microsoft.NET', 'Framework64')
module-attribute
DOTNET_SDK_DIR = op.join(os.getenv('programfiles(x86)'), 'Reference Assemblies', 'Microsoft', 'Framework', '.NETFramework')
module-attribute
DOTNET_FRAMEWORK_DIRS = sorted([x for x in os.listdir(DOTNET_DIR) if x.startswith('v4.') and 'X' not in x], reverse=True)
module-attribute
DOTNET64_FRAMEWORK_DIRS = sorted([x for x in os.listdir(DOTNET64_DIR) if x.startswith('v4.') and 'X' not in x], reverse=True)
module-attribute
DOTNET_TARGETPACK_DIRS = sorted([x for x in os.listdir(DOTNET_SDK_DIR) if x.startswith('v4.') and 'X' not in x], reverse=True)
module-attribute
RUNTIME_NAMESPACE = 'PyRevitLabs.PyRevit.Runtime'
module-attribute
CMD_EXECUTOR_TYPE_NAME = '{}.{}'.format(RUNTIME_NAMESPACE, 'ScriptCommand')
module-attribute
CMD_AVAIL_TYPE_NAME_EXTENDED = coreutils.make_canonical_name(RUNTIME_NAMESPACE, 'ScriptCommandExtendedAvail')
module-attribute
CMD_AVAIL_TYPE_NAME_SELECTION = coreutils.make_canonical_name(RUNTIME_NAMESPACE, 'ScriptCommandSelectionAvail')
module-attribute
CMD_AVAIL_TYPE_NAME_ZERODOC = coreutils.make_canonical_name(RUNTIME_NAMESPACE, 'ScriptCommandZeroDocAvail')
module-attribute
CMD_AVAIL_NAME_POSTFIX = '-avail'
module-attribute
SOURCE_FILE_EXT = '.cs'
module-attribute
SOURCE_FILE_FILTER = '(\\.cs)'
module-attribute
CPYTHON_ENGINE = user_config.get_active_cpython_engine()
module-attribute
BASE_TYPES_DIR_HASH = coreutils.get_str_hash(coreutils.calculate_dir_hash(INTERFACE_TYPES_DIR, '', SOURCE_FILE_FILTER) + EXEC_PARAMS.engine_ver + str(CPYTHON_ENGINE.Version) if CPYTHON_ENGINE else '0')[:HASH_CUTOFF_LENGTH]
module-attribute
RUNTIME_ASSM_FILE_ID = '{}_{}'.format(BASE_TYPES_DIR_HASH, RUNTIME_NAMESPACE)
module-attribute
RUNTIME_ASSM_FILE = op.join(BIN_DIR, 'pyRevitLabs.PyRevit.Runtime.{}.dll'.format(HOST_APP.version))
module-attribute
RUNTIME_ASSM_NAME = op.splitext(op.basename(RUNTIME_ASSM_FILE))[0]
module-attribute
RUNTIME_ASSM = None
module-attribute
assm_list = assmutils.find_loaded_asm(RUNTIME_ASSM_NAME)
module-attribute
CMD_EXECUTOR_TYPE = assmutils.find_type_by_name(RUNTIME_ASSM, CMD_EXECUTOR_TYPE_NAME)
module-attribute
CMD_AVAIL_TYPE_EXTENDED = assmutils.find_type_by_name(RUNTIME_ASSM, CMD_AVAIL_TYPE_NAME_EXTENDED)
module-attribute
CMD_AVAIL_TYPE_SELECTION = assmutils.find_type_by_name(RUNTIME_ASSM, CMD_AVAIL_TYPE_NAME_SELECTION)
module-attribute
CMD_AVAIL_TYPE_ZERODOC = assmutils.find_type_by_name(RUNTIME_ASSM, CMD_AVAIL_TYPE_NAME_ZERODOC)
module-attribute
Classes
Functions:
get_references()
Get list of all referenced assemblies.
Resolved once per host process, then reused by later session loads: the shipped assemblies that resolving loads stay loaded, and host framework locations don't change while the host runs.
Returns:
| Type | Description |
|---|---|
list
|
referenced assemblies |
Source code in pyrevitlib/pyrevit/runtime/__init__.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
create_ipyengine_configs(clean=False, full_frame=False, persistent=False)
Return the configuration for ipython engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clean
|
bool
|
Engine should be clean. Defaults to False. |
False
|
full_frame
|
bool
|
Engine shoul be full frame. Defaults to False. |
False
|
persistent
|
bool
|
Engine should persist. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Configuration |
Source code in pyrevitlib/pyrevit/runtime/__init__.py
create_ext_command_attrs()
Create dotnet attributes for Revit external commands.
This method is used in creating custom dotnet types for pyRevit commands
and compiling them into a DLL assembly. Current implementation sets
RegenerationOption.Manual and TransactionMode.Manual
Returns:
| Type | Description |
|---|---|
list[CustomAttributeBuilder]
|
object for |
Source code in pyrevitlib/pyrevit/runtime/__init__.py
create_type(modulebuilder, type_class, class_name, custom_attr_list, *args)
Create a dotnet type for a pyRevit command.
See baseclasses.cs code for the template pyRevit command dotnet type
and its constructor default arguments that must be provided here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modulebuilder (
|
obj: |
required | |
type_class
|
type
|
source dotnet type for the command |
required |
class_name
|
str
|
name for the new type |
required |
custom_attr_list (
|
obj: |
required | |
*args
|
Any
|
list of arguments to be used with type constructor |
()
|
Returns:
| Type | Description |
|---|---|
type
|
returns created dotnet type |
Examples:
asm_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(
win_asm_name, AssemblyBuilderAccess.RunAndSave, filepath
)
module_builder = asm_builder.DefineDynamicModule(
ext_asm_file_name, ext_asm_full_file_name
)
create_type(
module_builder,
runtime.ScriptCommand,
"PyRevitSomeCommandUniqueName",
runtime.create_ext_command_attrs(),
[scriptpath, atlscriptpath, searchpath, helpurl, name,
bundle, extension, uniquename, False, False])
Source code in pyrevitlib/pyrevit/runtime/__init__.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |