diff --git a/src/Mod/Arch/ArchAxis.py b/src/Mod/Arch/ArchAxis.py index d7a337407..cd2490251 100644 --- a/src/Mod/Arch/ArchAxis.py +++ b/src/Mod/Arch/ArchAxis.py @@ -117,7 +117,7 @@ class _ViewProviderAxis: "A View Provider for the Axis object" def __init__(self,vobj): - vobj.addProperty("App::PropertyLength","BubbleSize","Arch", translate("Arch","The size of the axis bubbles")) + vobj.addProperty("App::PropertyFloat","BubbleSize","Arch", translate("Arch","The size of the axis bubbles")) vobj.addProperty("App::PropertyEnumeration","NumberingStyle","Arch", translate("Arch","The numbering style")) vobj.addProperty("App::PropertyEnumeration","DrawStyle","Base","") vobj.addProperty("App::PropertyFloat","LineWidth","Base","") diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 3078dcf53..d2f10bcc8 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -282,12 +282,9 @@ class ComponentTaskPanel: class Component: "The default Arch Component object" def __init__(self,obj): - obj.addProperty("App::PropertyLink","Base","Arch", - "The base object this component is built upon") - obj.addProperty("App::PropertyLinkList","Additions","Arch", - "Other shapes that are appended to this object") - obj.addProperty("App::PropertyLinkList","Subtractions","Arch", - "Other shapes that are subtracted from this object") + obj.addProperty("App::PropertyLink","Base","Arch","The base object this component is built upon") + obj.addProperty("App::PropertyLinkList","Additions","Arch","Other shapes that are appended to this object") + obj.addProperty("App::PropertyLinkList","Subtractions","Arch","Other shapes that are subtracted from this object") obj.Proxy = self self.Type = "Component" self.Subvolume = None diff --git a/src/Mod/Arch/ArchFloor.py b/src/Mod/Arch/ArchFloor.py index 2d6ee2b63..0f4a482c5 100644 --- a/src/Mod/Arch/ArchFloor.py +++ b/src/Mod/Arch/ArchFloor.py @@ -82,10 +82,8 @@ class _CommandFloor: class _Floor: "The Floor object" def __init__(self,obj): - obj.addProperty("App::PropertyLength","Height","Arch", - translate("Arch","The height of this floor")) - obj.addProperty("App::PropertyPlacement","Placement","Arch", - translate("Arch","The placement of this group")) + obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The height of this floor")) + obj.addProperty("App::PropertyPlacement","Placement","Arch",translate("Arch","The placement of this group")) self.Type = "Floor" obj.Proxy = self self.Object = obj @@ -112,10 +110,11 @@ class _Floor: o.Placement.move(delta) self.OldPlacement = pl # adjust childrens heights - for o in obj.Group: - if Draft.getType(o) in ["Wall","Structure"]: - if not o.Height: - o.Proxy.execute(o) + if obj.Height.Value: + for o in obj.Group: + if Draft.getType(o) in ["Wall","Structure"]: + if not o.Height.Value: + o.Proxy.execute(o) def addObject(self,child): if hasattr(self,"Object"): diff --git a/src/Mod/Arch/ArchFrame.py b/src/Mod/Arch/ArchFrame.py index 5dcfdd977..46d21a6b6 100644 --- a/src/Mod/Arch/ArchFrame.py +++ b/src/Mod/Arch/ArchFrame.py @@ -45,6 +45,7 @@ def makeFrame(base,profile,name=translate("Arch","Frame")): obj.Base = base obj.Profile = profile #profile.ViewObject.hide() + return obj class _CommandFrame: "the Arch Frame command definition" diff --git a/src/Mod/Arch/ArchRebar.py b/src/Mod/Arch/ArchRebar.py index 1417150d6..f48606da5 100644 --- a/src/Mod/Arch/ArchRebar.py +++ b/src/Mod/Arch/ArchRebar.py @@ -164,7 +164,7 @@ class _Rebar(ArchComponent.Component): return if not obj.Base.Shape.Wires: return - if not obj.Diameter: + if not obj.Diameter.Value: return if not obj.Amount: return @@ -173,7 +173,7 @@ class _Rebar(ArchComponent.Component): if hasattr(obj,"Rounding"): print obj.Rounding if obj.Rounding: - radius = obj.Rounding * obj.Diameter + radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire,radius) bpoint, bvec = self.getBaseAndAxis(obj) @@ -188,13 +188,13 @@ class _Rebar(ArchComponent.Component): size = axis.Length #print axis #print size - if (obj.OffsetStart+obj.OffsetEnd) > size: + if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: return # all tests ok! pl = obj.Placement import Part - circle = Part.makeCircle(obj.Diameter/2,bpoint,bvec) + circle = Part.makeCircle(obj.Diameter.Value/2,bpoint,bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle],True,False,2) @@ -210,11 +210,11 @@ class _Rebar(ArchComponent.Component): if hasattr(obj,"Spacing"): obj.Spacing = 0 else: - if obj.OffsetStart: - baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart) + if obj.OffsetStart.Value: + baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) else: baseoffset = None - interval = size - (obj.OffsetStart + obj.OffsetEnd) + interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) vinterval = DraftVecUtils.scaleTo(axis,interval) for i in range(obj.Amount): diff --git a/src/Mod/Arch/ArchRoof.py b/src/Mod/Arch/ArchRoof.py index 7593398ba..71184a3dd 100644 --- a/src/Mod/Arch/ArchRoof.py +++ b/src/Mod/Arch/ArchRoof.py @@ -93,10 +93,8 @@ class _Roof(ArchComponent.Component): def __init__(self,obj): ArchComponent.Component.__init__(self,obj) - obj.addProperty("App::PropertyAngle","Angle","Base", - translate("Arch","The angle of this roof")) - obj.addProperty("App::PropertyInteger","Face","Base", - translate("Arch","The face number of the base object used to build this roof")) + obj.addProperty("App::PropertyAngle","Angle","Base",translate("Arch","The angle of this roof")) + obj.addProperty("App::PropertyInteger","Face","Base",translate("Arch","The face number of the base object used to build this roof")) self.Type = "Roof" def execute(self,obj): diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index b11671220..72a9f567e 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -94,16 +94,14 @@ class _SectionPlane: "A section plane object" def __init__(self,obj): obj.Proxy = self - obj.addProperty("App::PropertyPlacement","Placement","Base", - translate("Arch","The placement of this object")) + obj.addProperty("App::PropertyPlacement","Placement","Base",translate("Arch","The placement of this object")) obj.addProperty("Part::PropertyPartShape","Shape","Base","") - obj.addProperty("App::PropertyLinkList","Objects","Arch", - translate("Arch","The objects that must be considered by this section plane. Empty means all document")) + obj.addProperty("App::PropertyLinkList","Objects","Arch",translate("Arch","The objects that must be considered by this section plane. Empty means all document")) self.Type = "SectionPlane" def execute(self,obj): import Part - l = obj.ViewObject.DisplaySize + l = obj.ViewObject.DisplaySize.Value p = Part.makePlane(l,l,Vector(l/2,-l/2,0),Vector(0,0,-1)) p.Placement = obj.Placement obj.Shape = p @@ -124,8 +122,7 @@ class _SectionPlane: class _ViewProviderSectionPlane(ArchComponent.ViewProviderComponent): "A View Provider for Section Planes" def __init__(self,vobj): - vobj.addProperty("App::PropertyLength","DisplaySize","Arch", - translate("Arch","The display size of this section plane")) + vobj.addProperty("App::PropertyLength","DisplaySize","Arch",translate("Arch","The display size of this section plane")) vobj.addProperty("App::PropertyPercent","Transparency","Base","") vobj.addProperty("App::PropertyFloat","LineWidth","Base","") vobj.addProperty("App::PropertyColor","LineColor","Base","") @@ -192,7 +189,7 @@ class _ViewProviderSectionPlane(ArchComponent.ViewProviderComponent): if hasattr(vobj,"Transparency"): self.mat2.transparency.setValue(vobj.Transparency/100.0) elif prop == "DisplaySize": - hd = vobj.DisplaySize/2 + hd = vobj.DisplaySize.Value/2 verts = [] fverts = [] for v in [[-hd,-hd],[hd,-hd],[hd,hd],[-hd,hd]]: diff --git a/src/Mod/Arch/ArchSite.py b/src/Mod/Arch/ArchSite.py index f1a6067ea..6ed49f922 100644 --- a/src/Mod/Arch/ArchSite.py +++ b/src/Mod/Arch/ArchSite.py @@ -85,14 +85,10 @@ class _Site(ArchFloor._Floor): "The Site object" def __init__(self,obj): ArchFloor._Floor.__init__(self,obj) - obj.addProperty("App::PropertyLink","Terrain","Arch", - translate("Arch","The terrain of this site")) - obj.addProperty("App::PropertyString","Address","Arch", - translate("Arch","The address of this site")) - obj.addProperty("App::PropertyString","Coordinates","Arch", - translate("Arch","The geographic coordinates of this site")) - obj.addProperty("App::PropertyString","Url","Arch", - translate("Arch","An url that shows this site in a mapping website")) + obj.addProperty("App::PropertyLink","Terrain","Arch",translate("Arch","The terrain of this site")) + obj.addProperty("App::PropertyString","Address","Arch",translate("Arch","The address of this site")) + obj.addProperty("App::PropertyString","Coordinates","Arch",translate("Arch","The geographic coordinates of this site")) + obj.addProperty("App::PropertyString","Url","Arch",translate("Arch","An url that shows this site in a mapping website")) self.Type = "Site" obj.setEditorMode('Height',2) diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py index 2f8e1d16f..0151a89ab 100644 --- a/src/Mod/Arch/ArchSpace.py +++ b/src/Mod/Arch/ArchSpace.py @@ -100,10 +100,8 @@ class _Space(ArchComponent.Component): "A space object" def __init__(self,obj): obj.Proxy = self - obj.addProperty("App::PropertyLink","Base","Arch", - translate("Arch","A base shape defining this space")) - obj.addProperty("App::PropertyLinkSubList","Boundaries","Arch", - translate("Arch","The objects that make the boundaries of this space object")) + obj.addProperty("App::PropertyLink","Base","Arch",translate("Arch","A base shape defining this space")) + obj.addProperty("App::PropertyLinkSubList","Boundaries","Arch",translate("Arch","The objects that make the boundaries of this space object")) self.Type = "Space" def execute(self,obj): @@ -216,10 +214,8 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent): vobj.LineWidth = 1 vobj.LineColor = (1.0,0.0,0.0,1.0) vobj.DrawStyle = "Dotted" - vobj.addProperty("App::PropertyString","Override","Base", - "Text override. Use $area to insert the area") - vobj.addProperty("App::PropertyColor","TextColor","Base", - "The color of the area text") + vobj.addProperty("App::PropertyString","Override","Base","Text override. Use $area to insert the area") + vobj.addProperty("App::PropertyColor","TextColor","Base","The color of the area text") vobj.TextColor = (1.0,0.0,0.0,1.0) vobj.Override = "$area m2" ArchComponent.ViewProviderComponent.__init__(self,vobj) diff --git a/src/Mod/Arch/ArchStairs.py b/src/Mod/Arch/ArchStairs.py index a4796440b..49428e50a 100644 --- a/src/Mod/Arch/ArchStairs.py +++ b/src/Mod/Arch/ArchStairs.py @@ -48,6 +48,7 @@ def makeStairs(base=None,length=4.5,width=1,height=3,steps=17,name=translate("Ar obj.Width = width obj.Height = height obj.NumberOfSteps = steps + return obj class _CommandStairs: @@ -78,42 +79,26 @@ class _Stairs(ArchComponent.Component): # http://en.wikipedia.org/wiki/Stairs # base properties - obj.addProperty("App::PropertyLength","Length","Arch", - translate("Arch","The length of these stairs, if no baseline is defined")) - obj.addProperty("App::PropertyLength","Width","Arch", - translate("Arch","The width of these stairs")) - obj.addProperty("App::PropertyLength","Height","Arch", - translate("Arch","The total height of these stairs")) - obj.addProperty("App::PropertyEnumeration","Align","Arch", - translate("Arch","The alignment of these stairs on their baseline, if applicable")) + obj.addProperty("App::PropertyLength","Length","Arch",translate("Arch","The length of these stairs, if no baseline is defined")) + obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of these stairs")) + obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The total height of these stairs")) + obj.addProperty("App::PropertyEnumeration","Align","Arch",translate("Arch","The alignment of these stairs on their baseline, if applicable")) # steps properties - obj.addProperty("App::PropertyInteger","NumberOfSteps","Steps", - translate("Arch","The number of risers in these stairs")) - obj.addProperty("App::PropertyLength","TreadDepth","Steps", - translate("Arch","The depth of the treads of these stairs")) - obj.addProperty("App::PropertyLength","RiserHeight","Steps", - translate("Arch","The height of the risers of these stairs")) - obj.addProperty("App::PropertyLength","Nosing","Steps", - translate("Arch","The size of the nosing")) - obj.addProperty("App::PropertyLength","TreadThickness","Steps", - translate("Arch","The thickness of the treads")) - obj.addProperty("App::PropertyLength","BlondelRatio","Steps", - translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in")) + obj.addProperty("App::PropertyInteger","NumberOfSteps","Steps",translate("Arch","The number of risers in these stairs")) + obj.addProperty("App::PropertyLength","TreadDepth","Steps",translate("Arch","The depth of the treads of these stairs")) + obj.addProperty("App::PropertyLength","RiserHeight","Steps",translate("Arch","The height of the risers of these stairs")) + obj.addProperty("App::PropertyLength","Nosing","Steps",translate("Arch","The size of the nosing")) + obj.addProperty("App::PropertyLength","TreadThickness","Steps",translate("Arch","The thickness of the treads")) + obj.addProperty("App::PropertyLength","BlondelRatio","Steps",translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in")) # structural properties - obj.addProperty("App::PropertyEnumeration","Landings","Structure", - translate("Arch","The type of landings of these stairs")) - obj.addProperty("App::PropertyEnumeration","Winders","Structure", - translate("Arch","The type of winders in these stairs")) - obj.addProperty("App::PropertyEnumeration","Structure","Structure", - translate("Arch","The type of structure of these stairs")) - obj.addProperty("App::PropertyLength","StructureThickness","Structure", - translate("Arch","The thickness of the massive structure or of the stringers")) - obj.addProperty("App::PropertyLength","StringerWidth","Structure", - translate("Arch","The width of the stringers")) - obj.addProperty("App::PropertyLength","StructureOffset","Structure", - translate("Arch","The offset between the border of the stairs and the structure")) + obj.addProperty("App::PropertyEnumeration","Landings","Structure",translate("Arch","The type of landings of these stairs")) + obj.addProperty("App::PropertyEnumeration","Winders","Structure",translate("Arch","The type of winders in these stairs")) + obj.addProperty("App::PropertyEnumeration","Structure","Structure",translate("Arch","The type of structure of these stairs")) + obj.addProperty("App::PropertyLength","StructureThickness","Structure",translate("Arch","The thickness of the massive structure or of the stringers")) + obj.addProperty("App::PropertyLength","StringerWidth","Structure",translate("Arch","The width of the stringers")) + obj.addProperty("App::PropertyLength","StructureOffset","Structure",translate("Arch","The offset between the border of the stairs and the structure")) obj.Align = ['Left','Right','Center'] obj.Landings = ["None","At center","At each corner"] @@ -136,9 +121,9 @@ class _Stairs(ArchComponent.Component): landings = 0 # base tests - if not obj.Width: + if not obj.Width.Value: return - if not obj.Height: + if not obj.Height.Value: if not obj.Base: return if obj.NumberOfSteps < 2: @@ -171,9 +156,9 @@ class _Stairs(ArchComponent.Component): else: self.makeCurvedStairs(obj,edge) else: - if not obj.Length: + if not obj.Length.Value: return - edge = Part.Line(Vector(0,0,0),Vector(obj.Length,0,0)).toShape() + edge = Part.Line(Vector(0,0,0),Vector(obj.Length.Value,0,0)).toShape() if obj.Landings == "At center": landings = 1 self.makeStraightStairsWithLanding(obj,edge) @@ -188,16 +173,16 @@ class _Stairs(ArchComponent.Component): # compute step data if obj.NumberOfSteps > 1: - l = obj.Length - h = obj.Height + l = obj.Length.Value + h = obj.Height.Value if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): l = obj.Base.Shape.Length if obj.Base.Shape.BoundBox.ZLength: h = obj.Base.Shape.BoundBox.ZLength - obj.TreadDepth = float(l-(landings*obj.Width))/(obj.NumberOfSteps-(1+landings)) + obj.TreadDepth = float(l-(landings*obj.Width.Value))/(obj.NumberOfSteps-(1+landings)) obj.RiserHeight = float(h)/obj.NumberOfSteps - obj.BlondelRatio = obj.RiserHeight*2+obj.TreadDepth + obj.BlondelRatio = obj.RiserHeight.Value*2+obj.TreadDepth.Value def align(self,basepoint,align,widthvec): @@ -218,30 +203,30 @@ class _Stairs(ArchComponent.Component): import Part,DraftGeomUtils v = DraftGeomUtils.vec(edge) vLength = Vector(v.x,v.y,0) - vWidth = vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width) + vWidth = vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width.Value) vBase = edge.Vertexes[0].Point - vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing)) - h = obj.Height - l = obj.Length + vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value)) + h = obj.Height.Value + l = obj.Length.Value if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): l = obj.Base.Shape.Length if obj.Base.Shape.BoundBox.ZLength: h = obj.Base.Shape.BoundBox.ZLength - fLength = float(l-obj.Width)/(numberofsteps-2) + fLength = float(l-obj.Width.Value)/(numberofsteps-2) fHeight = float(h)/numberofsteps a = math.atan(fHeight/fLength) print "landing data:",fLength,":",fHeight # step p1 = self.align(vBase,obj.Align,vWidth) - p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness))) + p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness.Value))) p2 = p1.add(DraftVecUtils.neg(vNose)).add(vLength) p3 = p2.add(vWidth) p4 = p3.add(DraftVecUtils.neg(vLength)).add(vNose) step = Part.Face(Part.makePolygon([p1,p2,p3,p4,p1])) - if obj.TreadThickness: - step = step.extrude(Vector(0,0,abs(obj.TreadThickness))) + if obj.TreadThickness.Value: + step = step.extrude(Vector(0,0,abs(obj.TreadThickness.Value))) self.steps.append(step) # structure @@ -249,61 +234,61 @@ class _Stairs(ArchComponent.Component): struct = None p7 = None p1 = p1.add(DraftVecUtils.neg(vNose)) - p2 = p1.add(Vector(0,0,-fHeight)).add(Vector(0,0,-obj.StructureThickness/math.cos(a))) - resheight = p1.sub(p2).Length - obj.StructureThickness + p2 = p1.add(Vector(0,0,-fHeight)).add(Vector(0,0,-obj.StructureThickness.Value/math.cos(a))) + resheight = p1.sub(p2).Length - obj.StructureThickness.Value reslength = resheight / math.tan(a) p3 = p2.add(DraftVecUtils.scaleTo(vLength,reslength)).add(Vector(0,0,resheight)) p6 = p1.add(vLength) - if obj.TreadThickness: - p7 = p6.add(Vector(0,0,obj.TreadThickness)) + if obj.TreadThickness.Value: + p7 = p6.add(Vector(0,0,obj.TreadThickness.Value)) - reslength = fLength + (obj.StructureThickness/math.sin(a)-(fHeight-obj.TreadThickness)/math.tan(a)) + reslength = fLength + (obj.StructureThickness.Value/math.sin(a)-(fHeight-obj.TreadThickness.Value)/math.tan(a)) if p7: p5 = p7.add(DraftVecUtils.scaleTo(vLength,reslength)) else: p5 = p6.add(DraftVecUtils.scaleTo(vLength,reslength)) - resheight = obj.StructureThickness+obj.TreadThickness + resheight = obj.StructureThickness.Value + obj.TreadThickness.Value reslength = resheight/math.tan(a) p4 = p5.add(DraftVecUtils.scaleTo(vLength,-reslength)).add(Vector(0,0,-resheight)) if obj.Structure == "Massive": - if obj.StructureThickness: + if obj.StructureThickness.Value: if p7: struct = Part.Face(Part.makePolygon([p1,p2,p3,p4,p5,p7,p6,p1])) else: struct = Part.Face(Part.makePolygon([p1,p2,p3,p4,p5,p6,p1])) evec = vWidth - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) struct.translate(mvec) evec = DraftVecUtils.scaleTo(evec,evec.Length-(2*mvec.Length)) struct = struct.extrude(evec) elif obj.Structure in ["One stringer","Two stringers"]: - if obj.StringerWidth and obj.StructureThickness: + if obj.StringerWidth.Value and obj.StructureThickness.Value: p1b = p1.add(Vector(0,0,-fHeight)) reslength = fHeight/math.tan(a) p1c = p1.add(DraftVecUtils.scaleTo(vLength,reslength)) p5b = None p5c = None - if obj.TreadThickness: - reslength = obj.StructureThickness/math.sin(a) + if obj.TreadThickness.Value: + reslength = obj.StructureThickness.Value/math.sin(a) p5b = p5.add(DraftVecUtils.scaleTo(vLength,-reslength)) - reslength = obj.TreadThickness/math.tan(a) - p5c = p5b.add(DraftVecUtils.scaleTo(vLength,-reslength)).add(Vector(0,0,-obj.TreadThickness)) + reslength = obj.TreadThickness.Value/math.tan(a) + p5c = p5b.add(DraftVecUtils.scaleTo(vLength,-reslength)).add(Vector(0,0,-obj.TreadThickness.Value)) pol = Part.Face(Part.makePolygon([p1c,p1b,p2,p3,p4,p5,p5b,p5c,p1c])) else: pol = Part.Face(Part.makePolygon([p1c,p1b,p2,p3,p4,p5,p1c])) - evec = DraftVecUtils.scaleTo(vWidth,obj.StringerWidth) + evec = DraftVecUtils.scaleTo(vWidth,obj.StringerWidth.Value) if obj.Structure == "One stringer": - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) else: - mvec = DraftVecUtils.scaleTo(vWidth,(vWidth.Length/2)-obj.StringerWidth/2) + mvec = DraftVecUtils.scaleTo(vWidth,(vWidth.Length/2)-obj.StringerWidth.Value/2) pol.translate(mvec) struct = pol.extrude(evec) elif obj.Structure == "Two stringers": pol2 = pol.copy() - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) pol.translate(mvec) mvec = vWidth.add(mvec.negative()) pol2.translate(mvec) @@ -330,11 +315,11 @@ class _Stairs(ArchComponent.Component): if round(v.z,Draft.precision()) != 0: h = v.z else: - h = obj.Height + h = obj.Height.Value vHeight = Vector(0,0,float(h)/numberofsteps) - vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width) + vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width.Value) vBase = edge.Vertexes[0].Point - vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing)) + vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value)) a = math.atan(vHeight.Length/vLength.Length) print "stair data:",vLength.Length,":",vHeight.Length @@ -342,31 +327,31 @@ class _Stairs(ArchComponent.Component): for i in range(numberofsteps-1): p1 = vBase.add((Vector(vLength).multiply(i)).add(Vector(vHeight).multiply(i+1))) p1 = self.align(p1,obj.Align,vWidth) - p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness))) + p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness.Value))) p2 = p1.add(DraftVecUtils.neg(vNose)).add(vLength) p3 = p2.add(vWidth) p4 = p3.add(DraftVecUtils.neg(vLength)).add(vNose) step = Part.Face(Part.makePolygon([p1,p2,p3,p4,p1])) - if obj.TreadThickness: - step = step.extrude(Vector(0,0,abs(obj.TreadThickness))) + if obj.TreadThickness.Value: + step = step.extrude(Vector(0,0,abs(obj.TreadThickness.Value))) self.steps.append(step) # structure lProfile = [] struct = None if obj.Structure == "Massive": - if obj.StructureThickness: + if obj.StructureThickness.Value: for i in range(numberofsteps-1): if not lProfile: lProfile.append(vBase) last = lProfile[-1] if len(lProfile) == 1: - last = last.add(Vector(0,0,-abs(obj.TreadThickness))) + last = last.add(Vector(0,0,-abs(obj.TreadThickness.Value))) lProfile.append(last.add(vHeight)) lProfile.append(lProfile[-1].add(vLength)) - resHeight1 = obj.StructureThickness/math.cos(a) + resHeight1 = obj.StructureThickness.Value/math.cos(a) lProfile.append(lProfile[-1].add(Vector(0,0,-resHeight1))) - resHeight2 = ((numberofsteps-1)*vHeight.Length)-(resHeight1+obj.TreadThickness) + resHeight2 = ((numberofsteps-1)*vHeight.Length)-(resHeight1+obj.TreadThickness.Value) resLength = (vLength.Length/vHeight.Length)*resHeight2 h = DraftVecUtils.scaleTo(vLength,-resLength) lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2))) @@ -375,44 +360,44 @@ class _Stairs(ArchComponent.Component): pol = Part.makePolygon(lProfile) struct = Part.Face(pol) evec = vWidth - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) struct.translate(mvec) evec = DraftVecUtils.scaleTo(evec,evec.Length-(2*mvec.Length)) struct = struct.extrude(evec) elif obj.Structure in ["One stringer","Two stringers"]: - if obj.StringerWidth and obj.StructureThickness: + if obj.StringerWidth.Value and obj.StructureThickness.Value: hyp = math.sqrt(vHeight.Length**2 + vLength.Length**2) l1 = Vector(vLength).multiply(numberofsteps-1) - h1 = Vector(vHeight).multiply(numberofsteps-1).add(Vector(0,0,-abs(obj.TreadThickness))) + h1 = Vector(vHeight).multiply(numberofsteps-1).add(Vector(0,0,-abs(obj.TreadThickness.Value))) p1 = vBase.add(l1).add(h1) p1 = self.align(p1,obj.Align,vWidth) lProfile.append(p1) - h2 = (obj.StructureThickness/vLength.Length)*hyp + h2 = (obj.StructureThickness.Value/vLength.Length)*hyp lProfile.append(lProfile[-1].add(Vector(0,0,-abs(h2)))) h3 = lProfile[-1].z-vBase.z l3 = (h3/vHeight.Length)*vLength.Length v3 = DraftVecUtils.scaleTo(vLength,-l3) lProfile.append(lProfile[-1].add(Vector(0,0,-abs(h3))).add(v3)) - l4 = (obj.StructureThickness/vHeight.Length)*hyp + l4 = (obj.StructureThickness.Value/vHeight.Length)*hyp v4 = DraftVecUtils.scaleTo(vLength,-l4) lProfile.append(lProfile[-1].add(v4)) lProfile.append(lProfile[0]) #print lProfile pol = Part.makePolygon(lProfile) pol = Part.Face(pol) - evec = DraftVecUtils.scaleTo(vWidth,obj.StringerWidth) + evec = DraftVecUtils.scaleTo(vWidth,obj.StringerWidth.Value) if obj.Structure == "One stringer": - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) else: - mvec = DraftVecUtils.scaleTo(vWidth,(vWidth.Length/2)-obj.StringerWidth/2) + mvec = DraftVecUtils.scaleTo(vWidth,(vWidth.Length/2)-obj.StringerWidth.Value/2) pol.translate(mvec) struct = pol.extrude(evec) elif obj.Structure == "Two stringers": pol2 = pol.copy() - if obj.StructureOffset: - mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset) + if obj.StructureOffset.Value: + mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) pol.translate(mvec) mvec = vWidth.add(mvec.negative()) pol2.translate(mvec) @@ -433,19 +418,19 @@ class _Stairs(ArchComponent.Component): return import Part,DraftGeomUtils v = DraftGeomUtils.vec(edge) - reslength = edge.Length - obj.Width + reslength = edge.Length - obj.Width.Value vLength = DraftVecUtils.scaleTo(v,float(reslength)/(obj.NumberOfSteps-2)) vLength = Vector(vLength.x,vLength.y,0) - vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width) + vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0,0,1)),obj.Width.Value) p1 = edge.Vertexes[0].Point if round(v.z,Draft.precision()) != 0: h = v.z else: - h = obj.Height + h = obj.Height.Value hstep = h/obj.NumberOfSteps landing = obj.NumberOfSteps/2 p2 = p1.add(DraftVecUtils.scale(vLength,landing-1).add(Vector(0,0,landing*hstep))) - p3 = p2.add(DraftVecUtils.scaleTo(vLength,obj.Width)) + p3 = p2.add(DraftVecUtils.scaleTo(vLength,obj.Width.Value)) p4 = p3.add(DraftVecUtils.scale(vLength,obj.NumberOfSteps-(landing+1)).add(Vector(0,0,(obj.NumberOfSteps-landing)*hstep))) self.makeStraightStairs(obj,Part.Line(p1,p2).toShape(),landing) self.makeStraightLanding(obj,Part.Line(p2,p3).toShape()) diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 8bb751d3f..6e9bc01a2 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -520,26 +520,16 @@ class _Structure(ArchComponent.Component): "The Structure object" def __init__(self,obj): ArchComponent.Component.__init__(self,obj) - obj.addProperty("App::PropertyLink","Tool","Arch", - translate("Arch","An optional extrusion path for this element")) - obj.addProperty("App::PropertyLength","Length","Arch", - translate("Arch","The length of this element, if not based on a profile")) - obj.addProperty("App::PropertyLength","Width","Arch", - translate("Arch","The width of this element, if not based on a profile")) - obj.addProperty("App::PropertyLength","Height","Arch", - translate("Arch","The height or extrusion depth of this element. Keep 0 for automatic")) - obj.addProperty("App::PropertyLinkList","Axes","Arch", - translate("Arch","Axes systems this structure is built on")) - obj.addProperty("App::PropertyLinkList","Armatures","Arch", - translate("Arch","Armatures contained in this element")) - obj.addProperty("App::PropertyVector","Normal","Arch", - translate("Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")) - obj.addProperty("App::PropertyIntegerList","Exclude","Arch", - translate("Arch","The element numbers to exclude when this structure is based on axes")) - obj.addProperty("App::PropertyEnumeration","Role","Arch", - translate("Arch","The role of this structural element")) - obj.addProperty("App::PropertyVectorList","Nodes","Arch", - translate("Arch","The structural nodes of this element")) + obj.addProperty("App::PropertyLink","Tool","Arch",translate("Arch","An optional extrusion path for this element")) + obj.addProperty("App::PropertyLength","Length","Arch",translate("Arch","The length of this element, if not based on a profile")) + obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of this element, if not based on a profile")) + obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The height or extrusion depth of this element. Keep 0 for automatic")) + obj.addProperty("App::PropertyLinkList","Axes","Arch",translate("Arch","Axes systems this structure is built on")) + obj.addProperty("App::PropertyLinkList","Armatures","Arch",translate("Arch","Armatures contained in this element")) + obj.addProperty("App::PropertyVector","Normal","Arch",translate("Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")) + obj.addProperty("App::PropertyIntegerList","Exclude","Arch",translate("Arch","The element numbers to exclude when this structure is based on axes")) + obj.addProperty("App::PropertyEnumeration","Role","Arch",translate("Arch","The role of this structural element")) + obj.addProperty("App::PropertyVectorList","Nodes","Arch",translate("Arch","The structural nodes of this element")) self.Type = "Structure" obj.Length = 1 obj.Width = 1 @@ -556,19 +546,19 @@ class _Structure(ArchComponent.Component): width = 1 height = 1 if hasattr(obj,"Length"): - if obj.Length: - length = obj.Length + if obj.Length.Value: + length = obj.Length.Value if hasattr(obj,"Width"): - if obj.Width: - width = obj.Width + if obj.Width.Value: + width = obj.Width.Value if hasattr(obj,"Height"): - if obj.Height: - height = obj.Height + if obj.Height.Value: + height = obj.Height.Value else: for p in obj.InList: if Draft.getType(p) == "Floor": - if p.Height: - height = p.Height + if p.Height.Value: + height = p.Height.Value # creating base shape pl = obj.Placement @@ -789,35 +779,31 @@ class _Profile(Draft._DraftObject): "A parametric beam profile object" def __init__(self,obj): - obj.addProperty("App::PropertyDistance","Width","Draft","Width of the beam").Width = 10 - obj.addProperty("App::PropertyDistance","Height","Draft","Height of the beam").Height = 30 - obj.addProperty("App::PropertyDistance","WebThickness","Draft","Thickness of the webs").WebThickness = 3 - obj.addProperty("App::PropertyDistance","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = 2 + 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/2,-obj.Height/2,0) - p2 = Vector(obj.Width/2,-obj.Height/2,0) - p3 = Vector(obj.Width/2,(-obj.Height/2)+obj.FlangeThickness,0) - p4 = Vector(obj.WebThickness/2,(-obj.Height/2)+obj.FlangeThickness,0) - p5 = Vector(obj.WebThickness/2,obj.Height/2-obj.FlangeThickness,0) - p6 = Vector(obj.Width/2,obj.Height/2-obj.FlangeThickness,0) - p7 = Vector(obj.Width/2,obj.Height/2,0) - p8 = Vector(-obj.Width/2,obj.Height/2,0) - p9 = Vector(-obj.Width/2,obj.Height/2-obj.FlangeThickness,0) - p10 = Vector(-obj.WebThickness/2,obj.Height/2-obj.FlangeThickness,0) - p11 = Vector(-obj.WebThickness/2,(-obj.Height/2)+obj.FlangeThickness,0) - p12 = Vector(-obj.Width/2,(-obj.Height/2)+obj.FlangeThickness,0) + 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 - - def onChanged(self,obj,prop): - if prop in ["Width","Height","WebThickness","FlangeThickness"]: - self.execute(obj) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Structure',_CommandStructure()) diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index c4e3c0efc..09909e62a 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -377,22 +377,14 @@ class _Wall(ArchComponent.Component): "The Wall object" def __init__(self,obj): ArchComponent.Component.__init__(self,obj) - obj.addProperty("App::PropertyLength","Length","Arch", - str(translate("Arch","The length of this wall. Not used if this wall is based on an underlying object"))) - obj.addProperty("App::PropertyLength","Width","Arch", - str(translate("Arch","The width of this wall. Not used if this wall is based on a face"))) - obj.addProperty("App::PropertyLength","Height","Arch", - str(translate("Arch","The height of this wall. Keep 0 for automatic. Not used if this wall is based on a solid"))) - obj.addProperty("App::PropertyEnumeration","Align","Arch", - str(translate("Arch","The alignment of this wall on its base object, if applicable"))) - obj.addProperty("App::PropertyVector","Normal","Arch", - str(translate("Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)"))) - obj.addProperty("App::PropertyBool","ForceWire","Arch", - str(translate("Arch","If True, if this wall is based on a face, it will use its border wire as trace, and disconsider the face."))) - obj.addProperty("App::PropertyInteger","Face","Arch", - str(translate("Arch","The face number of the base object used to build this wall"))) - obj.addProperty("App::PropertyLength","Offset","Arch", - str(translate("Arch","The offset between this wall and its baseline (only for left and right alignments)"))) + obj.addProperty("App::PropertyLength","Length","Arch",translate("Arch","The length of this wall. Not used if this wall is based on an underlying object")) + obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of this wall. Not used if this wall is based on a face")) + obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The height of this wall. Keep 0 for automatic. Not used if this wall is based on a solid")) + obj.addProperty("App::PropertyEnumeration","Align","Arch",translate("Arch","The alignment of this wall on its base object, if applicable")) + obj.addProperty("App::PropertyVector","Normal","Arch",translate("Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")) + obj.addProperty("App::PropertyBool","ForceWire","Arch",translate("Arch","If True, if this wall is based on a face, it will use its border wire as trace, and disconsider the face.")) + obj.addProperty("App::PropertyInteger","Face","Arch",translate("Arch","The face number of the base object used to build this wall")) + obj.addProperty("App::PropertyLength","Offset","Arch",translate("Arch","The offset between this wall and its baseline (only for left and right alignments)")) obj.Align = ['Left','Right','Center'] obj.ForceWire = False self.Type = "Wall" @@ -511,21 +503,21 @@ class _Wall(ArchComponent.Component): "returns normal,width,height values from this wall" length = 1 if hasattr(obj,"Length"): - if obj.Length: - length = obj.Length + if obj.Length.Value: + length = obj.Length.Value width = 1 if hasattr(obj,"Width"): - if obj.Width: - width = obj.Width + if obj.Width.Value: + width = obj.Width.Value height = 1 if hasattr(obj,"Height"): - if obj.Height: - height = obj.Height + if obj.Height.Value: + height = obj.Height.Value else: for p in obj.InList: if Draft.getType(p) == "Floor": - if p.Height: - height = p.Height + if p.Height.Value: + height = p.Height.Value normal = None if hasattr(obj,"Normal"): if obj.Normal == Vector(0,0,0): @@ -548,8 +540,8 @@ class _Wall(ArchComponent.Component): if obj.Align == "Left": dvec.multiply(width) if hasattr(obj,"Offset"): - if obj.Offset: - dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset) + if obj.Offset.Value: + dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset.Value) wire = DraftGeomUtils.offsetWire(wire,dvec2) w2 = DraftGeomUtils.offsetWire(wire,dvec) w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges)) @@ -558,8 +550,8 @@ class _Wall(ArchComponent.Component): dvec.multiply(width) dvec = dvec.negative() if hasattr(obj,"Offset"): - if obj.Offset: - dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset) + if obj.Offset.Value: + dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset.Value) wire = DraftGeomUtils.offsetWire(wire,dvec2) w2 = DraftGeomUtils.offsetWire(wire,dvec) w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges)) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index b9aada61c..c986401da 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -574,21 +574,14 @@ class _Window(ArchComponent.Component): "The Window object" def __init__(self,obj): ArchComponent.Component.__init__(self,obj) - obj.addProperty("App::PropertyStringList","WindowParts","Arch", - translate("Arch","the components of this window")) - obj.addProperty("App::PropertyLength","HoleDepth","Arch", - translate("Arch","The depth of the hole that this window makes in its host object. Keep 0 for automatic.")) - obj.addProperty("Part::PropertyPartShape","Subvolume","Arch", - translate("Arch","an optional volume to be subtracted from hosts of this window")) - obj.addProperty("App::PropertyLength","Width","Arch", - translate("Arch","The width of this window (for preset windows only)")) - obj.addProperty("App::PropertyLength","Height","Arch", - translate("Arch","The height of this window (for preset windows only)")) - obj.addProperty("App::PropertyVector","Normal","Arch", - translate("Arch","The normal direction of this window")) + obj.addProperty("App::PropertyStringList","WindowParts","Arch",translate("Arch","the components of this window")) + obj.addProperty("App::PropertyLength","HoleDepth","Arch",translate("Arch","The depth of the hole that this window makes in its host object. Keep 0 for automatic.")) + obj.addProperty("Part::PropertyPartShape","Subvolume","Arch",translate("Arch","an optional volume to be subtracted from hosts of this window")) + obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of this window (for preset windows only)")) + obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The height of this window (for preset windows only)")) + obj.addProperty("App::PropertyVector","Normal","Arch",translate("Arch","The normal direction of this window")) obj.addProperty("App::PropertyInteger","Preset","Arch","") - obj.addProperty("App::PropertyEnumeration","Role","Arch", - translate("Arch","The role of this window")) + obj.addProperty("App::PropertyEnumeration","Role","Arch",translate("Arch","The role of this window")) obj.setEditorMode("Preset",2) self.Type = "Window" @@ -608,9 +601,9 @@ class _Window(ArchComponent.Component): if obj.Base: try: if prop == "Height": - obj.Base.setDatum(16,obj.Height) + obj.Base.setDatum(16,obj.Height.Value) elif prop == "Width": - obj.Base.setDatum(17,obj.Width) + obj.Base.setDatum(17,obj.Width.Value) except: # restoring constraints when loading a file fails # because of load order, but it doesn't harm... @@ -691,8 +684,8 @@ class _Window(ArchComponent.Component): base = obj.Base width = 0 if hasattr(obj,"HoleDepth"): - if obj.HoleDepth: - width = obj.HoleDepth + if obj.HoleDepth.Value: + width = obj.HoleDepth.Value if not width: if base: b = base.Shape.BoundBox @@ -703,8 +696,8 @@ class _Window(ArchComponent.Component): if orig.Base: base = orig.Base if hasattr(orig,"HoleDepth"): - if orig.HoleDepth: - width = orig.HoleDepth + if orig.HoleDepth.Value: + width = orig.HoleDepth.Value if not width: if base: b = base.Shape.BoundBox diff --git a/src/Mod/Arch/TestArch.py b/src/Mod/Arch/TestArch.py index 7f86153e4..b30217a7c 100644 --- a/src/Mod/Arch/TestArch.py +++ b/src/Mod/Arch/TestArch.py @@ -23,7 +23,7 @@ #* * #***************************************************************************/ -import FreeCAD, os, unittest, FreeCADGui, Arch, Draft +import FreeCAD, os, unittest, FreeCADGui, Arch, Draft, Part, Sketcher class ArchTest(unittest.TestCase): @@ -44,9 +44,127 @@ class ArchTest(unittest.TestCase): def testStructure(self): FreeCAD.Console.PrintLog ('Checking Arch Structure...\n') - s = Arch.makeStructure(length=2,width=3,hright=5) + s = Arch.makeStructure(length=2,width=3,height=5) self.failUnless(s,"Arch Structure failed") + def testRebar(self): + FreeCAD.Console.PrintLog ('Checking Arch Rebar...\n') + s = Arch.makeStructure(length=2,width=3,height=5) + sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch') + sk.Support = (s,["Face6"]) + sk.addGeometry(Part.Line(FreeCAD.Vector(-0.85,1.25,0),FreeCAD.Vector(0.75,1.25,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(0.75,1.25,0),FreeCAD.Vector(0.75,-1.20,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(0.75,-1.20,0),FreeCAD.Vector(-0.85,-1.20,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(-0.85,-1.20,0),FreeCAD.Vector(-0.85,1.25,0))) + sk.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',3,2,0,1)) + r = Arch.makeRebar(s,sk,diameter=.1,amount=2) + self.failUnless(r,"Arch Rebar failed") + + def testFloor(self): + FreeCAD.Console.PrintLog ('Checking Arch Floor...\n') + s = Arch.makeStructure(length=2,width=3,height=5) + f = Arch.makeFloor([s]) + self.failUnless(f,"Arch Floor failed") + + def testBuilding(self): + FreeCAD.Console.PrintLog ('Checking Arch Building...\n') + s = Arch.makeStructure(length=2,width=3,height=5) + f = Arch.makeFloor([s]) + b = Arch.makeBuilding([f]) + self.failUnless(b,"Arch Building failed") + + def testSite(self): + FreeCAD.Console.PrintLog ('Checking Arch Site...\n') + s = Arch.makeStructure(length=2,width=3,height=5) + f = Arch.makeFloor([s]) + b = Arch.makeBuilding([f]) + si = Arch.makeSite([b]) + self.failUnless(si,"Arch Site failed") + + def testWindow(self): + FreeCAD.Console.PrintLog ('Checking Arch Window...\n') + l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0)) + w = Arch.makeWall(l) + sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch001') + sk.Support = (w,["Face3"]) + sk.addGeometry(Part.Line(FreeCAD.Vector(-1.80,1.30,0),FreeCAD.Vector(-0.90,1.30,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(-0.90,1.30,0),FreeCAD.Vector(-0.90,0.25,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(-0.90,0.25,0),FreeCAD.Vector(-1.80,0.25,0))) + sk.addGeometry(Part.Line(FreeCAD.Vector(-1.80,0.25,0),FreeCAD.Vector(-1.80,1.30,0))) + sk.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) + sk.addConstraint(Sketcher.Constraint('Coincident',3,2,0,1)) + win = Arch.makeWindow(sk) + Arch.removeComponents(win,host=w) + self.failUnless(win,"Arch Window failed") + + def testRoof(self): + FreeCAD.Console.PrintLog ('Checking Arch Roof...\n') + r = Draft.makeRectangle(length=2,height=-1) + ro = Arch.makeRoof(r) + self.failUnless(ro,"Arch Roof failed") + + def testAxis(self): + FreeCAD.Console.PrintLog ('Checking Arch Axis...\n') + a = Arch.makeAxis() + self.failUnless(a,"Arch Axis failed") + + def testSection(self): + FreeCAD.Console.PrintLog ('Checking Arch Section...\n') + s = Arch.makeSectionPlane([]) + v = Arch.makeSectionView(s) + self.failUnless(v,"Arch Section failed") + + def testSpace(self): + FreeCAD.Console.PrintLog ('Checking Arch Space...\n') + sb = Part.makeBox(1,1,1) + b = FreeCAD.ActiveDocument.addObject('Part::Feature','Box') + b.Shape = sb + s = Arch.makeSpace([b]) + self.failUnless(s,"Arch Space failed") + + def testStairs(self): + FreeCAD.Console.PrintLog ('Checking Arch Stairs...\n') + s = Arch.makeStairs() + self.failUnless(s,"Arch Stairs failed") + + def testFrame(self): + FreeCAD.Console.PrintLog ('Checking Arch Frame...\n') + l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0)) + p = Draft.makeRectangle(length=.5,height=.5) + f = Arch.makeFrame(l,p) + self.failUnless(f,"Arch Frame failed") + + def testAdd(self): + FreeCAD.Console.PrintLog ('Checking Arch Add...\n') + l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0)) + w = Arch.makeWall(l) + sb = Part.makeBox(1,1,1) + b = FreeCAD.ActiveDocument.addObject('Part::Feature','Box') + b.Shape = sb + FreeCAD.ActiveDocument.recompute() + Arch.addComponents(b,w) + FreeCAD.ActiveDocument.recompute() + r = (w.Shape.Volume > 1.5) + self.failUnless(r,"Arch Add failed") + + def testRemove(self): + FreeCAD.Console.PrintLog ('Checking Arch Remove...\n') + l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0)) + w = Arch.makeWall(l) + sb = Part.makeBox(1,1,1) + b = FreeCAD.ActiveDocument.addObject('Part::Feature','Box') + b.Shape = sb + FreeCAD.ActiveDocument.recompute() + Arch.removeComponents(b,w) + FreeCAD.ActiveDocument.recompute() + r = (w.Shape.Volume < 0.75) + self.failUnless(r,"Arch Remove failed") + def tearDown(self): FreeCAD.closeDocument("ArchTest") pass diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index a8e1fd631..f4848f4e5 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -427,7 +427,10 @@ def formatObject(target,origin=None): for p in matchrep.PropertiesList: if not p in ["DisplayMode","BoundingBox","Proxy","RootNode","Visibility"]: if p in obrep.PropertiesList: - val = getattr(matchrep,p) + if hasattr(getattr(matchrep,p),"Value"): + val = getattr(matchrep,p).Value + else: + val = getattr(matchrep,p) setattr(obrep,p,val) if matchrep.DisplayMode in obrep.listDisplayModes(): obrep.DisplayMode = matchrep.DisplayMode @@ -929,7 +932,10 @@ def makeCopy(obj,force=None,reparent=False): try: setattr(newobj,p,obj.getPropertyByName(p)) except: - pass + try: + setattr(newobj,p,obj.getPropertyByName(p).Value) + except: + pass if reparent: parents = obj.InList if parents: @@ -1294,7 +1300,7 @@ def scale(objectslist,delta=Vector(1,1,1),center=Vector(0,0,0),copy=False,legacy elif (obj.isDerivedFrom("Part::Feature")): newobj.Shape = sh elif (obj.TypeId == "App::Annotation"): - factor = delta.x * delta.y * delta.z * obj.ViewObject.FontSize + factor = delta.x * delta.y * delta.z * obj.ViewObject.FontSize.Value obj.ViewObject.Fontsize = factor if copy: formatObject(newobj,obj) newobjlist.append(newobj) @@ -1670,7 +1676,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct if obj.ViewObject.Proxy: if hasattr(obj.ViewObject.Proxy,"p1"): prx = obj.ViewObject.Proxy - ts = (len(prx.string)*obj.ViewObject.FontSize)/4 + ts = (len(prx.string)*obj.ViewObject.FontSize.Value)/4 rm = ((prx.p3.sub(prx.p2)).Length/2)-ts p2a = getProj(prx.p2.add(DraftVecUtils.scaleTo(prx.p3.sub(prx.p2),rm))) p2b = getProj(prx.p3.add(DraftVecUtils.scaleTo(prx.p2.sub(prx.p3),rm))) @@ -1716,7 +1722,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct # drawing arrows if hasattr(obj.ViewObject,"ArrowType"): - arrowsize = obj.ViewObject.ArrowSize/pointratio + arrowsize = obj.ViewObject.ArrowSize.Value/pointratio if hasattr(obj.ViewObject,"FlipArrows"): if obj.ViewObject.FlipArrows: angle = angle+math.pi @@ -1748,8 +1754,8 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct if hasattr(obj.ViewObject,"ArrowType"): p2 = getProj(prx.p2) p3 = getProj(prx.p3) - arrowsize = obj.ViewObject.ArrowSize/pointratio - arrowlength = 4*obj.ViewObject.ArrowSize + arrowsize = obj.ViewObject.ArrowSize.Value/pointratio + arrowlength = 4*obj.ViewObject.ArrowSize.Value u1 = getProj((prx.circle.valueAt(prx.circle.FirstParameter+arrowlength)).sub(prx.circle.valueAt(prx.circle.FirstParameter))) u2 = getProj((prx.circle.valueAt(prx.circle.LastParameter-arrowlength)).sub(prx.circle.valueAt(prx.circle.LastParameter))) angle1 = -DraftVecUtils.angle(u1) @@ -2743,7 +2749,7 @@ class _DraftObject: def execute(self,obj): pass - def onChanged(self, fp, prop): + def onChanged(self, obj, prop): pass class _ViewProviderDraft: @@ -2887,20 +2893,13 @@ class _Dimension(_DraftObject): "The Draft Dimension object" def __init__(self, obj): _DraftObject.__init__(self,obj,"Dimension") - obj.addProperty("App::PropertyVector","Start","Draft", - "Startpoint of dimension") - obj.addProperty("App::PropertyVector","End","Draft", - "Endpoint of dimension") - obj.addProperty("App::PropertyVector","Normal","Draft", - "the normal direction of this dimension") - obj.addProperty("App::PropertyVector","Direction","Draft", - "the normal direction of this dimension") - obj.addProperty("App::PropertyVector","Dimline","Draft", - "Point through which the dimension line passes") - obj.addProperty("App::PropertyLink","Support","Draft", - "The object measured by this dimension") - obj.addProperty("App::PropertyLinkSubList","LinkedGeometry","Draft", - "The geometry this dimension is linked to") + obj.addProperty("App::PropertyVector","Start","Draft","Startpoint of dimension") + obj.addProperty("App::PropertyVector","End","Draft","Endpoint of dimension") + obj.addProperty("App::PropertyVector","Normal","Draft","the normal direction of this dimension") + obj.addProperty("App::PropertyVector","Direction","Draft","the normal direction of this dimension") + obj.addProperty("App::PropertyVector","Dimline","Draft","Point through which the dimension line passes") + obj.addProperty("App::PropertyLink","Support","Draft","The object measured by this dimension") + obj.addProperty("App::PropertyLinkSubList","LinkedGeometry","Draft","The geometry this dimension is linked to") obj.addProperty("App::PropertyLength","Distance","Draft","The measurement of this dimension") obj.Start = FreeCAD.Vector(0,0,0) obj.End = FreeCAD.Vector(1,0,0) @@ -2948,15 +2947,15 @@ class _ViewProviderDimension(_ViewProviderDraft): obj.addProperty("App::PropertyLength","TextSpacing","Draft","The spacing between the text and the dimension line") obj.addProperty("App::PropertyEnumeration","ArrowType","Draft","Arrow type") obj.addProperty("App::PropertyString","FontName","Draft","Font name") - obj.addProperty("App::PropertyLength","LineWidth","Draft","Line width") + obj.addProperty("App::PropertyFloat","LineWidth","Draft","Line width") obj.addProperty("App::PropertyColor","LineColor","Draft","Line color") obj.addProperty("App::PropertyLength","ExtLines","Draft","Length of the extension lines") obj.addProperty("App::PropertyBool","FlipArrows","Draft","Rotate the dimension arrows 180 degrees") obj.addProperty("App::PropertyVector","TextPosition","Draft","The position of the text. Leave (0,0,0) for automatic position") obj.addProperty("App::PropertyString","Override","Draft","Text override. Use $dim to insert the dimension length") - obj.FontSize=getParam("textheight",0.20) - obj.TextSpacing=getParam("dimspacing",0.05) - obj.FontName=getParam("textfont","") + obj.FontSize = getParam("textheight",0.20) + obj.TextSpacing = getParam("dimspacing",0.05) + obj.FontName = getParam("textfont","") obj.ArrowSize = getParam("arrowsize",0.1) obj.ArrowType = arrowtypes obj.ArrowType = arrowtypes[getParam("dimsymbol",0)] @@ -3056,7 +3055,7 @@ class _ViewProviderDimension(_ViewProviderDraft): if proj: self.p2 = self.p1.add(proj.negative()) self.p3 = self.p4.add(proj.negative()) - dmax = obj.ViewObject.ExtLines + dmax = obj.ViewObject.ExtLines.Value if dmax and (proj.Length > dmax): self.p1 = self.p2.add(DraftVecUtils.scaleTo(proj,dmax)) self.p4 = self.p3.add(DraftVecUtils.scaleTo(proj,dmax)) @@ -3093,7 +3092,7 @@ class _ViewProviderDimension(_ViewProviderDraft): self.trans1.rotation.setValue((rot2[0],rot2[1],rot2[2],rot2[3])) self.trans2.rotation.setValue((rot2[0],rot2[1],rot2[2],rot2[3])) if hasattr(obj.ViewObject,"TextSpacing"): - offset = DraftVecUtils.scaleTo(v1,obj.ViewObject.TextSpacing) + offset = DraftVecUtils.scaleTo(v1,obj.ViewObject.TextSpacing.Value) else: offset = DraftVecUtils.scaleTo(v1,0.05) @@ -3129,7 +3128,7 @@ class _ViewProviderDimension(_ViewProviderDraft): # set the lines if m == "3D": # calculate the spacing of the text - textsize = (len(self.string)*obj.ViewObject.FontSize)/4 + textsize = (len(self.string)*obj.ViewObject.FontSize.Value)/4 spacing = ((self.p3.sub(self.p2)).Length/2) - textsize self.p2a = self.p2.add(DraftVecUtils.scaleTo(self.p3.sub(self.p2),spacing)) self.p2b = self.p3.add(DraftVecUtils.scaleTo(self.p2.sub(self.p3),spacing)) @@ -3156,9 +3155,9 @@ class _ViewProviderDimension(_ViewProviderDraft): self.updateData(vobj.Object,"Start") elif prop == "FontSize": if hasattr(self,"font"): - self.font.size = vobj.FontSize + self.font.size = vobj.FontSize.Value if hasattr(self,"font3d"): - self.font3d.size = vobj.FontSize*100 + self.font3d.size = vobj.FontSize.Value*100 elif prop == "FontName": if hasattr(self,"font") and hasattr(self,"font3d"): self.font.name = self.font3d.name = str(vobj.FontName) @@ -3183,7 +3182,7 @@ class _ViewProviderDimension(_ViewProviderDraft): # set scale symbol = arrowtypes.index(vobj.ArrowType) - s = vobj.ArrowSize + s = vobj.ArrowSize.Value self.trans1.scaleFactor.setValue((s,s,s)) self.trans2.scaleFactor.setValue((s,s,s)) @@ -3262,20 +3261,13 @@ class _AngularDimension(_DraftObject): "The Draft AngularDimension object" def __init__(self, obj): _DraftObject.__init__(self,obj,"AngularDimension") - obj.addProperty("App::PropertyAngle","FirstAngle","Draft", - "Start angle of the dimension") - obj.addProperty("App::PropertyAngle","LastAngle","Draft", - "End angle of the dimension") - obj.addProperty("App::PropertyVector","Dimline","Draft", - "Point through which the dimension line passes") - obj.addProperty("App::PropertyVector","Center","Draft", - "The center point of this dimension") - obj.addProperty("App::PropertyVector","Normal","Draft", - "The normal direction of this dimension") - obj.addProperty("App::PropertyLink","Support","Draft", - "The object measured by this dimension") - obj.addProperty("App::PropertyLinkSubList","LinkedGeometry","Draft", - "The geometry this dimension is linked to") + obj.addProperty("App::PropertyAngle","FirstAngle","Draft","Start angle of the dimension") + obj.addProperty("App::PropertyAngle","LastAngle","Draft","End angle of the dimension") + obj.addProperty("App::PropertyVector","Dimline","Draft","Point through which the dimension line passes") + obj.addProperty("App::PropertyVector","Center","Draft","The center point of this dimension") + obj.addProperty("App::PropertyVector","Normal","Draft","The normal direction of this dimension") + obj.addProperty("App::PropertyLink","Support","Draft","The object measured by this dimension") + obj.addProperty("App::PropertyLinkSubList","LinkedGeometry","Draft","The geometry this dimension is linked to") obj.addProperty("App::PropertyAngle","Angle","Draft","The measurement of this dimension") obj.FirstAngle = 0 obj.LastAngle = 90 @@ -3300,14 +3292,14 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): obj.addProperty("App::PropertyLength","ArrowSize","Draft","Arrow size") obj.addProperty("App::PropertyLength","TextSpacing","Draft","The spacing between the text and the dimension line") obj.addProperty("App::PropertyEnumeration","ArrowType","Draft","Arrow type") - obj.addProperty("App::PropertyLength","LineWidth","Draft","Line width") + obj.addProperty("App::PropertyFloat","LineWidth","Draft","Line width") obj.addProperty("App::PropertyColor","LineColor","Draft","Line color") obj.addProperty("App::PropertyBool","FlipArrows","Draft","Rotate the dimension arrows 180 degrees") obj.addProperty("App::PropertyVector","TextPosition","Draft","The position of the text. Leave (0,0,0) for automatic position") obj.addProperty("App::PropertyString","Override","Draft","Text override. Use 'dim' to insert the dimension length") - obj.FontSize=getParam("textheight",0.20) - obj.FontName=getParam("textfont","") - obj.TextSpacing=getParam("dimspacing",0.05) + obj.FontSize = getParam("textheight",0.20) + obj.FontName = getParam("textfont","") + obj.TextSpacing = getParam("dimspacing",0.05) obj.ArrowSize = getParam("arrowsize",0.1) obj.ArrowType = arrowtypes obj.ArrowType = arrowtypes[getParam("dimsymbol",0)] @@ -3410,7 +3402,7 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): # set the arc if m == "3D": # calculate the spacing of the text - spacing = (len(self.string)*obj.ViewObject.FontSize)/8 + spacing = (len(self.string)*obj.ViewObject.FontSize.Value)/8 pts1 = [] cut = None pts2 = [] @@ -3445,7 +3437,7 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): self.trans2.translation.setValue((self.p3.x,self.p3.y,self.p3.z)) self.coord2.point.setValue((self.p3.x,self.p3.y,self.p3.z)) # calculate small chords to make arrows look better - arrowlength = 4*obj.ViewObject.ArrowSize + arrowlength = 4*obj.ViewObject.ArrowSize.Value u1 = (self.circle.valueAt(self.circle.FirstParameter+arrowlength)).sub(self.circle.valueAt(self.circle.FirstParameter)).normalize() u2 = (self.circle.valueAt(self.circle.LastParameter)).sub(self.circle.valueAt(self.circle.LastParameter-arrowlength)).normalize() if hasattr(obj.ViewObject,"FlipArrows"): @@ -3473,7 +3465,7 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): offset = r.multVec(Vector(0,1,0)) if hasattr(obj.ViewObject,"TextSpacing"): - offset = DraftVecUtils.scaleTo(offset,obj.ViewObject.TextSpacing) + offset = DraftVecUtils.scaleTo(offset,obj.ViewObject.TextSpacing.Value) else: offset = DraftVecUtils.scaleTo(offset,0.05) if m == "3D": @@ -3490,9 +3482,9 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): def onChanged(self, vobj, prop): if prop == "FontSize": if hasattr(self,"font"): - self.font.size = vobj.FontSize + self.font.size = vobj.FontSize.Value if hasattr(self,"font3d"): - self.font3d.size = vobj.FontSize*100 + self.font3d.size = vobj.FontSize.Value*100 elif prop == "FontName": if hasattr(self,"font") and hasattr(self,"font3d"): self.font.name = self.font3d.name = str(vobj.FontName) @@ -3512,7 +3504,7 @@ class _ViewProviderAngularDimension(_ViewProviderDraft): # set scale symbol = arrowtypes.index(vobj.ArrowType) - s = vobj.ArrowSize + s = vobj.ArrowSize.Value self.trans1.scaleFactor.setValue((s,s,s)) self.trans2.scaleFactor.setValue((s,s,s)) @@ -3596,40 +3588,33 @@ class _Rectangle(_DraftObject): _DraftObject.__init__(self,obj,"Rectangle") obj.addProperty("App::PropertyDistance","Length","Draft","Length of the rectangle") obj.addProperty("App::PropertyDistance","Height","Draft","Height of the rectange") - obj.addProperty("App::PropertyDistance","FilletRadius","Draft","Radius to use to fillet the corners") - obj.addProperty("App::PropertyDistance","ChamferSize","Draft","Size of the chamfer to give to the corners") + obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners") + obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners") obj.Length=1 obj.Height=1 - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - if prop in ["Length","Height"]: - self.createGeometry(fp) - - def createGeometry(self,fp): - if (fp.Length != 0) and (fp.Height != 0): + def execute(self, obj): + if (obj.Length.Value != 0) and (obj.Height.Value != 0): import Part, DraftGeomUtils - plm = fp.Placement + plm = obj.Placement p1 = Vector(0,0,0) - p2 = Vector(p1.x+fp.Length,p1.y,p1.z) - p3 = Vector(p1.x+fp.Length,p1.y+fp.Height,p1.z) - p4 = Vector(p1.x,p1.y+fp.Height,p1.z) + p2 = Vector(p1.x+obj.Length.Value,p1.y,p1.z) + p3 = Vector(p1.x+obj.Length.Value,p1.y+obj.Height.Value,p1.z) + p4 = Vector(p1.x,p1.y+obj.Height.Value,p1.z) shape = Part.makePolygon([p1,p2,p3,p4,p1]) - if "ChamferSize" in fp.PropertiesList: - if fp.ChamferSize != 0: - w = DraftGeomUtils.filletWire(shape,fp.ChamferSize,chamfer=True) + if "ChamferSize" in obj.PropertiesList: + if obj.ChamferSize.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.ChamferSize.Value,chamfer=True) if w: shape = w - if "FilletRadius" in fp.PropertiesList: - if fp.FilletRadius != 0: - w = DraftGeomUtils.filletWire(shape,fp.FilletRadius) + if "FilletRadius" in obj.PropertiesList: + if obj.FilletRadius.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value) if w: shape = w shape = Part.Face(shape) - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm class _ViewProviderRectangle(_ViewProviderDraft): def __init__(self,vobj): @@ -3642,153 +3627,86 @@ class _Circle(_DraftObject): def __init__(self, obj): _DraftObject.__init__(self,obj,"Circle") - obj.addProperty("App::PropertyAngle","FirstAngle","Draft", - "Start angle of the arc") - obj.addProperty("App::PropertyAngle","LastAngle","Draft", - "End angle of the arc (for a full circle, give it same value as First Angle)") - obj.addProperty("App::PropertyDistance","Radius","Draft", - "Radius of the circle") + obj.addProperty("App::PropertyAngle","FirstAngle","Draft","Start angle of the arc") + obj.addProperty("App::PropertyAngle","LastAngle","Draft","End angle of the arc (for a full circle, give it same value as First Angle)") + obj.addProperty("App::PropertyLength","Radius","Draft","Radius of the circle") - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - if prop in ["Radius","FirstAngle","LastAngle"]: - self.createGeometry(fp) - - def createGeometry(self,fp): + def execute(self, obj): import Part - plm = fp.Placement - shape = Part.makeCircle(fp.Radius,Vector(0,0,0), - Vector(0,0,1),fp.FirstAngle,fp.LastAngle) - if fp.FirstAngle == fp.LastAngle: + plm = obj.Placement + shape = Part.makeCircle(obj.Radius.Value,Vector(0,0,0),Vector(0,0,1),obj.FirstAngle,obj.LastAngle) + if obj.FirstAngle == obj.LastAngle: shape = Part.Wire(shape) shape = Part.Face(shape) - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm class _Ellipse(_DraftObject): "The Circle object" def __init__(self, obj): _DraftObject.__init__(self,obj,"Ellipse") - obj.addProperty("App::PropertyDistance","MinorRadius","Draft", - "The minor radius of the ellipse") - obj.addProperty("App::PropertyDistance","MajorRadius","Draft", - "The major radius of the ellipse") + obj.addProperty("App::PropertyLength","MinorRadius","Draft","The minor radius of the ellipse") + obj.addProperty("App::PropertyLength","MajorRadius","Draft","The major radius of the ellipse") - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - if prop in ["MinorRadius","MajorRadius"]: - self.createGeometry(fp) - - def createGeometry(self,fp): + def execute(self, obj): import Part - plm = fp.Placement - if fp.MajorRadius < fp.MinorRadius: + plm = obj.Placement + if obj.MajorRadius.Value < obj.MinorRadius.Value: msg(translate("Error: Major radius is smaller than the minor radius")) return - if fp.MajorRadius and fp.MinorRadius: - shape = Part.Ellipse(Vector(0,0,0),fp.MajorRadius,fp.MinorRadius).toShape() + if obj.MajorRadius.Value and obj.MinorRadius.Value: + shape = Part.Ellipse(Vector(0,0,0),obj.MajorRadius.Value,obj.MinorRadius.Value).toShape() shape = Part.Wire(shape) shape = Part.Face(shape) - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm class _Wire(_DraftObject): "The Wire object" def __init__(self, obj): _DraftObject.__init__(self,obj,"Wire") - obj.addProperty("App::PropertyVectorList","Points","Draft", - "The vertices of the wire") - obj.addProperty("App::PropertyBool","Closed","Draft", - "If the wire is closed or not") - obj.addProperty("App::PropertyLink","Base","Draft", - "The base object is the wire is formed from 2 objects") - obj.addProperty("App::PropertyLink","Tool","Draft", - "The tool object is the wire is formed from 2 objects") - obj.addProperty("App::PropertyVector","Start","Draft", - "The start point of this line") - obj.addProperty("App::PropertyVector","End","Draft", - "The end point of this line") - obj.addProperty("App::PropertyDistance","FilletRadius","Draft","Radius to use to fillet the corners") - obj.addProperty("App::PropertyDistance","ChamferSize","Draft","Size of the chamfer to give to the corners") + obj.addProperty("App::PropertyVectorList","Points","Draft","The vertices of the wire") + obj.addProperty("App::PropertyBool","Closed","Draft","If the wire is closed or not") + obj.addProperty("App::PropertyLink","Base","Draft","The base object is the wire is formed from 2 objects") + obj.addProperty("App::PropertyLink","Tool","Draft","The tool object is the wire is formed from 2 objects") + obj.addProperty("App::PropertyVector","Start","Draft","The start point of this line") + obj.addProperty("App::PropertyVector","End","Draft","The end point of this line") + obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners") + obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners") obj.Closed = False - def execute(self, fp): - self.createGeometry(fp) - - def updateProps(self,fp): - "sets the start and end properties" - pl = FreeCAD.Placement(fp.Placement) - if len(fp.Points) >= 2: - displayfpstart = pl.multVec(fp.Points[0]) - displayfpend = pl.multVec(fp.Points[-1]) - if fp.Start != displayfpstart: - fp.Start = displayfpstart - if fp.End != displayfpend: - fp.End = displayfpend - if len(fp.Points) > 2: - fp.setEditorMode('Start',2) - fp.setEditorMode('End',2) - - def onChanged(self, fp, prop): - if prop in ["Points","Closed","Base","Tool","FilletRadius"]: - self.createGeometry(fp) - if prop == "Points": - self.updateProps(fp) - elif prop == "Start": - pts = fp.Points - invpl = FreeCAD.Placement(fp.Placement).inverse() - realfpstart = invpl.multVec(fp.Start) - if pts: - if pts[0] != realfpstart: - pts[0] = realfpstart - fp.Points = pts - elif prop == "End": - pts = fp.Points - invpl = FreeCAD.Placement(fp.Placement).inverse() - realfpend = invpl.multVec(fp.End) - if len(pts) > 1: - if pts[-1] != realfpend: - pts[-1] = realfpend - fp.Points = pts - elif prop == "Placement": - self.updateProps(fp) - - def createGeometry(self,fp): + def execute(self, obj): import Part, DraftGeomUtils - plm = fp.Placement - if fp.Base and (not fp.Tool): - if fp.Base.isDerivedFrom("Sketcher::SketchObject"): - shape = fp.Base.Shape.copy() - if fp.Base.Shape.isClosed(): + plm = obj.Placement + if obj.Base and (not obj.Tool): + if obj.Base.isDerivedFrom("Sketcher::SketchObject"): + shape = obj.Base.Shape.copy() + if obj.Base.Shape.isClosed(): shape = Part.Face(shape) - fp.Shape = shape - elif fp.Base and fp.Tool: - if fp.Base.isDerivedFrom("Part::Feature") and fp.Tool.isDerivedFrom("Part::Feature"): - if (not fp.Base.Shape.isNull()) and (not fp.Tool.Shape.isNull()): - sh1 = fp.Base.Shape.copy() - sh2 = fp.Tool.Shape.copy() + obj.Shape = shape + elif obj.Base and obj.Tool: + if obj.Base.isDerivedFrom("Part::Feature") and obj.Tool.isDerivedFrom("Part::Feature"): + if (not obj.Base.Shape.isNull()) and (not obj.Tool.Shape.isNull()): + sh1 = obj.Base.Shape.copy() + sh2 = obj.Tool.Shape.copy() shape = sh1.fuse(sh2) if DraftGeomUtils.isCoplanar(shape.Faces): shape = DraftGeomUtils.concatenate(shape) - fp.Shape = shape + obj.Shape = shape p = [] for v in shape.Vertexes: p.append(v.Point) - if fp.Points != p: fp.Points = p - elif fp.Points: - if fp.Points[0] == fp.Points[-1]: - if not fp.Closed: fp.Closed = True - fp.Points.pop() - if fp.Closed and (len(fp.Points) > 2): - shape = Part.makePolygon(fp.Points+[fp.Points[0]]) - if "FilletRadius" in fp.PropertiesList: - if fp.FilletRadius != 0: - w = DraftGeomUtils.filletWire(shape,fp.FilletRadius) + if obj.Points != p: obj.Points = p + elif obj.Points: + if obj.Points[0] == obj.Points[-1]: + if not obj.Closed: obj.Closed = True + obj.Points.pop() + if obj.Closed and (len(obj.Points) > 2): + shape = Part.makePolygon(obj.Points+[obj.Points[0]]) + if "FilletRadius" in obj.PropertiesList: + if obj.FilletRadius.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value) if w: shape = w try: @@ -3797,8 +3715,8 @@ class _Wire(_DraftObject): pass else: edges = [] - pts = fp.Points[1:] - lp = fp.Points[0] + pts = obj.Points[1:] + lp = obj.Points[0] for p in pts: if not DraftVecUtils.equals(lp,p): edges.append(Part.Line(lp,p).toShape()) @@ -3807,34 +3725,63 @@ class _Wire(_DraftObject): shape = Part.Wire(edges) except: shape = None - if "ChamferSize" in fp.PropertiesList: - if fp.ChamferSize != 0: - w = DraftGeomUtils.filletWire(shape,fp.ChamferSize,chamfer=True) + if "ChamferSize" in obj.PropertiesList: + if obj.ChamferSize.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.ChamferSize.Value,chamfer=True) if w: shape = w - if "FilletRadius" in fp.PropertiesList: - if fp.FilletRadius != 0: - w = DraftGeomUtils.filletWire(shape,fp.FilletRadius) + if "FilletRadius" in obj.PropertiesList: + if obj.FilletRadius.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value) if w: shape = w if shape: - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm + self.onChanged(obj,"Placement") + + def onChanged(self, obj, prop): + if prop == "Start": + pts = obj.Points + invpl = FreeCAD.Placement(obj.Placement).inverse() + realfpstart = invpl.multVec(obj.Start) + if pts: + if pts[0] != realfpstart: + pts[0] = realfpstart + obj.Points = pts + elif prop == "End": + pts = obj.Points + invpl = FreeCAD.Placement(obj.Placement).inverse() + realfpend = invpl.multVec(obj.End) + if len(pts) > 1: + if pts[-1] != realfpend: + pts[-1] = realfpend + obj.Points = pts + elif prop == "Placement": + pl = FreeCAD.Placement(obj.Placement) + if len(obj.Points) >= 2: + displayfpstart = pl.multVec(obj.Points[0]) + displayfpend = pl.multVec(obj.Points[-1]) + if obj.Start != displayfpstart: + obj.Start = displayfpstart + if obj.End != displayfpend: + obj.End = displayfpend + if len(obj.Points) > 2: + obj.setEditorMode('Start',2) + obj.setEditorMode('End',2) + class _ViewProviderWire(_ViewProviderDraft): "A View Provider for the Wire object" def __init__(self, obj): _ViewProviderDraft.__init__(self,obj) - obj.addProperty("App::PropertyBool","EndArrow","Draft", - "Displays a dim symbol at the end of the wire") + obj.addProperty("App::PropertyBool","EndArrow","Draft","Displays a dim symbol at the end of the wire") def attach(self, obj): from pivy import coin self.Object = obj.Object col = coin.SoBaseColor() - col.rgb.setValue(obj.LineColor[0], - obj.LineColor[1], - obj.LineColor[2]) + col.rgb.setValue(obj.LineColor[0],obj.LineColor[1],obj.LineColor[2]) self.coords = coin.SoCoordinate3() self.pt = coin.SoSeparator() self.pt.addChild(col) @@ -3870,49 +3817,42 @@ class _Polygon(_DraftObject): def __init__(self, obj): _DraftObject.__init__(self,obj,"Polygon") obj.addProperty("App::PropertyInteger","FacesNumber","Draft","Number of faces") - obj.addProperty("App::PropertyDistance","Radius","Draft","Radius of the control circle") + obj.addProperty("App::PropertyLength","Radius","Draft","Radius of the control circle") obj.addProperty("App::PropertyEnumeration","DrawMode","Draft","How the polygon must be drawn from the control circle") - obj.addProperty("App::PropertyDistance","FilletRadius","Draft","Radius to use to fillet the corners") - obj.addProperty("App::PropertyDistance","ChamferSize","Draft","Size of the chamfer to give to the corners") + obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners") + obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners") obj.DrawMode = ['inscribed','circumscribed'] obj.FacesNumber = 0 obj.Radius = 1 - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - if prop in ["FacesNumber","Radius","DrawMode"]: - self.createGeometry(fp) - - def createGeometry(self,fp): - if (fp.FacesNumber >= 3) and (fp.Radius > 0): + def execute(self, obj): + if (obj.FacesNumber >= 3) and (obj.Radius.Value > 0): import Part, DraftGeomUtils - plm = fp.Placement - angle = (math.pi*2)/fp.FacesNumber - if fp.DrawMode == 'inscribed': - delta = fp.Radius + plm = obj.Placement + angle = (math.pi*2)/obj.FacesNumber + if obj.DrawMode == 'inscribed': + delta = obj.Radius.Value else: - delta = fp.Radius/math.cos(angle/2) + delta = obj.Radius.Value/math.cos(angle/2) pts = [Vector(delta,0,0)] - for i in range(fp.FacesNumber-1): + for i in range(obj.FacesNumber-1): ang = (i+1)*angle pts.append(Vector(delta*math.cos(ang),delta*math.sin(ang),0)) pts.append(pts[0]) shape = Part.makePolygon(pts) - if "ChamferSize" in fp.PropertiesList: - if fp.ChamferSize != 0: - w = DraftGeomUtils.filletWire(shape,fp.ChamferSize,chamfer=True) + if "ChamferSize" in obj.PropertiesList: + if obj.ChamferSize.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.ChamferSize.Value,chamfer=True) if w: shape = w - if "FilletRadius" in fp.PropertiesList: - if fp.FilletRadius != 0: - w = DraftGeomUtils.filletWire(shape,fp.FilletRadius) + if "FilletRadius" in obj.PropertiesList: + if obj.FilletRadius.Value != 0: + w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value) if w: shape = w shape = Part.Face(shape) - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm class _DrawingView(_DraftObject): "The Draft DrawingView object" @@ -3920,7 +3860,7 @@ class _DrawingView(_DraftObject): _DraftObject.__init__(self,obj,"DrawingView") obj.addProperty("App::PropertyVector","Direction","Shape View","Projection direction") obj.addProperty("App::PropertyFloat","LineWidth","View Style","The width of the lines inside this object") - obj.addProperty("App::PropertyFloat","FontSize","View Style","The size of the texts inside this object") + obj.addProperty("App::PropertyLength","FontSize","View Style","The size of the texts inside this object") obj.addProperty("App::PropertyLink","Source","Base","The linked object") obj.addProperty("App::PropertyEnumeration","FillStyle","View Style","Shape Fill Style") obj.addProperty("App::PropertyEnumeration","LineStyle","View Style","Line Style") @@ -3930,15 +3870,6 @@ class _DrawingView(_DraftObject): obj.FontSize = 12 def execute(self, obj): - if obj.Source: - obj.ViewResult = self.updateSVG(obj) - - def onChanged(self, obj, prop): - if prop in ["X","Y","Scale","LineWidth","FontSize","FillStyle","Direction","LineStyle"]: - obj.ViewResult = self.updateSVG(obj) - - def updateSVG(self, obj): - "encapsulates a svg fragment into a transformation node" result = "" if hasattr(obj,"Source"): if obj.Source: @@ -3952,9 +3883,9 @@ class _DrawingView(_DraftObject): others = [] for o in obj.Source.Group: if o.ViewObject.isVisible(): - svg += getSVG(o,obj.Scale,obj.LineWidth,obj.FontSize,obj.FillStyle,obj.Direction,ls) + svg += getSVG(o,obj.Scale,obj.LineWidth,obj.FontSize.Value,obj.FillStyle,obj.Direction,ls) else: - svg = getSVG(obj.Source,obj.Scale,obj.LineWidth,obj.FontSize,obj.FillStyle,obj.Direction,ls) + svg = getSVG(obj.Source,obj.Scale,obj.LineWidth,obj.FontSize.Value,obj.FillStyle,obj.Direction,ls) result += ' 2): - if fp.Points[0] == fp.Points[-1]: # should not occur, but OCC will crash + if obj.Points: + plm = obj.Placement + if obj.Closed and (len(obj.Points) > 2): + if obj.Points[0] == obj.Points[-1]: # should not occur, but OCC will crash msg(translate('draft', "_BSpline.createGeometry: Closed with same first/last Point. Geometry not updated.\n"), "error") return spline = Part.BSplineCurve() - spline.interpolate(fp.Points, True) + spline.interpolate(obj.Points, True) # DNC: bug fix: convert to face if closed shape = Part.Wire(spline.toShape()) shape = Part.Face(shape) - fp.Shape = shape + obj.Shape = shape else: spline = Part.BSplineCurve() - spline.interpolate(fp.Points, False) - fp.Shape = spline.toShape() - fp.Placement = plm + spline.interpolate(obj.Points, False) + obj.Shape = spline.toShape() + obj.Placement = plm # for compatibility with older versions _ViewProviderBSpline = _ViewProviderWire @@ -4013,55 +3935,35 @@ class _Block(_DraftObject): def __init__(self, obj): _DraftObject.__init__(self,obj,"Block") - obj.addProperty("App::PropertyLinkList","Components","Draft", - "The components of this block") + obj.addProperty("App::PropertyLinkList","Components","Draft","The components of this block") - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - if prop in ["Components"]: - self.createGeometry(fp) - - def createGeometry(self,fp): + def execute(self, obj): import Part - plm = fp.Placement + plm = obj.Placement shps = [] - for c in fp.Components: + for c in obj.Components: shps.append(c.Shape) if shps: shape = Part.makeCompound(shps) - fp.Shape = shape - fp.Placement = plm + obj.Shape = shape + obj.Placement = plm class _Shape2DView(_DraftObject): "The Shape2DView object" def __init__(self,obj): - obj.addProperty("App::PropertyLink","Base","Draft", - "The base object this 2D view must represent") - obj.addProperty("App::PropertyVector","Projection","Draft", - "The projection vector of this object") - obj.addProperty("App::PropertyEnumeration","ProjectionMode","Draft", - "The way the viewed object must be projected") - obj.addProperty("App::PropertyIntegerList","FaceNumbers","Draft", - "The indices of the faces to be projected in Individual Faces mode") - obj.addProperty("App::PropertyBool","HiddenLines","Draft", - "Show hidden lines") - obj.addProperty("App::PropertyBool","Tessellation","Draft", "Tessellate BSplines into line segments using number of spline poles") + obj.addProperty("App::PropertyLink","Base","Draft","The base object this 2D view must represent") + obj.addProperty("App::PropertyVector","Projection","Draft","The projection vector of this object") + obj.addProperty("App::PropertyEnumeration","ProjectionMode","Draft","The way the viewed object must be projected") + obj.addProperty("App::PropertyIntegerList","FaceNumbers","Draft","The indices of the faces to be projected in Individual Faces mode") + obj.addProperty("App::PropertyBool","HiddenLines","Draft","Show hidden lines") + obj.addProperty("App::PropertyBool","Tessellation","Draft","Tessellate BSplines into line segments using number of spline poles") obj.Projection = Vector(0,0,1) obj.ProjectionMode = ["Solid","Individual Faces","Cutlines"] obj.HiddenLines = False obj.Tessellation = True _DraftObject.__init__(self,obj,"Shape2DView") - def execute(self,obj): - self.createGeometry(obj) - - def onChanged(self,obj,prop): - if prop in ["Projection","Base","ProjectionMode","FaceNumbers"]: - self.createGeometry(obj) - def getProjected(self,obj,shape,direction): "returns projected edges from a shape and a direction" import Part,Drawing,DraftGeomUtils @@ -4080,7 +3982,7 @@ class _Shape2DView(_DraftObject): else: return DraftGeomUtils.cleanProjection(Part.makeCompound(edges)) - def createGeometry(self,obj): + def execute(self,obj): import DraftGeomUtils pl = obj.Placement if obj.Base: @@ -4154,30 +4056,18 @@ class _Array(_DraftObject): def __init__(self,obj): _DraftObject.__init__(self,obj,"Array") - obj.addProperty("App::PropertyLink","Base","Draft", - "The base object that must be duplicated") - obj.addProperty("App::PropertyEnumeration","ArrayType","Draft", - "The type of array to create") - obj.addProperty("App::PropertyVector","Axis","Draft", - "The axis direction") - obj.addProperty("App::PropertyInteger","NumberX","Draft", - "Number of copies in X direction") - obj.addProperty("App::PropertyInteger","NumberY","Draft", - "Number of copies in Y direction") - obj.addProperty("App::PropertyInteger","NumberZ","Draft", - "Number of copies in Z direction") - obj.addProperty("App::PropertyInteger","NumberPolar","Draft", - "Number of copies") - obj.addProperty("App::PropertyVector","IntervalX","Draft", - "Distance and orientation of intervals in X direction") - obj.addProperty("App::PropertyVector","IntervalY","Draft", - "Distance and orientation of intervals in Y direction") - obj.addProperty("App::PropertyVector","IntervalZ","Draft", - "Distance and orientation of intervals in Z direction") - obj.addProperty("App::PropertyVector","Center","Draft", - "Center point") - obj.addProperty("App::PropertyAngle","Angle","Draft", - "Angle to cover with copies") + obj.addProperty("App::PropertyLink","Base","Draft","The base object that must be duplicated") + obj.addProperty("App::PropertyEnumeration","ArrayType","Draft","The type of array to create") + obj.addProperty("App::PropertyVector","Axis","Draft","The axis direction") + obj.addProperty("App::PropertyInteger","NumberX","Draft","Number of copies in X direction") + obj.addProperty("App::PropertyInteger","NumberY","Draft","Number of copies in Y direction") + obj.addProperty("App::PropertyInteger","NumberZ","Draft","Number of copies in Z direction") + obj.addProperty("App::PropertyInteger","NumberPolar","Draft","Number of copies") + obj.addProperty("App::PropertyVector","IntervalX","Draft","Distance and orientation of intervals in X direction") + obj.addProperty("App::PropertyVector","IntervalY","Draft","Distance and orientation of intervals in Y direction") + obj.addProperty("App::PropertyVector","IntervalZ","Draft","Distance and orientation of intervals in Z direction") + obj.addProperty("App::PropertyVector","Center","Draft","Center point") + obj.addProperty("App::PropertyAngle","Angle","Draft","Angle to cover with copies") obj.ArrayType = ['ortho','polar'] obj.NumberX = 1 obj.NumberY = 1 @@ -4189,9 +4079,6 @@ class _Array(_DraftObject): obj.Angle = 360 obj.Axis = Vector(0,0,1) - def execute(self,obj): - self.createGeometry(obj) - def onChanged(self,obj,prop): if prop == "ArrayType": if obj.ViewObject: @@ -4217,11 +4104,8 @@ class _Array(_DraftObject): obj.ViewObject.setEditorMode('IntervalX',2) obj.ViewObject.setEditorMode('IntervalY',2) obj.ViewObject.setEditorMode('IntervalZ',2) - if prop in ["ArrayType","NumberX","NumberY","NumberZ","NumberPolar", - "IntervalX","IntervalY","IntervalZ","Angle","Center","Axis"]: - self.createGeometry(obj) - def createGeometry(self,obj): + def execute(self,obj): import DraftGeomUtils if obj.Base: pl = obj.Placement @@ -4281,16 +4165,11 @@ class _PathArray(_DraftObject): def __init__(self,obj): _DraftObject.__init__(self,obj,"PathArray") - obj.addProperty("App::PropertyLink","Base","Draft", - "The base object that must be duplicated") - obj.addProperty("App::PropertyLink","PathObj","Draft", - "The path object along which to distribute objects") - obj.addProperty("App::PropertyLinkSubList","PathSubs","Draft", - "Selected subobjects (edges) of PathObj") - obj.addProperty("App::PropertyInteger","Count","Draft", - "Number of copies") - obj.addProperty("App::PropertyVector","Xlate","Draft", - "Optional translation vector") + obj.addProperty("App::PropertyLink","Base","Draft","The base object that must be duplicated") + obj.addProperty("App::PropertyLink","PathObj","Draft","The path object along which to distribute objects") + obj.addProperty("App::PropertyLinkSubList","PathSubs","Draft","Selected subobjects (edges) of PathObj") + obj.addProperty("App::PropertyInteger","Count","Draft","Number of copies") + obj.addProperty("App::PropertyVector","Xlate","Draft","Optional translation vector") obj.addProperty("App::PropertyBool","Align","Draft","Orientation of Base along path") obj.Count = 2 obj.PathSubs = [] @@ -4298,13 +4177,6 @@ class _PathArray(_DraftObject): obj.Align = False def execute(self,obj): - self.createGeometry(obj) - - def onChanged(self,obj,prop): - if prop in ["Count","Xlate","Align"]: - self.createGeometry(obj) - - def createGeometry(self,obj): import FreeCAD import Part import DraftGeomUtils @@ -4449,30 +4321,30 @@ class _Point(_DraftObject): mode = 2 obj.setEditorMode('Placement',mode) - def execute(self, fp): + def execute(self, obj): import Part - shape = Part.Vertex(Vector(fp.X,fp.Y,fp.Z)) - fp.Shape = shape + shape = Part.Vertex(Vector(obj.X,obj.Y,obj.Z)) + obj.Shape = shape class _ViewProviderPoint(_ViewProviderDraft): "A viewprovider for the Draft Point object" def __init__(self, obj): _ViewProviderDraft.__init__(self,obj) - def onChanged(self, vp, prop): + def onChanged(self, vobj, prop): mode = 2 - vp.setEditorMode('LineColor',mode) - vp.setEditorMode('LineWidth',mode) - vp.setEditorMode('BoundingBox',mode) - vp.setEditorMode('ControlPoints',mode) - vp.setEditorMode('Deviation',mode) - vp.setEditorMode('DiffuseColor',mode) - vp.setEditorMode('DisplayMode',mode) - vp.setEditorMode('Lighting',mode) - vp.setEditorMode('LineMaterial',mode) - vp.setEditorMode('ShapeColor',mode) - vp.setEditorMode('ShapeMaterial',mode) - vp.setEditorMode('Transparency',mode) + vobj.setEditorMode('LineColor',mode) + vobj.setEditorMode('LineWidth',mode) + vobj.setEditorMode('BoundingBox',mode) + vobj.setEditorMode('ControlPoints',mode) + vobj.setEditorMode('Deviation',mode) + vobj.setEditorMode('DiffuseColor',mode) + vobj.setEditorMode('DisplayMode',mode) + vobj.setEditorMode('Lighting',mode) + vobj.setEditorMode('LineMaterial',mode) + vobj.setEditorMode('ShapeColor',mode) + vobj.setEditorMode('ShapeMaterial',mode) + vobj.setEditorMode('Transparency',mode) def getIcon(self): return ":/icons/Draft_Dot.svg" @@ -4482,20 +4354,11 @@ class _Clone(_DraftObject): def __init__(self,obj): _DraftObject.__init__(self,obj,"Clone") - obj.addProperty("App::PropertyLinkList","Objects","Draft", - "The objects included in this scale object") - obj.addProperty("App::PropertyVector","Scale","Draft", - "The scale vector of this object") + obj.addProperty("App::PropertyLinkList","Objects","Draft","The objects included in this scale object") + obj.addProperty("App::PropertyVector","Scale","Draft","The scale vector of this object") obj.Scale = Vector(1,1,1) def execute(self,obj): - self.createGeometry(obj) - - def onChanged(self,obj,prop): - if prop in ["Scale","Objects"]: - self.createGeometry(obj) - - def createGeometry(self,obj): import Part, DraftGeomUtils pl = obj.Placement shapes = [] @@ -4545,28 +4408,22 @@ class _ShapeString(_DraftObject): obj.addProperty("App::PropertyInteger","Tracking","Draft", "Inter-character spacing") - def execute(self, fp): - self.createGeometry(fp) - - def onChanged(self, fp, prop): - pass - - def createGeometry(self,fp): + def execute(self, obj): import Part # import OpenSCAD2Dgeom import os - if fp.String and fp.FontFile: - if fp.Placement: - plm = fp.Placement + if obj.String and obj.FontFile: + if obj.Placement: + plm = obj.Placement # TODO: os.path.splitunc() for Win/Samba net files? - head, tail = os.path.splitdrive(fp.FontFile) # os.path.splitdrive() for Win + head, tail = os.path.splitdrive(obj.FontFile) # os.path.splitdrive() for Win head, tail = os.path.split(tail) head = head + '/' # os.split drops last '/' from head - CharList = Part.makeWireString(fp.String, + CharList = Part.makeWireString(obj.String, head, tail, - fp.Size, - fp.Tracking) + obj.Size, + obj.Tracking) SSChars = [] for char in CharList: CharFaces = [] @@ -4581,9 +4438,9 @@ class _ShapeString(_DraftObject): s = self.makeFaces(char) SSChars.append(s) shape = Part.Compound(SSChars) - fp.Shape = shape + obj.Shape = shape if plm: - fp.Placement = plm + obj.Placement = plm def makeFaces(self, wireChar): import Part