def export_keynotes(self, sender, args): kfile = forms.save_file('txt') if kfile: logger.debug('Exporting keynotes to: %s' % kfile) try: kdb.export_legacy_keynotes(self._conn, kfile) except System.TimeoutException as toutex: forms.alert(toutex.Message)
def create_definition_file(cls, path_and_name=None): """Create a new DefinitionFile to store SharedParameter definitions :param path_and_name: file path and name including extension (.txt file) :rtype: DefinitionFile """ if path_and_name is None: path_and_name = forms.save_file( file_ext="txt", default_name="pyrevit_sharedparameters") with open(path_and_name, "w"): pass HOST_APP.app.SharedParametersFilename = path_and_name return cls.get_definition_file()
def export_visible_keynotes(self, sender, args): kfile = forms.save_file('txt') if kfile: logger.debug('Exporting visible keynotes to: %s' % kfile) include_list = set() for rkey in self.current_keynotes: include_list.update(rkey.collect_keys()) try: kdb.export_legacy_keynotes(self._conn, kfile, include_keys=include_list) except System.TimeoutException as toutex: forms.alert(toutex.Message)
def write_csv(all_rows): default_filename = "textnotes_%s.csv" % doc.Title try: init_dir = my_config.init_dir if not os.path.exists(init_dir): init_dir = '' except: init_dir = '' export_file = save_file(file_ext="csv", init_dir=init_dir, default_name=default_filename) print('%s\n\nWriting...' % export_file) with open(export_file, 'w') as f: writer = csv.writer(f, delimiter=';', quotechar='"', quoting=csv.QUOTE_MINIMAL, lineterminator='\n') writer.writerow( ['Sheet', 'SheetID', 'View', 'ViewID', 'Text', 'TextId']) writer.writerow([]) for r in all_rows: row = [] for v in r: try: vv = v.ToString() except: vv = str(v) row.append(vv) writer.writerow([unicode(s).encode("utf-8") for s in row]) print('Completed')
def get_config_file(): # Get parameter definition yaml file from user return forms.save_file(file_ext='yaml')
def alertReopen(): forms.alert( 'Note that changes won\'t take effect until the current file is closed and reopened again.' ) res = None optionSelect = 'Select or create database' optionDisable = 'Disable logging' optionCancel = 'Close' if not sqliteFile: res = forms.alert(msgDisabled, options=[optionSelect, optionCancel]) else: res = forms.alert(msgEnabled.format(sqliteFile), options=[optionSelect, optionDisable, optionCancel]) if res == optionSelect: sqliteFile = forms.save_file(file_ext='sqlite', default_name='{}.sqlite'.format( revitron.DOC.Title), unc_paths=False) if sqliteFile: revitron.DocumentConfigStorage().set('revitron.history', {'file': sqliteFile}) alertReopen() if res == optionDisable: revitron.DocumentConfigStorage().set('revitron.history', dict()) alertReopen()
# print(doc_dirname) doc_basename = os.path.basename(doc_pathname) new_basename = doc_basename.split(' ОВ v')[0] + ' ОВ.rvt' # print(doc_basename) # print(os.path.join(doc_dirname, doc_basename)) # print(os.path.dirname(path)) storage_path = os.path.join( doc_dirname, doc_basename.split(' ОВ v')[0] + ' Путь в сети.txt') try: remote_path = open(storage_path, 'r').read().decode("utf-8") # print(remote_path) except IOError: remote_path = forms.save_file(file_ext='', default_name=new_basename, init_dir=doc_dirname, files_filter='') if remote_path: with codecs.open(storage_path, mode='w', encoding='utf-8') as f: f.write(remote_path) else: sys.exit() if os.access(remote_path, os.F_OK): old_path = os.path.join(os.path.dirname(remote_path), 'old') # print(old_path) if not os.access(old_path, os.F_OK): os.mkdir(old_path) basename = os.path.basename(remote_path) timestamp = os.path.getctime(remote_path) (mode, ino, dev, nlink, uid, gid, size, atime, mtime,