Ejemplo n.º 1
0
def get_document_data_file(file_id, file_ext, add_cmd_name=False):
    """Return filename to be used by a user script to store data.

    File name is generated in this format:
    ``pyRevit_{Revit Version}_{file_id}_{Project Name}.{file_ext}``

    Example:
        >>> script.get_document_data_file('mydata', 'data')
        '.../pyRevit_2018_mydata_Project1.data'
        >>> script.get_document_data_file('mydata', 'data', add_cmd_name=True)
        '.../pyRevit_2018_Command Name_mydata_Project1.data'

    Document data files are not cleaned up at pyRevit startup.
    Script should manage cleaning up these files.

    Args:
        file_id (str): unique id for the filename
        file_ext (str): file extension
        add_cmd_name (bool, optional): add command name to file name

    Returns:
        str: full file path
    """
    proj_info = revit.get_project_info()  #pylint: disable=E1101

    if add_cmd_name:
        script_file_id = '{}_{}_{}'.format(
            EXEC_PARAMS.command_name, file_id, proj_info.filename
            or proj_info.name)
    else:
        script_file_id = '{}_{}'.format(file_id, proj_info.filename
                                        or proj_info.name)

    return appdata.get_data_file(script_file_id, file_ext)
Ejemplo n.º 2
0
# Sets variables for export filenames
#export_folder = "Export_dynamo"
backup_extension = "bak"
filename_extension = "csv"
filename_revclouds = "x_revclouds"
filename_sheets = "x_sheets"
filename_manual = "man"

# Begin console window
console = script.get_output()
console.set_height(400)
console.lock_size()

report_title = 'Revision Export'
report_date = coreutils.current_date()
report_project = revit.get_project_info().name

# setup element styling
console.add_style(
    'table { border-collapse: collapse; width:100% }'
    'table, th, td { border-bottom: 1px solid #aaa; padding: 5px;}'
    'th { background-color: #545454; color: white; }'
    'tr:nth-child(odd) {background-color: #f2f2f2}')
#-----RETURN DOCUMENT FOLDER AND FILENAME-------------
# Get full path of current document
try:
    docpath = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(
        revit.doc.GetWorksharingCentralModelPath())
except:
    docpath = revit.doc.PathName
Ejemplo n.º 3
0
"""Saves current selection memory as a Selection Filter."""

import os
import os.path as op
import pickle as pl

from pyrevit.coreutils import timestamp
from pyrevit import revit, DB
from pyrevit import script

proj_info = revit.get_project_info()
datafile = script.get_document_data_file("SelList", "pym")

if op.exists(datafile):
    if proj_info.name:
        filtername = 'SavedSelection_' + proj_info.name + '_' + timestamp()
    else:
        filtername = 'SavedSelection_' + timestamp()

    with open(datafile, 'r') as f:
        cursel = pl.load(f)

    with revit.Transaction('pySaveSelection'):
        selFilter = DB.SelectionFilterElement.Create(revit.doc, filtername)
        for elid in cursel:
            selFilter.AddSingle(DB.ElementId(int(elid)))