# BIMTester - OpenBIM Auditing Tool # Copyright (C) 2021 Dion Moult # # This file is part of BIMTester. # # BIMTester is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # BIMTester is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with BIMTester. If not, see . import fileinput import uuid def create_zoom_set_of_smartviews(sm_file, smartviewset_name): # smartviewset_name: is the directory name in Zoom the SmartViews are in smf = open(sm_file, "w") smf.write('\n') smf.write("\n") smf.write(" 5\n") smf.write(" Win - Version: ") # next line belongs to last, because of line length smf.write("3.4 (build 3.4.13.559)\n") smf.write("\n") smf.write("\n") smf.write("\n") smf.write(" \n") smf.write(" BIMTester {}\n".format(smartviewset_name)) smf.write(" \n") smf.write(" a2ddfaf7-97f2-4519-aabd-f2d94f6b4d6b\n") smf.write(" 2020-10-30T13:23:30") # next line belongs to last, because of line length smf.write("\n") smf.write(" \n") smf.write(" \n") smf.write(" \n") smf.write("\n") smf.close() def add_smartview(sm_file, smartview_name, guids): # smartview_name: is the name of the SmartView in Zoom # guids: List of guids # model will be grey and transparent, the guids objs will be red and not transparent # build the smartview string smview_string = " \n" smview_string += " GUID filter, {}\n".format(smartview_name) smview_string += "{}\n".format(each_smartview_string_before1) smview_string += str(uuid.uuid4()) # create and add a smart view guid smview_string += "{}\n".format(each_smartview_string_before2) for guid in guids: smview_string += "{}{}{}\n".format(rule_string_before, guid, rule_string_after) smview_string += "{}\n".format(each_smartview_string_after) # insert smartview string into file theline = " " newtext = smview_string + theline for line in fileinput.FileInput(sm_file, inplace=True): # the print replaces the line in the file # and add the line afterwards print(line.replace(theline, newtext), end="") each_smartview_string_title = """ Filter GUID """ each_smartview_string_before1 = """ bernd@bimstatik.ch 2020-10-30T13:18:45 bernd@bimstatik.ch 2020-10-30T13:23:30 """ each_smartview_string_before2 = """ Any None None None None None Is AddSetColored 187 187 187 Any None None None None None Is SetTransparent """ each_smartview_string_after = """ None None 0 """ rule_string_before = """ Any GUID Summary Summary StringValue None Is """ rule_string_after = """ SetColored 255 10 10 """