So … yet again … reviewing my code, thinking about the ‘needs’ and ‘stupid stuff’ / ‘is it necessary’.
I make lots of scripts for our company and while I use them often, I’m also curious why else uses them. If not used, I can remove the scripts from our toolbar, or notify people of the sweetness of the script.
Since like forever I’m using an open-txt-file-add-stuff-close-file method. This always felt horrible to me, but it worked. Now I’m at the point of 1. remove the logging at all or 2. setup a better approach (lite weight database?)
Share your thoughts / suggestions. I’m open to them all
def log():
if not revit.doc.IsFamilyDocument:
import __main__
project_nummer = projectnummer()
date = datetime.now().strftime("%d %B %Y")
script_naam = os.path.basename(__main__.__file__)[:-10]
log_path = "T:\\Revit addons\\Our Tools\\our.log\\{}\\".format(str(datetime.now().year))
bestand = log_path + "our_tools_log.txt"
val = "{}\t{}\t{}".format(script_naam, project_nummer, date)
exists = os.path.isfile(bestand)
if exists:
with open(bestand, "a+") as f:
f.writelines(val)
return "Log: {} {}".format(log_path, val)
print "Log ({})bestand bestaat niet.".format(bestand)
# output
# pdf 1234 02 January 2024