Skip to content

components

Base classes for pyRevit extension components.

Attributes

mlogger = get_logger(__name__) module-attribute

EXT_HASH_VALUE_KEY = 'dir_hash_value' module-attribute

EXT_HASH_VERSION_KEY = 'pyrvt_version' module-attribute

Classes

NoButton(cmp_path=None, needs_script=True)

Bases: GenericUICommand

This is not a button.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def __init__(self, cmp_path=None, needs_script=True):
    self.needs_script = needs_script
    self.script_file = self.config_script_file = None
    self.arguments = []
    self.context = None
    self.class_name = self.avail_class_name = None
    self.requires_clean_engine = False
    self.requires_fullframe_engine = False
    self.requires_persistent_engine = False
    self.requires_mainthread_engine = False
    # engine options specific to dynamo
    self.dynamo_path = None
    # self.dynamo_path_exec = False
    self.dynamo_path_check_existing = False
    self.dynamo_force_manual_run = False
    self.dynamo_model_nodes_info = None
    # using classname otherwise exceptions in superclasses won't show
    GenericUIComponent.__init__(self, cmp_path=cmp_path)

    mlogger.debug('Maximum host version: %s', self.max_revit_ver)
    mlogger.debug('Minimum host version: %s', self.min_revit_ver)
    mlogger.debug('command tooltip: %s', self._tooltip)
    mlogger.debug('Command author: %s', self.author)
    mlogger.debug('Command help url: %s', self._help_url)

    if self.is_beta:
        mlogger.debug('Command is in beta.')

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = None instance-attribute
config_script_file = None instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
type_id = exts.NOGUI_COMMAND_POSTFIX class-attribute instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file

NoScriptButton(cmp_path=None, needs_commandclass=False)

Bases: GenericUICommand

Base for buttons that doesn't run a script.

Source code in pyrevitlib/pyrevit/extensions/components.py
def __init__(self, cmp_path=None, needs_commandclass=False):
    # using classname otherwise exceptions in superclasses won't show
    GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False)
    self.assembly = self.command_class = self.avail_command_class = None
    # read metadata from metadata file
    if self.meta:
        # get the target assembly from metadata
        self.assembly = \
            self.meta.get(exts.MDATA_LINK_BUTTON_ASSEMBLY, None)

        # get the target command class from metadata
        self.command_class = \
            self.meta.get(exts.MDATA_LINK_BUTTON_COMMAND_CLASS, None)

        # get the target command class from metadata
        self.avail_command_class = \
            self.meta.get(exts.MDATA_LINK_BUTTON_AVAIL_COMMAND_CLASS, None)

        # for invoke buttons there is no script source so
        # assign the metadata file to the script
        self.script_file = self.config_script_file = self.meta_file
    else:
        mlogger.debug("%s does not specify target assembly::class.", self)

    if self.directory and not self.assembly:
        mlogger.error("%s does not specify target assembly.", self)

    if self.directory and needs_commandclass and not self.command_class:
        mlogger.error("%s does not specify target command class.", self)

    mlogger.debug('%s assembly.class: %s.%s',
                  self, self.assembly, self.command_class)

Attributes

type_id = None class-attribute instance-attribute
name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
assembly = None instance-attribute
command_class = None instance-attribute
avail_command_class = None instance-attribute
script_file = self.meta_file instance-attribute
config_script_file = self.meta_file instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file
get_target_assembly(required=False)
Source code in pyrevitlib/pyrevit/extensions/components.py
def get_target_assembly(self, required=False):
    assm_file = self.assembly.lower()
    if not assm_file.endswith(framework.ASSEMBLY_FILE_TYPE):
        assm_file += '.' + framework.ASSEMBLY_FILE_TYPE

    # try finding assembly for this specific host version
    target_asm_by_host = self.find_bundle_module(assm_file, by_host=True)
    if target_asm_by_host:
        return target_asm_by_host
    # try find assembly by its name
    target_asm = self.find_bundle_module(assm_file)
    if target_asm:
        return target_asm

    if required:
        mlogger.error("%s can not find target assembly.", self)

    return ''

LinkButton(cmp_path=None)

Bases: NoScriptButton

Link button.

