From 6121e8dea44048d34f01010cf8b37df7eb1e0a4d Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 9 Jan 2016 16:04:11 -0200 Subject: [PATCH] Arch: new presets system for structures --- src/Mod/Arch/Arch.py | 1 + src/Mod/Arch/ArchProfile.py | 194 +++++++++++++++ src/Mod/Arch/ArchStructure.py | 396 ++++++------------------------ src/Mod/Arch/CMakeLists.txt | 10 + src/Mod/Arch/Presets/profiles.csv | 250 +++++++++++++++++++ 5 files changed, 527 insertions(+), 324 deletions(-) create mode 100644 src/Mod/Arch/ArchProfile.py create mode 100644 src/Mod/Arch/Presets/profiles.csv diff --git a/src/Mod/Arch/Arch.py b/src/Mod/Arch/Arch.py index 65a2c9f8e22d..387ebf0043be 100644 --- a/src/Mod/Arch/Arch.py +++ b/src/Mod/Arch/Arch.py @@ -45,6 +45,7 @@ from ArchSite import * from ArchBuilding import * from ArchStructure import * +from ArchProfile import * from ArchCommands import * from ArchSectionPlane import * from ArchWindow import * diff --git a/src/Mod/Arch/ArchProfile.py b/src/Mod/Arch/ArchProfile.py new file mode 100644 index 000000000000..cbacce1f481b --- /dev/null +++ b/src/Mod/Arch/ArchProfile.py @@ -0,0 +1,194 @@ +import FreeCAD, Draft, Part, os +from FreeCAD import Vector +import csv + +if FreeCAD.GuiUp: + import FreeCADGui + from PySide import QtCore, QtGui + from DraftTools import translate +else: + def translate(ctxt,txt): + return txt + +__title__="FreeCAD Profile" +__author__ = "XX" +__url__ = "XX" + +# 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")] + +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 + return Presets + +def makeProfile(profile=[0,'REC','REC100x100','R',100,100]): + '''makeProfile(profile): returns a shape with the face defined by the profile data''' + obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",profile[2]) + obj.Label = translate("Arch",profile[2]) + if profile[3]=="C": + _ProfileC(obj, profile) + elif profile[3]=="H": + _ProfileH(obj, profile) + elif profile[3]=="R": + _ProfileR(obj, profile) + elif profile[3]=="RH": + _ProfileRH(obj, profile) + elif profile[3]=="U": + _ProfileU(obj, profile) + else : + print "Profile not supported" + if FreeCAD.GuiUp: + Draft._ViewProviderDraft(obj.ViewObject) + return obj + +class _Profile(Draft._DraftObject): + '''Superclass for Profile classes''' + + def __init__(self,obj, profile): + self.Profile=profile + Draft._DraftObject.__init__(self,obj,"Profile") + + +class _ProfileC(_Profile): + '''A parametric circular tubeprofile. Profile data: [Outside diameter, Inside diameter]''' + + def __init__(self,obj, profile): + obj.addProperty("App::PropertyLength","OutDiameter","Draft","Outside Diameter").OutDiameter = profile[4] + obj.addProperty("App::PropertyLength","Thickness","Draft","Wall thickness").Thickness = profile[5] + _Profile.__init__(self,obj,profile) + + def execute(self,obj): + pl = obj.Placement + c1=Part.Circle() + c1.Radius=obj.OutDiameter.Value + c2=Part.Circle() + c2.Radius=obj.OutDiameter.Value-2*obj.Thickness.Value + cs1=c1.toShape() + cs2=c2.toShape() + p=Part.makeRuledSurface(cs2,cs1) + obj.Shape = p + obj.Placement = pl + +class _ProfileH(_Profile): + '''A parametric H or I beam profile. Profile data: [width, height, web thickness, flange thickness] (see http://en.wikipedia.org/wiki/I-beam for reference)''' + + def __init__(self,obj, profile): + obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = profile[4] + obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = profile[5] + obj.addProperty("App::PropertyLength","WebThickness","Draft","Thickness of the web").WebThickness = profile[6] + obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flanges").FlangeThickness = profile[7] + _Profile.__init__(self,obj,profile) + + def execute(self,obj): + pl = obj.Placement + p1 = Vector(-obj.Width.Value/2,-obj.Height.Value/2,0) + p2 = Vector(obj.Width.Value/2,-obj.Height.Value/2,0) + p3 = Vector(obj.Width.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) + p4 = Vector(obj.WebThickness.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) + p5 = Vector(obj.WebThickness.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) + p6 = Vector(obj.Width.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) + p7 = Vector(obj.Width.Value/2,obj.Height.Value/2,0) + p8 = Vector(-obj.Width.Value/2,obj.Height.Value/2,0) + p9 = Vector(-obj.Width.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) + p10 = Vector(-obj.WebThickness.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) + p11 = Vector(-obj.WebThickness.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) + p12 = Vector(-obj.Width.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) + p = Part.makePolygon([p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p1]) + p = Part.Face(p) + p.reverse() + obj.Shape = p + obj.Placement = pl + +class _ProfileR(_Profile): + '''A parametric rectangular beam profile based on [Width, Height]''' + + def __init__(self,obj, profile): + obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = profile[4] + obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = profile[5] + _Profile.__init__(self,obj,profile) + + def execute(self,obj): + pl = obj.Placement + p1 = Vector(-obj.Width.Value/2,-obj.Height.Value/2,0) + p2 = Vector(obj.Width.Value/2,-obj.Height.Value/2,0) + p3 = Vector(obj.Width.Value/2,obj.Height.Value/2,0) + p4 = Vector(-obj.Width.Value/2,obj.Height.Value/2,0) + p = Part.makePolygon([p1,p2,p3,p4,p1]) + p = Part.Face(p) + p.reverse() + obj.Shape = p + obj.Placement = pl + +class _ProfileRH(_Profile): + '''A parametric Rectangular hollow beam profile. Profile data: [width, height, thickness]''' + + def __init__(self,obj, profile): + obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = profile[4] + obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = profile[5] + obj.addProperty("App::PropertyLength","Thickness","Draft","Thickness of the sides").Thickness = profile[6] + _Profile.__init__(self,obj,profile) + + def execute(self,obj): + pl = obj.Placement + p1 = Vector(-obj.Width.Value/2,-obj.Height.Value/2,0) + p2 = Vector(obj.Width.Value/2,-obj.Height.Value/2,0) + p3 = Vector(obj.Width.Value/2,obj.Height.Value/2,0) + p4 = Vector(-obj.Width.Value/2,obj.Height.Value/2,0) + q1 = Vector(-obj.Width.Value/2+obj.Thickness.Value,-obj.Height.Value/2+obj.Thickness.Value,0) + q2 = Vector(obj.Width.Value/2-obj.Thickness.Value,-obj.Height.Value/2+obj.Thickness.Value,0) + q3 = Vector(obj.Width.Value/2-obj.Thickness.Value,obj.Height.Value/2-obj.Thickness.Value,0) + q4 = Vector(-obj.Width.Value/2+obj.Thickness.Value,obj.Height.Value/2-obj.Thickness.Value,0) + p = Part.makePolygon([p1,p2,p3,p4,p1]) + q = Part.makePolygon([q1,q2,q3,q4,q1]) + r = Part.Face([p,q]) + r.reverse() + obj.Shape = r + obj.Placement = pl + +class _ProfileU(_Profile): + '''A parametric H or I beam profile. Profile data: [width, height, web thickness, flange thickness] (see http://en.wikipedia.org/wiki/I-beam forreference)''' + + def __init__(self,obj, profile): + obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = profile[4] + obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = profile[5] + obj.addProperty("App::PropertyLength","WebThickness","Draft","Thickness of the webs").WebThickness = profile[6] + obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = profile[7] + _Profile.__init__(self,obj,profile) + + def execute(self,obj): + pl = obj.Placement + p1 = Vector(-obj.Width.Value/2,-obj.Height.Value/2,0) + p2 = Vector(obj.Width.Value/2,-obj.Height.Value/2,0) + p3 = Vector(obj.Width.Value/2,obj.Height.Value/2,0) + p4 = Vector(obj.Width.Value/2-obj.FlangeThickness.Value,obj.Height.Value/2,0) + p5 = Vector(obj.Width.Value/2-obj.FlangeThickness.Value,obj.WebThickness.Value-obj.Height.Value/2,0) + p6 = Vector(-obj.Width.Value/2+obj.FlangeThickness.Value,obj.WebThickness.Value-obj.Height.Value/2,0) + p7 = Vector(-obj.Width.Value/2+obj.FlangeThickness.Value,obj.Height.Value/2,0) + p8 = Vector(-obj.Width.Value/2,obj.Height.Value/2,0) + p = Part.makePolygon([p1,p2,p3,p4,p5,p6,p7,p8,p1]) + p = Part.Face(p) + p.reverse() + obj.Shape = p + obj.Placement = pl + + diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 270301ea0cc6..19dca6470bbf 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -20,9 +20,12 @@ #* USA * #* * #*************************************************************************** +#Modified 2016-01-03 JAndersM import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands from FreeCAD import Vector +import ArchProfile + if FreeCAD.GuiUp: import FreeCADGui from PySide import QtCore, QtGui @@ -36,256 +39,20 @@ def translate(ctxt,txt): __url__ = "http://www.freecadweb.org" # Make some strings picked by the translator -if FreeCAD.GuiUp: - QtCore.QT_TRANSLATE_NOOP("Arch","Wood") - QtCore.QT_TRANSLATE_NOOP("Arch","Steel") +#if FreeCAD.GuiUp: +# QtCore.QT_TRANSLATE_NOOP("Arch","Wood") +# QtCore.QT_TRANSLATE_NOOP("Arch","Steel") # Possible roles for structural elements Roles = ["Beam","Column","Slab","Wall","Curtain Wall","Roof","Foundation","Pile","Tendon"] -# Presets in the form: Class, Name, Width, Height, [Web thickness, Flange thickness] -Presets = [None, - - # wood sections - - ["Wood","1x2in",19,28], - ["Wood","1x3in",19,64], - ["Wood","1x4in",19,89], - ["Wood","1x6in",19,89], - ["Wood","1x8in",19,140], - ["Wood","1x10in",19,184], - ["Wood","1x12in",19,286], - - ["Wood","2x2in",38,38], - ["Wood","2x3in",38,64], - ["Wood","2x4in",38,89], - ["Wood","2x6in",38,140], - ["Wood","2x8in",38,184], - ["Wood","2x10in",38,235], - ["Wood","2x12in",38,286], - - ["Wood","4x4in",89,89], - ["Wood","4x6in",89,140], - ["Wood","6x6in",140,140], - ["Wood","8x8in",184,184], - - - # HEA - - ["Steel","HEA100",100,96,5,8], - ["Steel","HEA120",120,114,5,8], - ["Steel","HEA140",140,133,5.5,8.5], - ["Steel","HEA160",160,152,6,9], - ["Steel","HEA180",180,171,6,9.5], - ["Steel","HEA200",200,190,6.5,10], - ["Steel","HEA220",220,210,7,11], - ["Steel","HEA240",240,230,7.5,12], - ["Steel","HEA260",260,250,7.5,12.5], - ["Steel","HEA280",280,270,8,13], - ["Steel","HEA300",300,290,8.5,14], - ["Steel","HEA320",300,310,9,15.5], - ["Steel","HEA340",300,330,9.5,16.5], - ["Steel","HEA360",300,350,10,17.5], - ["Steel","HEA400",300,390,11,19], - ["Steel","HEA450",300,440,11.5,21], - ["Steel","HEA500",300,490,12,23], - ["Steel","HEA550",300,540,12.5,24], - ["Steel","HEA600",300,590,13,25], - ["Steel","HEA650",300,640,13.5,26], - ["Steel","HEA700",300,690,14.5,27], - ["Steel","HEA800",300,790,15,28], - ["Steel","HEA900",300,890,16,30], - ["Steel","HEA1000",300,990,16.5,31], - - # HEAA - - ["Steel","HEAA100",100,91,4.2,5.5], - ["Steel","HEAA120",120,109,4.2,5.5], - ["Steel","HEAA140",140,128,4.3,6], - ["Steel","HEAA160",160,148,4.5,7], - ["Steel","HEAA180",180,167,5,7.5], - ["Steel","HEAA200",200,186,5.5,8], - ["Steel","HEAA220",220,205,6,8.5], - ["Steel","HEAA240",240,224,6.5,9], - ["Steel","HEAA260",260,244,6.5,9.5], - ["Steel","HEAA280",280,264,7,10], - ["Steel","HEAA300",300,283,7.5,10.5], - ["Steel","HEAA320",300,301,8,11], - ["Steel","HEAA340",300,320,8.5,11.5], - ["Steel","HEAA360",300,339,9,12], - ["Steel","HEAA400",300,378,9.5,13], - ["Steel","HEAA450",300,425,10,13.5], - ["Steel","HEAA500",300,472,10.5,14], - ["Steel","HEAA550",300,522,11.5,15], - ["Steel","HEAA600",300,571,12,15.5], - ["Steel","HEAA650",300,620,12.5,16], - ["Steel","HEAA700",300,670,13,17], - ["Steel","HEAA800",300,770,14,18], - ["Steel","HEAA900",300,870,15,20], - ["Steel","HEAA1000",300,970,16,21], - - # HEB - - ["Steel","HEB100",100,100,6,10], - ["Steel","HEB120",120,120,6.5,11], - ["Steel","HEB140",140,140,7,12], - ["Steel","HEB160",160,160,8,13], - ["Steel","HEB180",180,180,8.5,14], - ["Steel","HEB200",200,200,9,15], - ["Steel","HEB220",220,220,9.5,16], - ["Steel","HEB240",240,240,10,17], - ["Steel","HEB260",260,260,10,17.5], - ["Steel","HEB280",280,280,10.5,18], - ["Steel","HEB300",300,300,11,19], - ["Steel","HEB320",300,320,11.5,20.5], - ["Steel","HEB340",300,340,12,21.5], - ["Steel","HEB360",300,360,12.5,22.5], - ["Steel","HEB400",300,400,13.5,24], - ["Steel","HEB450",300,450,14,26], - ["Steel","HEB500",300,500,14.5,28], - ["Steel","HEB550",300,550,15,29], - ["Steel","HEB600",300,600,15.5,30], - ["Steel","HEB650",300,650,16,31], - ["Steel","HEB700",300,700,17,32], - ["Steel","HEB800",300,800,17.5,33], - ["Steel","HEB900",300,900,18.5,35], - ["Steel","HEB1000",300,1000,19,36], - - # HEM - - ["Steel","HEM160",166,180,14,23], - ["Steel","HEM180",186,200,14.5,24], - ["Steel","HEM200",206,220,15,25], - ["Steel","HEM220",226,240,15.5,26], - ["Steel","HEM240",248,270,18,32], - ["Steel","HEM260",268,290,18,32.5], - ["Steel","HEM280",288,310,18.5,33], - ["Steel","HEM300",310,340,21,39], - ["Steel","HEM320",309,359,21,40], - ["Steel","HEM340",309,377,21,40], - ["Steel","HEM360",308,395,21,40], - ["Steel","HEM400",307,432,21,40], - ["Steel","HEM450",307,478,21,40], - ["Steel","HEM500",306,524,21,40], - ["Steel","HEM550",306,572,21,40], - ["Steel","HEM600",305,620,21,40], - ["Steel","HEM650",305,668,21,40], - ["Steel","HEM700",304,716,21,40], - ["Steel","HEM800",303,814,21,40], - ["Steel","HEM900",302,910,21,40], - ["Steel","HEM1000",302,1008,21,40], - - # INP - - ["Steel","INP80",42,80,3.9,5.9], - ["Steel","INP100",50,100,4.5,6.8], - ["Steel","INP120",58,120,5.1,7.7], - ["Steel","INP140",66,140,5.7,8.6], - ["Steel","INP160",74,160,6.3,9.5], - ["Steel","INP180",82,180,6.9,10.4], - ["Steel","INP200",90,200,7.5,11.3], - ["Steel","INP220",98,220,8.1,12.2], - ["Steel","INP240",106,240,8.7,13.1], - ["Steel","INP260",113,260,9.4,14.1], - ["Steel","INP280",119,280,10.1,15.2], - ["Steel","INP300",125,300,10.8,16.2], - ["Steel","INP320",131,320,11.5,17.3], - ["Steel","INP340",137,340,12.2,18.3], - ["Steel","INP360",143,360,13,19.5], - ["Steel","INP380",149,380,13.7,20.5], - ["Steel","INP400",155,400,14.4,21.6], - - # IPE - - ["Steel","IPE100",55,100,4.1,5.7], - ["Steel","IPE120",64,120,4.4,6.3], - ["Steel","IPE140",73,140,4.7,6.9], - ["Steel","IPE160",82,160,5,7.4], - ["Steel","IPE180",91,180,5.3,8], - ["Steel","IPE200",100,200,5.6,8.5], - ["Steel","IPE220",110,220,5.9,9.2], - ["Steel","IPE240",120,240,6.2,9.8], - ["Steel","IPE270",135,270,6.6,10.2], - ["Steel","IPE300",150,300,7.1,10.7], - ["Steel","IPE330",160,330,7.5,11.5], - ["Steel","IPE360",170,360,8,12.7], - ["Steel","IPE400",180,400,8.6,13.5], - ["Steel","IPE450",190,450,9.4,14.6], - ["Steel","IPE500",200,500,10.2,16], - ["Steel","IPE550",210,550,11.1,17.2], - ["Steel","IPE600",220,600,12,19], - - # IPEA - - ["Steel","IPEA100",55,98,3.6,4.7], - ["Steel","IPEA120",64,118,3.8,5.1], - ["Steel","IPEA140",73,138,3.8,5.6], - ["Steel","IPEA160",82,157,4,5.9], - ["Steel","IPEA180",91,177,4.3,6.5], - ["Steel","IPEA200",100,197,4.5,7], - ["Steel","IPEA220",110,217,5,7.7], - ["Steel","IPEA240",120,237,5.2,8.3], - ["Steel","IPEA270",135,267,5.5,8.7], - ["Steel","IPEA300",150,297,6.1,9.2], - ["Steel","IPEA330",160,327,6.5,10], - ["Steel","IPEA360",170,357.6,6.6,11.5], - ["Steel","IPEA400",180,397,7,12], - ["Steel","IPEA450",190,447,7.6,13.1], - ["Steel","IPEA500",200,497,8.4,14.5], - ["Steel","IPEA550",210,547,9,15.7], - ["Steel","IPEA600",220,597,9.8,17.5], - - # IPEO - - ["Steel","IPEO180",89,182,6.4,9.5], - ["Steel","IPEO200",102,202,6.2,9.5], - ["Steel","IPEO220",112,222,6.6,10.2], - ["Steel","IPEO240",122,242,7,10.8], - ["Steel","IPEO270",136,274,7.5,12.2], - ["Steel","IPEO300",152,304,8,12.7], - ["Steel","IPEO330",162,334,8.5,13.5], - ["Steel","IPEO360",172,364,9.2,14.7], - ["Steel","IPEO400",182,404,9.7,15.5], - ["Steel","IPEO450",192,456,11,17.6], - ["Steel","IPEO500",202,506,12,19], - ["Steel","IPEO550",212,556,12.7,20.2], - ["Steel","IPEO600",224,610,15,24], - - # IPER - - ["Steel","IPER140",72,142,5.3,7.8], - ["Steel","IPER160",81,162,5.6,8.5], - ["Steel","IPER180",92,183,6,9], - ["Steel","IPER200",98,204,6.6,10.5], - ["Steel","IPER220",108,225,6.7,11.8], - ["Steel","IPER240",118,245,7.5,12.3], - ["Steel","IPER270",133,276,7.1,13.1], - ["Steel","IPER300",147,306,8.5,13.7], - ["Steel","IPER330",158,336,9.2,14.5], - ["Steel","IPER360",168,366,9.9,16], - ["Steel","IPER400",178,407,10.6,17], - ["Steel","IPER450",188,458,11.3,18.6], - ["Steel","IPER500",198,508,12.6,20], - ["Steel","IPER550",210,560,14,22.2], - ["Steel","IPER600",218,608,14,23], - - # IPEV - - ["Steel","IPEV400",182,408,10.6,17.5], - ["Steel","IPEV450",194,460,12.4,19.6], - ["Steel","IPEV500",204,514,14.2,23], - ["Steel","IPEV550",216,566,17.1,25.2], - ["Steel","IPEV600",228,618,18,28], - ["Steel","IPE750x137",263,753,11.5,17], - ["Steel","IPE750x147",265,753,13.2,17], - ["Steel","IPE750x161",266,758,13.8,19.3], - ["Steel","IPE750x173",267,762,14.4,21.6], - ["Steel","IPE750x185",267,766,14.9,23.6], - ["Steel","IPE750x196",268,770,15.6,25.4], - ["Steel","IPE750x210",268,775,16,28], - ["Steel","IPE750x222",269,778,17,29.5] - - ] +#Reads preset profiles and categorizes them +Categories=[None] +Presets=ArchProfile.readPresets() +for pre in Presets[1:]: + if pre[1] not in Categories: + Categories.append(pre[1]) + def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structure"): '''makeStructure([obj],[length],[width],[heigth],[swap]): creates a @@ -352,23 +119,6 @@ def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"): else: return result -def makeProfile(W=46,H=80,tw=3.8,tf=5.2,name="Profile"): - '''makeProfile(W,H,tw,tf): returns a shape with one face describing - the profile of a steel beam (IPE, IPN, HE, etc...) based on the following - dimensions: W = total width, H = total height, tw = web thickness - tw = flange thickness (see http://en.wikipedia.org/wiki/I-beam for - reference)''' - obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",name) - obj.Label = translate("Arch",name) - _Profile(obj) - obj.Width = W - obj.Height = H - obj.WebThickness = tw - obj.FlangeThickness = tf - if FreeCAD.GuiUp: - Draft._ViewProviderDraft(obj.ViewObject) - return obj - class _CommandStructure: "the Arch Structure command definition" def GetResources(self): @@ -385,7 +135,7 @@ def Activated(self): self.Length = p.GetFloat("StructureLength",100) self.Width = p.GetFloat("StructureWidth",100) self.Height = p.GetFloat("StructureHeight",1000) - self.Profile = 0 + self.Profile = None self.continueCmd = False self.DECIMALS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2) import DraftGui @@ -432,18 +182,17 @@ def getPoint(self,point=None,obj=None): return FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structure"))) FreeCADGui.addModule("Arch") - if self.Profile: - pr = Presets[self.Profile] - FreeCADGui.doCommand('p = Arch.makeProfile('+str(pr[2])+','+str(pr[3])+','+str(pr[4])+','+str(pr[5])+')') - if self.Length == pr[2]: + if self.Profile is not None: + FreeCADGui.doCommand('p = Arch.makeProfile('+str(self.Profile)+')') + if self.Length == self.Profile[4]: # vertical FreeCADGui.doCommand('s = Arch.makeStructure(p,height='+str(self.Height)+')') else: # horizontal FreeCADGui.doCommand('s = Arch.makeStructure(p,height='+str(self.Length)+')') FreeCADGui.doCommand('s.Placement.Rotation = FreeCAD.Rotation(-0.5,0.5,-0.5,0.5)') - FreeCADGui.doCommand('s.Profile = "'+pr[1]+'"') - else: + FreeCADGui.doCommand('s.Profile = "'+self.Profile[2]+'"') + else : FreeCADGui.doCommand('s = Arch.makeStructure(length='+str(self.Length)+',width='+str(self.Width)+',height='+str(self.Height)+')') FreeCADGui.doCommand('s.Placement.Base = '+DraftVecUtils.toString(point)) FreeCADGui.doCommand('s.Placement.Rotation=FreeCAD.DraftWorkingPlane.getRotation().Rotation') @@ -452,6 +201,12 @@ def getPoint(self,point=None,obj=None): if self.continueCmd: self.Activated() + def _createItemlist(self, baselist) : + ilist=[] + for p in baselist: + ilist.append(p[2]+" ("+str(p[4])+"x"+str(p[5])+"mm)") + return ilist + def taskbox(self): "sets up a taskbox widget" w = QtGui.QWidget() @@ -459,40 +214,46 @@ def taskbox(self): w.setWindowTitle(translate("Arch","Structure options").decode("utf8")) grid = QtGui.QGridLayout(w) + # categories box + labelc = QtGui.QLabel(translate("Arch","Category").decode("utf8")) + valuec = QtGui.QComboBox() + valuec.addItems([" "]+Categories[1:]) + grid.addWidget(labelc,0,0,1,1) + grid.addWidget(valuec,0,1,1,1) + # presets box labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8")) - valuep = QtGui.QComboBox() - fpresets = [" "] - for p in Presets[1:]: - fpresets.append(str(translate("Arch",p[0]))+" "+p[1]+" ("+str(p[2])+"x"+str(p[3])+"mm)") - valuep.addItems(fpresets) - grid.addWidget(labelp,0,0,1,1) - grid.addWidget(valuep,0,1,1,1) + self.vPresets = QtGui.QComboBox() + self.pSelect=Presets[1:] + fpresets = [" "]+self._createItemlist(self.pSelect) + self.vPresets.addItems(fpresets) + grid.addWidget(labelp,1,0,1,1) + grid.addWidget(self.vPresets,1,1,1,1) # length label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8")) self.vLength = ui.createWidget("Gui::InputField") self.vLength.setText(self.FORMAT % self.Length) - grid.addWidget(label1,1,0,1,1) - grid.addWidget(self.vLength,1,1,1,1) + grid.addWidget(label1,2,0,1,1) + grid.addWidget(self.vLength,2,1,1,1) # width label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8")) self.vWidth = ui.createWidget("Gui::InputField") self.vWidth.setText(self.FORMAT % self.Width) - grid.addWidget(label2,2,0,1,1) - grid.addWidget(self.vWidth,2,1,1,1) + grid.addWidget(label2,3,0,1,1) + grid.addWidget(self.vWidth,3,1,1,1) # height label3 = QtGui.QLabel(translate("Arch","Height").decode("utf8")) self.vHeight = ui.createWidget("Gui::InputField") self.vHeight.setText(self.FORMAT % self.Height) - grid.addWidget(label3,3,0,1,1) - grid.addWidget(self.vHeight,3,1,1,1) + grid.addWidget(label3,4,0,1,1) + grid.addWidget(self.vHeight,4,1,1,1) # horizontal button value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8")) - grid.addWidget(value5,4,0,1,2) + grid.addWidget(value5,5,0,1,2) # continue button label4 = QtGui.QLabel(translate("Arch","Con&tinue").decode("utf8")) @@ -503,10 +264,11 @@ def taskbox(self): if hasattr(FreeCADGui,"draftToolBar"): value4.setChecked(FreeCADGui.draftToolBar.continueMode) self.continueCmd = FreeCADGui.draftToolBar.continueMode - grid.addWidget(label4,5,0,1,1) - grid.addWidget(value4,5,1,1,1) + grid.addWidget(label4,6,0,1,1) + grid.addWidget(value4,6,1,1,1) - QtCore.QObject.connect(valuep,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset) + QtCore.QObject.connect(valuec,QtCore.SIGNAL("currentIndexChanged(int)"),self.setCategory) + QtCore.QObject.connect(self.vPresets,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset) QtCore.QObject.connect(self.vLength,QtCore.SIGNAL("valueChanged(double)"),self.setLength) QtCore.QObject.connect(self.vWidth,QtCore.SIGNAL("valueChanged(double)"),self.setWidth) QtCore.QObject.connect(self.vHeight,QtCore.SIGNAL("valueChanged(double)"),self.setHeight) @@ -540,14 +302,25 @@ def setContinue(self,i): if hasattr(FreeCADGui,"draftToolBar"): FreeCADGui.draftToolBar.continueMode = bool(i) + def setCategory(self,i): + self.vPresets.clear() + if i > 0: + self.pSelect= [p for p in Presets[1:] if p[1] == Categories[i]] + fpresets = [" "]+self._createItemlist(self.pSelect) + self.vPresets.addItems(fpresets) + else: + self.pSelect=Presets[1:] + fpresets = [" "]+self._createItemlist(self.pSelect) + self.vPresets.addItems(fpresets) + def setPreset(self,i): if i > 0: - self.vLength.setText(self.FORMAT % float(Presets[i][2])) - self.vWidth.setText(self.FORMAT % float(Presets[i][3])) - if len(Presets[i]) == 6: - self.Profile = i + p=self.pSelect[i-1][0] + self.vLength.setText(self.FORMAT % float(Presets[p][4])) + self.vWidth.setText(self.FORMAT % float(Presets[p][5])) + self.Profile = Presets[p] else: - self.Profile = 0 + self.Profile = None def rotate(self): l = self.Length @@ -604,8 +377,12 @@ def execute(self,obj): if not height: return if obj.Normal == Vector(0,0,0): - p = FreeCAD.Placement(obj.Base.Placement) - normal = p.Rotation.multVec(normal) + if len(obj.Base.Shape.Faces) > 0 : + normal=obj.Base.Shape.Faces[0].normalAt(.5,.5) + else: + return + #p = FreeCAD.Placement(obj.Base.Placement) + #normal = p.Rotation.multVec(normal) else: normal = Vector(obj.Normal) normal = normal.multiply(height) @@ -738,35 +515,6 @@ def onChanged(self,vobj,prop): self.pointstyle.pointSize = vobj.NodeSize ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop) -class _Profile(Draft._DraftObject): - "A parametric beam profile object" - - def __init__(self,obj): - obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = 10 - obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = 30 - obj.addProperty("App::PropertyLength","WebThickness","Draft","Thickness of the webs").WebThickness = 3 - obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = 2 - Draft._DraftObject.__init__(self,obj,"Profile") - - def execute(self,obj): - import Part - pl = obj.Placement - p1 = Vector(-obj.Width.Value/2,-obj.Height.Value/2,0) - p2 = Vector(obj.Width.Value/2,-obj.Height.Value/2,0) - p3 = Vector(obj.Width.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) - p4 = Vector(obj.WebThickness.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) - p5 = Vector(obj.WebThickness.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) - p6 = Vector(obj.Width.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) - p7 = Vector(obj.Width.Value/2,obj.Height.Value/2,0) - p8 = Vector(-obj.Width.Value/2,obj.Height.Value/2,0) - p9 = Vector(-obj.Width.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) - p10 = Vector(-obj.WebThickness.Value/2,obj.Height.Value/2-obj.FlangeThickness.Value,0) - p11 = Vector(-obj.WebThickness.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) - p12 = Vector(-obj.Width.Value/2,(-obj.Height.Value/2)+obj.FlangeThickness.Value,0) - p = Part.makePolygon([p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p1]) - p = Part.Face(p) - obj.Shape = p - obj.Placement = pl class _StructuralSystem(ArchComponent.Component): "The Structural System object" @@ -774,7 +522,7 @@ def __init__(self,obj): ArchComponent.Component.__init__(self,obj) obj.addProperty("App::PropertyLinkList","Axes","Arch",translate("Arch","Axes systems this structure is built on")) obj.addProperty("App::PropertyIntegerList","Exclude","Arch",translate("Arch","The element numbers to exclude when this structure is based on axes")) - obj.addProperty("App::PropertyBool","Align","Arch","If true the element are aligned with axes").Align = False + obj.addProperty("App::PropertyBool","Align","Arch","If true the element are aligned with axes").Align = False self.Type = "StructuralSystem" def execute(self,obj): diff --git a/src/Mod/Arch/CMakeLists.txt b/src/Mod/Arch/CMakeLists.txt index d01acf24b80a..cc3fd867d490 100644 --- a/src/Mod/Arch/CMakeLists.txt +++ b/src/Mod/Arch/CMakeLists.txt @@ -32,6 +32,7 @@ SET(Arch_SRCS ArchServer.py ArchMaterial.py ArchSchedule.py + ArchProfile.py ) SOURCE_GROUP("" FILES ${Arch_SRCS}) @@ -52,3 +53,12 @@ INSTALL( ${Arch_QRC_SRCS} DESTINATION Mod/Arch ) + +INSTALL( + DIRECTORY + Presets + DESTINATION + ${CMAKE_INSTALL_DATADIR}/Mod/Arch + FILES_MATCHING + PATTERN "*.csv*" +) diff --git a/src/Mod/Arch/Presets/profiles.csv b/src/Mod/Arch/Presets/profiles.csv new file mode 100644 index 000000000000..01495b3653b0 --- /dev/null +++ b/src/Mod/Arch/Presets/profiles.csv @@ -0,0 +1,250 @@ +#Data structure: +#Category, Name, Profile class, geometric data... +#Possible profile classes are: +#C=Circular tube +#H= H- or I-profile +#R= Rectangular +#RH= Rectangular hollow +#U= U-profile +########################################### +#Circular tube +#Category,Name,H,Outside diameter,Thickness +CTH,CTH423,C,42.4,3.2 +#H- or I-profile +#Category,Name,H,width,height,web thickness,flange thickness +HEA,HEA100,H,100,96,5,8 +HEA,HEA120,H,120,114,5,8 +HEA,HEA140,H,140,133,5.5,8.5 +HEA,HEA160,H,160,152,6,9 +HEA,HEA180,H,180,171,6,9.5 +HEA,HEA200,H,200,190,6.5,10 +HEA,HEA220,H,220,210,7,11 +HEA,HEA240,H,240,230,7.5,12 +HEA,HEA260,H,260,250,7.5,12.5 +HEA,HEA280,H,280,270,8,13 +HEA,HEA300,H,300,290,8.5,14 +HEA,HEA320,H,300,310,9,15.5 +HEA,HEA340,H,300,330,9.5,16.5 +HEA,HEA360,H,300,350,10,17.5 +HEA,HEA400,H,300,390,11,19 +HEA,HEA450,H,300,440,11.5,21 +HEA,HEA500,H,300,490,12,23 +HEA,HEA550,H,300,540,12.5,24 +HEA,HEA600,H,300,590,13,25 +HEA,HEA650,H,300,640,13.5,26 +HEA,HEA700,H,300,690,14.5,27 +HEA,HEA800,H,300,790,15,28 +HEA,HEA900,H,300,890,16,30 +HEA,HEA1000,H,300,990,16.5,31 +HEA,HEAA100,H,100,91,4.2,5.5 +HEA,HEAA120,H,120,109,4.2,5.5 +HEA,HEAA140,H,140,128,4.3,6 +HEA,HEAA160,H,160,148,4.5,7 +HEA,HEAA180,H,180,167,5,7.5 +HEA,HEAA200,H,200,186,5.5,8 +HEA,HEAA220,H,220,205,6,8.5 +HEA,HEAA240,H,240,224,6.5,9 +HEA,HEAA260,H,260,244,6.5,9.5 +HEA,HEAA280,H,280,264,7,10 +HEA,HEAA300,H,300,283,7.5,10.5 +HEA,HEAA320,H,300,301,8,11 +HEA,HEAA340,H,300,320,8.5,11.5 +HEA,HEAA360,H,300,339,9,12 +HEA,HEAA400,H,300,378,9.5,13 +HEA,HEAA450,H,300,425,10,13.5 +HEA,HEAA500,H,300,472,10.5,14 +HEA,HEAA550,H,300,522,11.5,15 +HEA,HEAA600,H,300,571,12,15.5 +HEA,HEAA650,H,300,620,12.5,16 +HEA,HEAA700,H,300,670,13,17 +HEA,HEAA800,H,300,770,14,18 +HEA,HEAA900,H,300,870,15,20 +HEA,HEAA1000,H,300,970,16,21 +HEB,HEB100,H,100,100,6,10 +HEB,HEB120,H,120,120,6.5,11 +HEB,HEB140,H,140,140,7,12 +HEB,HEB160,H,160,160,8,13 +HEB,HEB180,H,180,180,8.5,14 +HEB,HEB200,H,200,200,9,15 +HEB,HEB220,H,220,220,9.5,16 +HEB,HEB240,H,240,240,10,17 +HEB,HEB260,H,260,260,10,17.5 +HEB,HEB280,H,280,280,10.5,18 +HEB,HEB300,H,300,300,11,19 +HEB,HEB320,H,300,320,11.5,20.5 +HEB,HEB340,H,300,340,12,21.5 +HEB,HEB360,H,300,360,12.5,22.5 +HEB,HEB400,H,300,400,13.5,24 +HEB,HEB450,H,300,450,14,26 +HEB,HEB500,H,300,500,14.5,28 +HEB,HEB550,H,300,550,15,29 +HEB,HEB600,H,300,600,15.5,30 +HEB,HEB650,H,300,650,16,31 +HEB,HEB700,H,300,700,17,32 +HEB,HEB800,H,300,800,17.5,33 +HEB,HEB900,H,300,900,18.5,35 +HEB,HEB1000,H,300,1000,19,36 +HEM,HEM160,H,166,180,14,23 +HEM,HEM180,H,186,200,14.5,24 +HEM,HEM200,H,206,220,15,25 +HEM,HEM220,H,226,240,15.5,26 +HEM,HEM240,H,248,270,18,32 +HEM,HEM260,H,268,290,18,32.5 +HEM,HEM280,H,288,310,18.5,33 +HEM,HEM300,H,310,340,21,39 +HEM,HEM320,H,309,359,21,40 +HEM,HEM340,H,309,377,21,40 +HEM,HEM360,H,308,395,21,40 +HEM,HEM400,H,307,432,21,40 +HEM,HEM450,H,307,478,21,40 +HEM,HEM500,H,306,524,21,40 +HEM,HEM550,H,306,572,21,40 +HEM,HEM600,H,305,620,21,40 +HEM,HEM650,H,305,668,21,40 +HEM,HEM700,H,304,716,21,40 +HEM,HEM800,H,303,814,21,40 +HEM,HEM900,H,302,910,21,40 +HEM,HEM1000,H,302,1008,21,40 +INP,INP80,H,42,80,3.9,5.9 +INP,INP100,H,50,100,4.5,6.8 +INP,INP120,H,58,120,5.1,7.7 +INP,INP140,H,66,140,5.7,8.6 +INP,INP160,H,74,160,6.3,9.5 +INP,INP180,H,82,180,6.9,10.4 +INP,INP200,H,90,200,7.5,11.3 +INP,INP220,H,98,220,8.1,12.2 +INP,INP240,H,106,240,8.7,13.1 +INP,INP260,H,113,260,9.4,14.1 +INP,INP280,H,119,280,10.1,15.2 +INP,INP300,H,125,300,10.8,16.2 +INP,INP320,H,131,320,11.5,17.3 +INP,INP340,H,137,340,12.2,18.3 +INP,INP360,H,143,360,13,19.5 +INP,INP380,H,149,380,13.7,20.5 +INP,INP400,H,155,400,14.4,21.6 +IPE,IPE100,H,55,100,4.1,5.7 +IPE,IPE120,H,64,120,4.4,6.3 +IPE,IPE140,H,73,140,4.7,6.9 +IPE,IPE160,H,82,160,5,7.4 +IPE,IPE180,H,91,180,5.3,8 +IPE,IPE200,H,100,200,5.6,8.5 +IPE,IPE220,H,110,220,5.9,9.2 +IPE,IPE240,H,120,240,6.2,9.8 +IPE,IPE270,H,135,270,6.6,10.2 +IPE,IPE300,H,150,300,7.1,10.7 +IPE,IPE330,H,160,330,7.5,11.5 +IPE,IPE360,H,170,360,8,12.7 +IPE,IPE400,H,180,400,8.6,13.5 +IPE,IPE450,H,190,450,9.4,14.6 +IPE,IPE500,H,200,500,10.2,16 +IPE,IPE550,H,210,550,11.1,17.2 +IPE,IPE600,H,220,600,12,19 +IPE,IPEA100,H,55,98,3.6,4.7 +IPE,IPEA120,H,64,118,3.8,5.1 +IPE,IPEA140,H,73,138,3.8,5.6 +IPE,IPEA160,H,82,157,4,5.9 +IPE,IPEA180,H,91,177,4.3,6.5 +IPE,IPEA200,H,100,197,4.5,7 +IPE,IPEA220,H,110,217,5,7.7 +IPE,IPEA240,H,120,237,5.2,8.3 +IPE,IPEA270,H,135,267,5.5,8.7 +IPE,IPEA300,H,150,297,6.1,9.2 +IPE,IPEA330,H,160,327,6.5,10 +IPE,IPEA360,H,170,357.6,6.6,11.5 +IPE,IPEA400,H,180,397,7,12 +IPE,IPEA450,H,190,447,7.6,13.1 +IPE,IPEA500,H,200,497,8.4,14.5 +IPE,IPEA550,H,210,547,9,15.7 +IPE,IPEA600,H,220,597,9.8,17.5 +IPE,IPEO180,H,89,182,6.4,9.5 +IPE,IPEO200,H,102,202,6.2,9.5 +IPE,IPEO220,H,112,222,6.6,10.2 +IPE,IPEO240,H,122,242,7,10.8 +IPE,IPEO270,H,136,274,7.5,12.2 +IPE,IPEO300,H,152,304,8,12.7 +IPE,IPEO330,H,162,334,8.5,13.5 +IPE,IPEO360,H,172,364,9.2,14.7 +IPE,IPEO400,H,182,404,9.7,15.5 +IPE,IPEO450,H,192,456,11,17.6 +IPE,IPEO500,H,202,506,12,19 +IPE,IPEO550,H,212,556,12.7,20.2 +IPE,IPEO600,H,224,610,15,24 +IPE,IPER140,H,72,142,5.3,7.8 +IPE,IPER160,H,81,162,5.6,8.5 +IPE,IPER180,H,92,183,6,9 +IPE,IPER200,H,98,204,6.6,10.5 +IPE,IPER220,H,108,225,6.7,11.8 +IPE,IPER240,H,118,245,7.5,12.3 +IPE,IPER270,H,133,276,7.1,13.1 +IPE,IPER300,H,147,306,8.5,13.7 +IPE,IPER330,H,158,336,9.2,14.5 +IPE,IPER360,H,168,366,9.9,16 +IPE,IPER400,H,178,407,10.6,17 +IPE,IPER450,H,188,458,11.3,18.6 +IPE,IPER500,H,198,508,12.6,20 +IPE,IPER550,H,210,560,14,22.2 +IPE,IPER600,H,218,608,14,23 +IPE,IPEV400,H,182,408,10.6,17.5 +IPE,IPEV450,H,194,460,12.4,19.6 +IPE,IPEV500,H,204,514,14.2,23 +IPE,IPEV550,H,216,566,17.1,25.2 +IPE,IPEV600,H,228,618,18,28 +IPE,IPE750x137,H,263,753,11.5,17 +IPE,IPE750x147,H,265,753,13.2,17 +IPE,IPE750x161,H,266,758,13.8,19.3 +IPE,IPE750x173,H,267,762,14.4,21.6 +IPE,IPE750x185,H,267,766,14.9,23.6 +IPE,IPE750x196,H,268,770,15.6,25.4 +IPE,IPE750x210,H,268,775,16,28 +IPE,IPE750x222,H,269,778,17,29.5 +#Rectangular +#Category,Name,R,width,height +REC,1x2in,R,19,28 +REC,1x3in,R,19,64 +REC,1x4in,R,19,89 +REC,1x6in,R,19,89 +REC,1x8in,R,19,140 +REC,1x10in,R,19,184 +REC,1x12in,R,19,286 +REC,2x2in,R,38,38 +REC,2x3in,R,38,64 +REC,2x4in,R,38,89 +REC,2x6in,R,38,140 +REC,2x8in,R,38,184 +REC,2x10in,R,38,235 +REC,2x12in,R,38,286 +REC,4x4in,R,89,89 +REC,4x6in,R,89,140 +REC,6x6in,R,140,140 +REC,8x8in,R,184,184 +#RH-profile +#Category,Name,RH,width,height,thickness +RHS,RHS120x90x3,RH,120,80,3 +RHS,RHS120x80x5,RH,120,80,5 +RHS,RHS120x80x8,RH,120,80,8 +RHS,RHS120x100x4,RH,120,100,4 +RHS,RHS120x100x5,RH,120,100,5 +RHS,RHS140x80x5,RH,140,80,5 +RHS,RHS150x100x5,RH,150,100,5 +RHS,RHS150x100x10,RH,150,100,10 +RHS,RHS160x80x5,RH,160,80,5 +RHS,RHS180x100x6,RH,180,100,6 +RHS,RHS180x120x6,RH,180,120,6 +RHS,RHS200x80x6,RH,200,80,6 +RHS,RHS200x100x10,RH,200,100,10 +#U-profile +#Category,Name,U,width,height,web thickness,flange thickness +UPE,UPE80,U,80,50,4,7 +UPE,UPE100,U,100,55,4.5,7.5 +UPE,UPE120,U,120,60,5,8 +UPE,UPE140,U,140,65,5,9 +UPE,UPE160,U,160,70,5.5,9.5 +UPE,UPE180,U,180,75,5.5,10.5 +UPE,UPE200,U,200,80,6,11 +UPE,UPE220,U,220,85,6.5,12 +UPE,UPE240,U,240,90,7,12.5 +UPE,UPE270,U,270,95,7.5,13.5 +UPE,UPE300,U,300,100,9.5,15 +UPE,UPE330,U,330,105,11,16 +UPE,UPE360,U,360,110,12,17 +UPE,UPE400,U,400,115,13.5,18