예제 #1
0
    def get_pat_data(self):
        pat_type = 'MODEL' if self._model_pat else 'DRAFTING'
        from pyrevit.versionmgr import PYREVIT_VERSION
        pattern_desc = PAT_FILE_TEMPLATE.format(
            time=current_time(),
            date=current_date(),
            version=PYREVIT_VERSION.get_formatted(),
            name=self._name,
            type=pat_type)
        for pat_grid in self._pattern_grids:
            grid_desc = PAT_SEPARATOR.join([
                str(degrees(pat_grid.angle)),
                str(pat_grid.origin.u * self._scale),
                str(pat_grid.origin.v * self._scale),
                str(pat_grid.shift * self._scale),
                str(pat_grid.offset * self._scale)
            ])
            grid_desc += PAT_SEPARATOR
            if pat_grid.segments:
                scaled_segments = []
                for idx, seg in enumerate(pat_grid.segments):
                    if idx % 2 != 0:
                        seg *= -1
                    scaled_segments.append(seg * self._scale)

                grid_desc += PAT_SEPARATOR.join(
                    [str(seg_l) for seg_l in scaled_segments])

            pattern_desc += grid_desc + '\n'

        return pattern_desc
예제 #2
0
    def get_pat_data(self):
        pat_type = 'MODEL' if self._model_pat else 'DRAFTING'
        unit_type = 'INCH' if self._scale == 12 else 'MM'
        pyrvtver = versionmgr.get_pyrevit_version()
        pattern_desc = \
            PAT_FILE_TEMPLATE.format(time=coreutils.current_time(),
                                     date=coreutils.current_date(),
                                     version=pyrvtver.get_formatted(),
                                     units=unit_type,
                                     name=self._name,
                                     type=pat_type)

        for pat_grid in self._pattern_grids:
            grid_desc = \
                PAT_SEPARATOR.join([str(degrees(pat_grid.angle)),
                                    str(pat_grid.origin.u * self._scale),
                                    str(pat_grid.origin.v * self._scale),
                                    str(pat_grid.shift * self._scale),
                                    str(pat_grid.offset * self._scale)])
            grid_desc += PAT_SEPARATOR
            if pat_grid.segments:
                scaled_segments = []
                for idx, seg in enumerate(pat_grid.segments):
                    if idx % 2 != 0:
                        seg *= -1
                    scaled_segments.append(seg * self._scale)

                grid_desc += PAT_SEPARATOR.join([str(seg_l)
                                                 for seg_l in scaled_segments])

            pattern_desc += grid_desc + '\n'

        return pattern_desc
예제 #3
0
def resolve_naming_conflicts(category, sched_name, fields, doc=None):
    """Decide what to do if there is an existing sched with identical name

    This function needs to check these conditions, in this order:
        1- exisiting key schedule for given category, with any of the fields
        2- existing any schedule with matching name

    Exisiting key schedule for given category, with identical fields, has
    already been checked for and the update function would be called
    """
    doc = doc or revit.doc

    all_schedules = \
        revit.query.get_all_views(doc=doc, view_types=[DB.ViewType.Schedule])
    # check for existing key schedules (check 1)
    matching_keysched = next(
        (x for x in all_schedules if x.Definition.IsKeySchedule
         and x.Definition.CategoryId == category.Id), None)
    if matching_keysched:
        cfield = has_field_conflicts(matching_keysched.Definition, fields)
        if cfield:
            if forms.alert(
                    "Field \"{}\" is already used by another "
                    "key schedule \"{}\". Multiple key schedules can not "
                    "set values for same parameter. Do you want to delete "
                    "the existing key schedule first?".format(
                        cfield, matching_keysched.Name),
                    yes=True,
                    no=True):
                # the the process continue to check matching names below
                if not safe_delete_keysched(doc, matching_keysched):
                    return None
            else:
                return None

    # by now, if there was a key schdule matching name, it is deleted
    # check for matching view names, of other types
    all_schedules = \
        revit.query.get_all_views(doc=doc, view_types=[DB.ViewType.Schedule])
    existing_sched = \
        revit.query.get_view_by_name(sched_name,
                                     view_types=[DB.ViewType.Schedule])
    if existing_sched:
        if forms.alert(
                "There is an existing schedule with the same name \"{}\"."
                "Do you want to choose a new name for this key schedule?".
                format(sched_name),
                yes=True,
                no=True):
            return forms.ask_for_unique_string(
                reserved_values=[x.Name for x in all_schedules],
                default='{} {}'.format(sched_name, coreutils.current_date()))
        return None
    return sched_name
예제 #4
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
예제 #5
0
파일: script.py 프로젝트: rheesk22/pyrevit
def resolve_messy_conflicts(category, sched_name, fields, doc=None):
    """Decide what to do if there is an existing sched with identical name"""
    doc = doc or revit.doc
    all_schedules = \
        revit.query.get_all_views(doc=doc, view_types=[DB.ViewType.Schedule])
    # check for existing key schedules that use the fields already
    matching_keysched = next(
        (
            x for x in all_schedules
            if x.Definition.IsKeySchedule
            and x.Definition.CategoryId == category.Id
        ),
        None
    )
    if matching_keysched:
        cfield = has_field_conflicts(matching_keysched.Definition, fields)
        if cfield:
            if forms.alert(
                    "Field \"{}\" is already used by another "
                    "key schedule \"{}\". Multiple key schedules can not "
                    "set values for same parameter. Do you want to delete "
                    "the existing key schedule first?".format(
                        cfield,
                        matching_keysched.Name
                        ),
                    yes=True, no=True):
                # the the process continue to check matching names below
                if not safe_delete_keysched(doc, matching_keysched):
                    return None

    # check for matching view names
    all_schedules = \
        revit.query.get_all_views(doc=doc, view_types=[DB.ViewType.Schedule])
    existing_view = \
        revit.query.get_view_by_name(sched_name,
                                     view_types=[DB.ViewType.Schedule])
    if existing_view:
        if isinstance(existing_view, DB.ViewSchedule) \
                and existing_view.Definition.IsKeySchedule \
                and existing_view.Definition.CategoryId == category.Id:
            if forms.alert(
                    "There is a \"{}\" key schedule with name \"{}\". "
                    "Do you want to delete this first?".format(
                        category.Name,
                        sched_name),
                    yes=True, no=True):
                if safe_delete_keysched(doc, existing_view):
                    return sched_name
        else:
            if forms.alert(
                    "There is a view with the same name \"{}\" but it is "
                    "not a key schedule! Do you want to choose a new name "
                    "for this key schedule?"
                    .format(sched_name),
                    yes=True, no=True):
                return forms.ask_for_unique_string(
                    reserved_values=[x.Name for x in all_schedules],
                    default='{} {}'.format(sched_name, coreutils.current_date())
                )
        return None
    return sched_name