Source code in pyrevitlib/pyrevit/extensions/components.py
def __init__(self, cmp_path=None):
    # using classname otherwise exceptions in superclasses won't show
    NoScriptButton.__init__(
        self,
        cmp_path=cmp_path,
        needs_commandclass=True
        )

    if self.context:
        mlogger.warn(
            "Linkbutton bundles do not support \"context:\". "
            "Use \"availability_class:\" instead and specify name of "
            "availability class in target assembly | %s", self
            )
        self.context = None

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = self.meta_file instance-attribute
config_script_file = self.meta_file instance-attribute
arguments = [] instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
assembly = None instance-attribute
command_class = None instance-attribute
avail_command_class = None instance-attribute
type_id = exts.LINK_BUTTON_POSTFIX class-attribute instance-attribute
context = None instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file
get_target_assembly(required=False)
Source code in pyrevitlib/pyrevit/extensions/components.py
def get_target_assembly(self, required=False):
    assm_file = self.assembly.lower()
    if not assm_file.endswith(framework.ASSEMBLY_FILE_TYPE):
        assm_file += '.' + framework.ASSEMBLY_FILE_TYPE

    # try finding assembly for this specific host version
    target_asm_by_host = self.find_bundle_module(assm_file, by_host=True)
    if target_asm_by_host:
        return target_asm_by_host
    # try find assembly by its name
    target_asm = self.find_bundle_module(assm_file)
    if target_asm:
        return target_asm

    if required:
        mlogger.error("%s can not find target assembly.", self)

    return ''

InvokeButton(cmp_path=None)

Bases: NoScriptButton

Invoke button.

Source code in pyrevitlib/pyrevit/extensions/components.py
def __init__(self, cmp_path=None):
    # using classname otherwise exceptions in superclasses won't show
    NoScriptButton.__init__(self, cmp_path=cmp_path)

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = self.meta_file instance-attribute
config_script_file = self.meta_file instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
assembly = None instance-attribute
command_class = None instance-attribute
avail_command_class = None instance-attribute
type_id = exts.INVOKE_BUTTON_POSTFIX class-attribute instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file
get_target_assembly(required=False)
Source code in pyrevitlib/pyrevit/extensions/components.py
def get_target_assembly(self, required=False):
    assm_file = self.assembly.lower()
    if not assm_file.endswith(framework.ASSEMBLY_FILE_TYPE):
        assm_file += '.' + framework.ASSEMBLY_FILE_TYPE

    # try finding assembly for this specific host version
    target_asm_by_host = self.find_bundle_module(assm_file, by_host=True)
    if target_asm_by_host:
        return target_asm_by_host
    # try find assembly by its name
    target_asm = self.find_bundle_module(assm_file)
    if target_asm:
        return target_asm

    if required:
        mlogger.error("%s can not find target assembly.", self)

    return ''

PushButton(cmp_path=None, needs_script=True)

Bases: GenericUICommand

Push button.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def __init__(self, cmp_path=None, needs_script=True):
    self.needs_script = needs_script
    self.script_file = self.config_script_file = None
    self.arguments = []
    self.context = None
    self.class_name = self.avail_class_name = None
    self.requires_clean_engine = False
    self.requires_fullframe_engine = False
    self.requires_persistent_engine = False
    self.requires_mainthread_engine = False
    # engine options specific to dynamo
    self.dynamo_path = None
    # self.dynamo_path_exec = False
    self.dynamo_path_check_existing = False
    self.dynamo_force_manual_run = False
    self.dynamo_model_nodes_info = None
    # using classname otherwise exceptions in superclasses won't show
    GenericUIComponent.__init__(self, cmp_path=cmp_path)

    mlogger.debug('Maximum host version: %s', self.max_revit_ver)
    mlogger.debug('Minimum host version: %s', self.min_revit_ver)
    mlogger.debug('command tooltip: %s', self._tooltip)
    mlogger.debug('Command author: %s', self.author)
    mlogger.debug('Command help url: %s', self._help_url)

    if self.is_beta:
        mlogger.debug('Command is in beta.')

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = None instance-attribute
config_script_file = None instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
type_id = exts.PUSH_BUTTON_POSTFIX class-attribute instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file

PanelPushButton(cmp_path=None, needs_script=True)

