コード例 #1
0
def applyzoomstate1(sender, args):
    if script.get_envvar(SYNC_VIEW_ENV_VAR):
        event_uidoc = sender.ActiveUIDocument
        event_doc = sender.ActiveUIDocument.Document
        active_ui_views = event_uidoc.GetOpenUIViews()
        current_ui_view = None
        for active_ui_view in active_ui_views:
            if active_ui_view.ViewId == args.CurrentActiveView.Id:
                current_ui_view = active_ui_view

        if isinstance(args.CurrentActiveView, DB.ViewPlan):
            project_name = op.splitext(op.basename(event_doc.PathName))[0]
            data_filename = project_name + '_pySyncRevitActiveViewZoomState'
            data_file = script.get_instance_data_file(data_filename)
            f = open(data_file, 'r')
            p2 = pl.load(f)
            p1 = pl.load(f)
            f.close()
            vc1 = DB.XYZ(p1.x, p1.y, 0)
            vc2 = DB.XYZ(p2.x, p2.y, 0)
            current_ui_view.ZoomAndCenterRectangle(vc1, vc2)
        logFile = open(
            "\\\\stvgroup.stvinc.com\\p\\NYNY\\Practices\\Hazem Kahla\\RevitLogs\\"
            + str(datetime.date.today()) + "_" +
            str(sender.ActiveUIDocument.Document.Application.Username) +
            ".txt", "w")
        logFile.write(
            str(datetime.datetime) + "_" + "LouM" + "_" + "Log Start")
        logFile.close()
コード例 #2
0
def copyzoomstate(sender, args):
    if envvars.get_pyrevit_env_var(SYNC_VIEW_ENV_VAR):
        event_uidoc = sender.ActiveUIDocument
        event_doc = sender.ActiveUIDocument.Document
        active_ui_views = event_uidoc.GetOpenUIViews()
        current_ui_view = None
        for active_ui_view in active_ui_views:
            if active_ui_view.ViewId == args.CurrentActiveView.Id:
                current_ui_view = active_ui_view

        if isinstance(args.CurrentActiveView, DB.ViewPlan):
            project_name = op.splitext(op.basename(event_doc.PathName))[0]
            data_filename = project_name + '_pySyncRevitActiveViewZoomState'
            data_file = script.get_instance_data_file(data_filename)

            cornerlist = current_ui_view.GetZoomCorners()

            vc1 = cornerlist[0]
            vc2 = cornerlist[1]
            p1 = Point()
            p2 = Point()
            p1.x = vc1.X
            p1.y = vc1.Y
            p2.x = vc2.X
            p2.y = vc2.Y

            f = open(data_file, 'w')
            pl.dump(p1, f)
            pl.dump(p2, f)
            f.close()
コード例 #3
0
def recover_sharedparam_defs(sharedparam_def_contents):
    global family_cfg_file

    # get a temporary text file to store the generated shared param data
    temp_defs_filepath = \
        script.get_instance_data_file(
            file_id=coreutils.get_file_name(family_cfg_file),
            add_cmd_name=True
        )

    revit.files.write_text(temp_defs_filepath, sharedparam_def_contents)

    return temp_defs_filepath
コード例 #4
0
ファイル: script.py プロジェクト: xulian070608/pyRevit
    def _get_schedule_text_data(self, schedule_view):
        schedule_data_file = \
            script.get_instance_data_file(str(schedule_view.Id.IntegerValue))
        vseop = DB.ViewScheduleExportOptions()
        vseop.TextQualifier = DB.ExportTextQualifier.None
        schedule_view.Export(op.dirname(schedule_data_file),
                             op.basename(schedule_data_file), vseop)

        sched_data = []
        try:
            with codecs.open(schedule_data_file, 'r', 'utf_16_le') \
                    as sched_data_file:
                return sched_data_file.readlines()
        except Exception as open_err:
            logger.error('Error opening sheet index export: %s | %s',
                         schedule_data_file, open_err)
            return sched_data
