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)
def __init__(self, cmp_path=None): # using classname otherwise exceptions in superclasses won't show GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False) # find content file self.script_file = \ self.find_bundle_file([ exts.CONTENT_VERSION_POSTFIX.format( version=HOST_APP.version ), ]) if not self.script_file: self.script_file = \ self.find_bundle_file([ exts.CONTENT_POSTFIX, ]) # requires at least one bundles if self.directory and not self.script_file: mlogger.error('Command %s: Does not have content file.', self) self.script_file = '' # find alternative content file self.config_script_file = \ self.find_bundle_file([ exts.ALT_CONTENT_VERSION_POSTFIX.format( version=HOST_APP.version ), ]) if not self.config_script_file: self.config_script_file = \ self.find_bundle_file([ exts.ALT_CONTENT_POSTFIX, ]) if not self.config_script_file: self.config_script_file = ''
def __init_from_dir__(self, cmd_dir): GenericUICommand.__init_from_dir__(self, cmd_dir) full_file_path = op.join(self.directory, DEFAULT_ON_ICON_FILE) self.icon_on_file = full_file_path if op.exists(full_file_path) else None full_file_path = op.join(self.directory, DEFAULT_OFF_ICON_FILE) self.icon_off_file = full_file_path if op.exists(full_file_path) else None
def __init__(self): GenericUICommand.__init__(self) self.icon_on_file = self.icon_off_file = None if self.name: logger.deprecate('{} | Toggle bundle is deprecated and will be ' 'removed soon. Please use SmartButton bundle, ' 'or any other bundle and use script.toggle_icon ' 'method to toggle the tool icon.' .format(self.name))
def __init_from_dir__(self, cmd_dir): GenericUICommand.__init_from_dir__(self, cmd_dir) self.assembly = self.command_class = None try: # reading script file content to extract parameters script_content = ScriptFileParser(self.get_full_script_address()) self.assembly = script_content.extract_param(LINK_BUTTON_ASSEMBLY_PARAM) # type: str self.command_class = script_content.extract_param(LINK_BUTTON_COMMAND_CLASS_PARAM) # type: str except PyRevitException as err: logger.error(err) logger.debug('Link button assembly.class: {}.{}'.format(self.assembly, self.command_class))
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 = None # to support legacy linkbutton types using python global var convention # if has python script, read metadata if self.script_language == exts.PYTHON_LANG: try: # reading script file content to extract parameters script_content = \ coreutils.ScriptFileParser(self.script_file) self.assembly = \ script_content.extract_param(exts.LINK_BUTTON_ASSEMBLY) self.command_class = \ script_content.extract_param(exts.LINK_BUTTON_COMMAND_CLASS) if self.assembly or self.command_class: mlogger.deprecate( "Creating link buttons using \"__assembly__\" " "and \"__commandclass__\" global " "variables inside a python file is deprecated. " "use bundle.yaml instead. | %s", self) except PyRevitException as err: mlogger.error(err) # otherwise read metadata from metadata file elif 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) # 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 not self.assembly: mlogger.error("%s does not specify target assembly.", self) if 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)
def __init_from_dir__(self, cmd_dir): GenericUICommand.__init_from_dir__(self, cmd_dir) full_file_path = op.join(self.directory, exts.DEFAULT_ON_ICON_FILE) self.icon_on_file = \ full_file_path if op.exists(full_file_path) else None full_file_path = op.join(self.directory, exts.DEFAULT_OFF_ICON_FILE) self.icon_off_file = \ full_file_path if op.exists(full_file_path) else None if self.name: logger.deprecate('{} | Toggle bundle is deprecated and will be ' 'removed soon. Please use SmartButton bundle, ' 'or any other bundle and use script.toggle_icon ' 'method to toggle the tool icon.' .format(self.name))
def __init__(self, cmp_path=None): # using classname otherwise exceptions in superclasses won't show GenericUICommand.__init__(self, cmp_path=cmp_path, needs_script=False) self.target_url = None # read metadata from metadata file if self.meta: # get the target url from metadata self.target_url = \ self.meta.get(exts.MDATA_URL_BUTTON_HYPERLINK, None) # for url 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.target_url: mlogger.error("%s does not specify target url.", self) mlogger.debug('%s target url: %s', self, self.target_url)
def __init__(self): GenericUICommand.__init__(self) self.icon_on_file = self.icon_off_file = None
def __init__(self): GenericUICommand.__init__(self) self.assembly = self.command_class = None