From 97aea8a4ed792fdad782c4598627ff7e5fce5bc1 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 11 Jan 2016 22:08:02 -0200 Subject: [PATCH] Arch: search for profiles.csv also in current dir --- src/Mod/Arch/ArchProfile.py | 42 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Mod/Arch/ArchProfile.py b/src/Mod/Arch/ArchProfile.py index 9e4be0f97..38c3eb8f6 100644 --- a/src/Mod/Arch/ArchProfile.py +++ b/src/Mod/Arch/ArchProfile.py @@ -38,30 +38,32 @@ __author__ = "Yorik van Havre" __url__ = "http://www.freecadweb.org" # Presets in the form: Class, Name, Profile type, [profile data] -# Loaded from Mod/Arch/Data/beams.csv -profilefiles = [os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","profiles.csv")] +# Search for profiles.csv in data/Mod/Arch/Presets and in the same folder as this file +profilefiles = [os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","profiles.csv"), + os.path.join(os.path.basedir(__file__),"Presets","profiles.csv")] def readPresets(): Presets=[None] for profilefile in profilefiles: - try: - with open(profilefile, 'rb') as csvfile: - beamreader = csv.reader(csvfile) - bid=1 #Unique index - for row in beamreader: - if row[0].startswith("#"): - continue - try: - r=[bid, row[0], row[1], row[2]] - for i in range(3,len(row)): - r=r+[float(row[i])] - if not r in Presets: - Presets.append(r) - bid=bid+1 - except ValueError: - print "Skipping bad line: "+str(row) - except IOError: - print "Could not open ",profilefile + if os.path.exists(profilefile): + try: + with open(profilefile, 'rb') as csvfile: + beamreader = csv.reader(csvfile) + bid=1 #Unique index + for row in beamreader: + if row[0].startswith("#"): + continue + try: + r=[bid, row[0], row[1], row[2]] + for i in range(3,len(row)): + r=r+[float(row[i])] + if not r in Presets: + Presets.append(r) + bid=bid+1 + except ValueError: + print "Skipping bad line: "+str(row) + except IOError: + print "Could not open ",profilefile return Presets def makeProfile(profile=[0,'REC','REC100x100','R',100,100]):