コード例 #5
0
    def _get_schedule_text_data(self, schedule_view):
        schedule_data_file = \
            script.get_instance_data_file(str(schedule_view.Id.IntegerValue))
        vseop = DB.ViewScheduleExportOptions()
        vseop.TextQualifier = coreutils.get_enum_none(DB.ExportTextQualifier)
        schedule_view.Export(op.dirname(schedule_data_file),
                             op.basename(schedule_data_file), vseop)

        sched_data = []
        try:
            with codecs.open(schedule_data_file, 'r', EXPORT_ENCODING) \
                    as sched_data_file:
                return [x.strip() for x in sched_data_file.readlines()]
        except Exception as open_err:
            logger.error('Error opening sheet index export: %s | %s',
                         schedule_data_file, open_err)
            return sched_data
コード例 #6
0
def applyzoomstate(sender, args):
    if envvars.get_pyrevit_env_var(SYNC_VIEW_ENV_VAR):
        event_uidoc = sender.ActiveUIDocument
        event_doc = sender.ActiveUIDocument.Document
        active_ui_views = event_uidoc.GetOpenUIViews()
        current_ui_view = None
        for active_ui_view in active_ui_views:
            if active_ui_view.ViewId == args.CurrentActiveView.Id:
                current_ui_view = active_ui_view

        if isinstance(args.CurrentActiveView, DB.ViewPlan):
            project_name = op.splitext(op.basename(event_doc.PathName))[0]
            data_filename = project_name + '_pySyncRevitActiveViewZoomState'
            data_file = script.get_instance_data_file(data_filename)
            f = open(data_file, 'r')
            p2 = pl.load(f)
            p1 = pl.load(f)
            f.close()
            vc1 = DB.XYZ(p1.x, p1.y, 0)
            vc2 = DB.XYZ(p2.x, p2.y, 0)
            current_ui_view.ZoomAndCenterRectangle(vc1, vc2)
コード例 #7
0
def get_shared_param_def_contents(shared_params):
    global family_cfg_file

    # get a temporary text file to store the generated shared param data
    temp_defs_filepath = \
        script.get_instance_data_file(
            file_id=coreutils.get_file_name(family_cfg_file),
            add_cmd_name=True
        )
    # make sure the file exists and it is empty
    open(temp_defs_filepath, 'w').close()

    # swap existing shared param with temp
    existing_sharedparam_file = HOST_APP.app.SharedParametersFilename
    HOST_APP.app.SharedParametersFilename = temp_defs_filepath
    # write the shared param data
    store_sharedparam_def(shared_params)
    # restore the original shared param file
    HOST_APP.app.SharedParametersFilename = existing_sharedparam_file

    return revit.files.read_text(temp_defs_filepath)
コード例 #8
0
def copyzoomstate1(sender, args):
    if script.get_envvar(SYNC_VIEW_ENV_VAR):
        event_uidoc = sender.ActiveUIDocument
        event_doc = sender.ActiveUIDocument.Document
        active_ui_views = event_uidoc.GetOpenUIViews()
        current_ui_view = None
        for active_ui_view in active_ui_views:
            if active_ui_view.ViewId == args.CurrentActiveView.Id:
                current_ui_view = active_ui_view

        if isinstance(args.CurrentActiveView, DB.ViewPlan):
            project_name = op.splitext(op.basename(event_doc.PathName))[0]
            data_filename = project_name + '_pySyncRevitActiveViewZoomState'
            data_file = script.get_instance_data_file(data_filename)

            cornerlist = current_ui_view.GetZoomCorners()

            vc1 = cornerlist[0]
            vc2 = cornerlist[1]
            p1 = Point()
            p2 = Point()
            p1.x = vc1.X
            p1.y = vc1.Y
            p2.x = vc2.X
            p2.y = vc2.Y

            f = open(data_file, 'w')
            pl.dump(p1, f)
            pl.dump(p2, f)
            f.close()

        logFile = open(
            "\\\\stvgroup.stvinc.com\\p\\NYNY\\Practices\\Hazem Kahla\\RevitLogs\\"
            + str(datetime.date.today()) + "_" +
            str(sender.ActiveUIDocument.Document.Application.Username) +
            ".txt", "w")
        logFile.write(
            str(datetime.datetime) + "_" + "LouM" + "_" + "Log Start")
        logFile.close()
コード例 #9
0
ファイル: script.py プロジェクト: FNXE/pyRevit
def get_datafile(document):
    data_filename = get_data_filename(document)
    return script.get_instance_data_file(data_filename)
コード例 #10
0
def get_datafile(document):
    """Get datafile for given document"""
    data_filename = get_data_filename(document)
    return script.get_instance_data_file(data_filename)