Bases: GenericUICommand

Panel push button.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def __init__(self, cmp_path=None, needs_script=True):
    self.needs_script = needs_script
    self.script_file = self.config_script_file = None
    self.arguments = []
    self.context = None
    self.class_name = self.avail_class_name = None
    self.requires_clean_engine = False
    self.requires_fullframe_engine = False
    self.requires_persistent_engine = False
    self.requires_mainthread_engine = False
    # engine options specific to dynamo
    self.dynamo_path = None
    # self.dynamo_path_exec = False
    self.dynamo_path_check_existing = False
    self.dynamo_force_manual_run = False
    self.dynamo_model_nodes_info = None
    # using classname otherwise exceptions in superclasses won't show
    GenericUIComponent.__init__(self, cmp_path=cmp_path)

    mlogger.debug('Maximum host version: %s', self.max_revit_ver)
    mlogger.debug('Minimum host version: %s', self.min_revit_ver)
    mlogger.debug('command tooltip: %s', self._tooltip)
    mlogger.debug('Command author: %s', self.author)
    mlogger.debug('Command help url: %s', self._help_url)

    if self.is_beta:
        mlogger.debug('Command is in beta.')

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = None instance-attribute
config_script_file = None instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
type_id = exts.PANEL_PUSH_BUTTON_POSTFIX class-attribute instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.

    This is used to uniquely identify this command
    and also to create the class in pyRevit dll assembly.
    Current method create a unique name based on the command
    full directory address.

    Examples:
        for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton'
        unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.
    """
    pieces = []
    inside_ext = False
    for dname in cmp_path.split(op.sep):
        if exts.ExtensionTypes.UI_EXTENSION.POSTFIX in dname:
            inside_ext = True

        name, ext = op.splitext(dname)
        if ext != '' and inside_ext:
            pieces.append(name)
        else:
            continue
    return coreutils.cleanup_string(
        exts.UNIQUE_ID_SEPARATOR.join(pieces),
        skip=[exts.UNIQUE_ID_SEPARATOR]
        ).lower()
get_full_bundle_name()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_full_bundle_name(self):
    return self.name + self.type_id
has_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_module_path(self, path):
    return path in self.module_paths
add_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def add_module_path(self, path):
    if path and not self.has_module_path(path):
        mlogger.debug('Appending syspath: %s to %s', path, self)
        self.module_paths.append(path)
remove_module_path(path)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def remove_module_path(self, path):
    if path and self.has_module_path(path):
        mlogger.debug('Removing syspath: %s from %s', path, self)
        return self.module_paths.remove(path)
get_bundle_file(file_name)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_bundle_file(self, file_name):
    if self.directory and file_name:
        file_addr = op.join(self.directory, file_name)
        return file_addr if op.exists(file_addr) else None
find_bundle_file(patterns, finder='postfix')
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_file(self, patterns, finder='postfix'):
    if self.directory:
        for bundle_file in os.listdir(self.directory):
            if 'name' == finder:
                for file_name in patterns:
                    if op.splitext(bundle_file)[0] == file_name:
                        return op.join(self.directory, bundle_file)
            elif 'postfix' == finder:
                for file_postfix in patterns:
                    if bundle_file.endswith(file_postfix):
                        return op.join(self.directory, bundle_file)
            elif 'regex' == finder:
                for regex_pattern in patterns:
                    if re.match(regex_pattern, bundle_file):
                        return op.join(self.directory, bundle_file)
    return None
find_bundle_module(module, by_host=False)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def find_bundle_module(self, module, by_host=False):
    # test of file_name is an actually path to a file
    if op.isfile(module):
        return module

    def build_assm_filename(module_filename):
        # build assembly by host version (assm_file_2020.ext)
        assm_name, assm_ext = op.splitext(module_filename)
        return assm_name + '_' + HOST_APP.version + assm_ext

    if by_host:
        module = build_assm_filename(module)

    # test if module is inside search paths
    for module_path in self.module_paths:
        possible_module_path = op.join(module_path, module)
        if op.isfile(possible_module_path):
            return possible_module_path
configure(config_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def configure(self, config_dict):
    configurable_params = \
        ['_ui_title', '_tooltip', '_help_url', 'author']
    # get root key:value pairs
    for key, value in config_dict.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
    # get key:value pairs grouped under special key, if exists
    templates = config_dict.get(exts.MDATA_TEMPLATES_KEY, {})
    for key, value in templates.items():
        for param_name in configurable_params:
            self._resolve_liquid_tag(param_name, key, value)
has_config_script()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def has_config_script(self):
    return self.config_script_file != self.script_file

SmartButton(cmp_path=None, needs_script=True)

Bases: GenericUICommand

Smart button.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def __init__(self, cmp_path=None, needs_script=True):
    self.needs_script = needs_script
    self.script_file = self.config_script_file = None
    self.arguments = []
    self.context = None
    self.class_name = self.avail_class_name = None
    self.requires_clean_engine = False
    self.requires_fullframe_engine = False
    self.requires_persistent_engine = False
    self.requires_mainthread_engine = False
    # engine options specific to dynamo
    self.dynamo_path = None
    # self.dynamo_path_exec = False
    self.dynamo_path_check_existing = False
    self.dynamo_force_manual_run = False
    self.dynamo_model_nodes_info = None
    # using classname otherwise exceptions in superclasses won't show
    GenericUIComponent.__init__(self, cmp_path=cmp_path)

    mlogger.debug('Maximum host version: %s', self.max_revit_ver)
    mlogger.debug('Minimum host version: %s', self.min_revit_ver)
    mlogger.debug('command tooltip: %s', self._tooltip)
    mlogger.debug('Command author: %s', self.author)
    mlogger.debug('Command help url: %s', self._help_url)

    if self.is_beta:
        mlogger.debug('Command is in beta.')

Attributes

name = None instance-attribute
is_container property
directory = cmp_path instance-attribute
unique_name = None instance-attribute
parent_ctrl_id = None instance-attribute
icon_file = None instance-attribute
author = None instance-attribute
media_file = None instance-attribute
min_revit_ver = None instance-attribute
max_revit_ver = None instance-attribute
is_beta = False instance-attribute
highlight_type = None instance-attribute
collapsed = False instance-attribute
version = None instance-attribute
meta = {} instance-attribute
meta_file = None instance-attribute
modules = [] instance-attribute
module_paths = [] instance-attribute
binary_path = None instance-attribute
library_path = None instance-attribute
control_id property
ui_title property
tooltip property
help_url property
is_supported property
needs_script = needs_script instance-attribute
script_file = None instance-attribute
config_script_file = None instance-attribute
arguments = [] instance-attribute
context = None instance-attribute
class_name = None instance-attribute
avail_class_name = None instance-attribute
requires_clean_engine = False instance-attribute
requires_fullframe_engine = False instance-attribute
requires_persistent_engine = False instance-attribute
requires_mainthread_engine = False instance-attribute
dynamo_path = None instance-attribute
dynamo_path_check_existing = False instance-attribute
dynamo_force_manual_run = False instance-attribute
dynamo_model_nodes_info = None instance-attribute
script_language property
is_cpython property
type_id = exts.SMART_BUTTON_POSTFIX class-attribute instance-attribute

Functions

get_cache_data()
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def get_cache_data(self):
    cache_dict = self.__dict__.copy()
    if hasattr(self, TYPE_ID_KEY):
        cache_dict[TYPE_ID_KEY] = getattr(self, TYPE_ID_KEY)
    return cache_dict
load_cache_data(cache_dict)
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
def load_cache_data(self, cache_dict):
    for k, v in cache_dict.items():
        self.__dict__[k] = v
matches(component_path) classmethod
Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def matches(cls, component_path):
    return component_path.lower().endswith(cls.type_id)
make_unique_name(cmp_path) classmethod

Creates a unique name for the command.

This is used to uniquely identify this command and also to create the class in pyRevit dll assembly. Current method create a unique name based on the command full directory address.

Examples:

for 'pyRevit.extension/pyRevit.tab/Edit.panel/Flip doors.pushbutton' unique name would be: 'pyrevit-pyrevit-edit-flipdoors'.

Source code in pyrevitlib/pyrevit/extensions/genericcomps.py
@classmethod
def make_unique_name(cls, cmp_path):
    """Creates a unique name for the command.