diff --git a/src/Mod/PartDesign/App/BodyPy.xml b/src/Mod/PartDesign/App/BodyPy.xml index 59e9bb5ef8..55326a1d35 100644 --- a/src/Mod/PartDesign/App/BodyPy.xml +++ b/src/Mod/PartDesign/App/BodyPy.xml @@ -32,7 +32,7 @@ Return the visible feature of this body - + diff --git a/src/Mod/PartDesign/PartDesign_Model.xml b/src/Mod/PartDesign/PartDesign_Model.xml index 5ba82edd94..acaa07c747 100644 --- a/src/Mod/PartDesign/PartDesign_Model.xml +++ b/src/Mod/PartDesign/PartDesign_Model.xml @@ -1,16 +1,16 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/Mod/PartDesign/Scripts/DistanceBolt.py b/src/Mod/PartDesign/Scripts/DistanceBolt.py index a7eece80cc..46db12ff8b 100644 --- a/src/Mod/PartDesign/Scripts/DistanceBolt.py +++ b/src/Mod/PartDesign/Scripts/DistanceBolt.py @@ -12,53 +12,53 @@ import FreeCAD, Part, math from FreeCAD import Base class DistanceBolt: - def __init__(self, obj): - ''' Add the properties: Length, Edges, Radius, Height ''' - obj.addProperty("App::PropertyInteger","Edges","Bolt","Number of edges of the outline").Edges=6 - obj.addProperty("App::PropertyLength","Length","Bolt","Length of the edges of the outline").Length=10.0 - obj.addProperty("App::PropertyLength","Radius","Bolt","Radius of the inner circle").Radius=4.0 - obj.addProperty("App::PropertyLength","Height","Bolt","Height of the extrusion").Height=20.0 - obj.Proxy = self + def __init__(self, obj): + ''' Add the properties: Length, Edges, Radius, Height ''' + obj.addProperty("App::PropertyInteger","Edges","Bolt","Number of edges of the outline").Edges=6 + obj.addProperty("App::PropertyLength","Length","Bolt","Length of the edges of the outline").Length=10.0 + obj.addProperty("App::PropertyLength","Radius","Bolt","Radius of the inner circle").Radius=4.0 + obj.addProperty("App::PropertyLength","Height","Bolt","Height of the extrusion").Height=20.0 + obj.Proxy = self - def onChanged(self, fp, prop): - if prop == "Edges" or prop == "Length" or prop == "Radius" or prop == "Height": - self.execute(fp) + def onChanged(self, fp, prop): + if prop == "Edges" or prop == "Length" or prop == "Radius" or prop == "Height": + self.execute(fp) - def execute(self, fp): - edges = fp.Edges - if edges < 3: - edges = 3 - length = fp.Length - radius = fp.Radius - height = fp.Height + def execute(self, fp): + edges = fp.Edges + if edges < 3: + edges = 3 + length = fp.Length + radius = fp.Radius + height = fp.Height - m=Base.Matrix() - m.rotateZ(math.radians(360.0/edges)) + m=Base.Matrix() + m.rotateZ(math.radians(360.0/edges)) - # create polygon - polygon = [] - v=Base.Vector(length,0,0) - for i in range(edges): - polygon.append(v) - v = m.multiply(v) - polygon.append(v) - wire = Part.makePolygon(polygon) + # create polygon + polygon = [] + v=Base.Vector(length,0,0) + for i in range(edges): + polygon.append(v) + v = m.multiply(v) + polygon.append(v) + wire = Part.makePolygon(polygon) - # create circle - circ=Part.makeCircle(radius) + # create circle + circ=Part.makeCircle(radius) - # Create the face with the polygon as outline and the circle as hole - face=Part.Face([wire,Part.Wire(circ)]) + # Create the face with the polygon as outline and the circle as hole + face=Part.Face([wire,Part.Wire(circ)]) - # Extrude in z to create the final solid - extrude=face.extrude(Base.Vector(0,0,height)) - fp.Shape = extrude + # Extrude in z to create the final solid + extrude=face.extrude(Base.Vector(0,0,height)) + fp.Shape = extrude def makeDistanceBolt(): - doc = FreeCAD.activeDocument() - if doc is None: - doc = FreeCAD.newDocument() - bolt=doc.addObject("Part::FeaturePython","Distance_Bolt") - bolt.Label = "Distance bolt" - DistanceBolt(bolt) - bolt.ViewObject.Proxy=0 + doc = FreeCAD.activeDocument() + if doc is None: + doc = FreeCAD.newDocument() + bolt=doc.addObject("Part::FeaturePython","Distance_Bolt") + bolt.Label = "Distance bolt" + DistanceBolt(bolt) + bolt.ViewObject.Proxy=0 diff --git a/src/Mod/PartDesign/Scripts/Parallelepiped.py b/src/Mod/PartDesign/Scripts/Parallelepiped.py index 37192171e2..205b7ffe79 100644 --- a/src/Mod/PartDesign/Scripts/Parallelepiped.py +++ b/src/Mod/PartDesign/Scripts/Parallelepiped.py @@ -12,77 +12,77 @@ import FreeCAD, Part, math from FreeCAD import Base class Parallelepiped: - def __init__(self, obj): - ''' Add the properties: Length, Edges, Radius, Height ''' - obj.addProperty("App::PropertyVector","A","Parallelepiped","Vector").A=Base.Vector(1,0,0) - obj.addProperty("App::PropertyVector","B","Parallelepiped","Vector").B=Base.Vector(0,1,0) - obj.addProperty("App::PropertyVector","C","Parallelepiped","Vector").C=Base.Vector(0,0,1) - obj.Proxy = self + def __init__(self, obj): + ''' Add the properties: Length, Edges, Radius, Height ''' + obj.addProperty("App::PropertyVector","A","Parallelepiped","Vector").A=Base.Vector(1,0,0) + obj.addProperty("App::PropertyVector","B","Parallelepiped","Vector").B=Base.Vector(0,1,0) + obj.addProperty("App::PropertyVector","C","Parallelepiped","Vector").C=Base.Vector(0,0,1) + obj.Proxy = self - def onChanged(self, fp, prop): - if prop == "A" or prop == "B" or prop == "C": - self.execute(fp) + def onChanged(self, fp, prop): + if prop == "A" or prop == "B" or prop == "C": + self.execute(fp) - def execute(self, fp): - a = fp.A - b = fp.B - c = fp.C + def execute(self, fp): + a = fp.A + b = fp.B + c = fp.C - m=Base.Matrix() - m.A11=a.x - m.A12=a.y - m.A13=a.z - m.A21=b.x - m.A22=b.y - m.A23=b.z - m.A31=c.x - m.A32=c.y - m.A33=c.z - box = Part.makeBox(1,1,1) - fp.Shape = box.transformGeometry(m) + m=Base.Matrix() + m.A11=a.x + m.A12=a.y + m.A13=a.z + m.A21=b.x + m.A22=b.y + m.A23=b.z + m.A31=c.x + m.A32=c.y + m.A33=c.z + box = Part.makeBox(1,1,1) + fp.Shape = box.transformGeometry(m) class BoxCylinder: - def __init__(self, obj): - obj.addProperty("App::PropertyFloat","Length","BoxCylinder","Length").Length=10.0 - obj.addProperty("App::PropertyFloat","Width","BoxCylinder","Width").Width=10.0 - obj.addProperty("App::PropertyLink","Source","BoxCylinder","Source").Source=None - obj.Proxy = self + def __init__(self, obj): + obj.addProperty("App::PropertyFloat","Length","BoxCylinder","Length").Length=10.0 + obj.addProperty("App::PropertyFloat","Width","BoxCylinder","Width").Width=10.0 + obj.addProperty("App::PropertyLink","Source","BoxCylinder","Source").Source=None + obj.Proxy = self - def onChanged(self, fp, prop): - if prop == "Length" or prop == "Width": - self.execute(fp) + def onChanged(self, fp, prop): + if prop == "Length" or prop == "Width": + self.execute(fp) - def execute(self, fp): - FreeCAD.Console.PrintMessage(str(fp.Source)+"\n") - if fp.Source is None: - return - r = fp.Source.Radius - l = fp.Length - w = fp.Width - h = 2*r+10 - fp.Shape = Part.makeBox(l,w,h) + def execute(self, fp): + FreeCAD.Console.PrintMessage(str(fp.Source)+"\n") + if fp.Source is None: + return + r = fp.Source.Radius + l = fp.Length + w = fp.Width + h = 2*r+10 + fp.Shape = Part.makeBox(l,w,h) def makeParallelepiped(): - doc = FreeCAD.activeDocument() - if doc is None: - doc = FreeCAD.newDocument() - obj=doc.addObject("Part::FeaturePython","Parallelepiped") - obj.Label = "Parallelepiped" - Parallelepiped(obj) - obj.ViewObject.Proxy=0 + doc = FreeCAD.activeDocument() + if doc is None: + doc = FreeCAD.newDocument() + obj=doc.addObject("Part::FeaturePython","Parallelepiped") + obj.Label = "Parallelepiped" + Parallelepiped(obj) + obj.ViewObject.Proxy=0 def makeBoxCylinder(): - doc = FreeCAD.activeDocument() - if doc is None: - doc = FreeCAD.newDocument() - cyl=doc.addObject("Part::Cylinder","Cylinder") - cyl.Radius=16.0 - cyl.Height=800.0 - obj=doc.addObject("Part::FeaturePython","Box") - BoxCylinder(obj) - obj.Source=cyl - obj.Length=800.0 - obj.Width=600.0 - obj.ViewObject.Proxy=0 - doc.recompute() + doc = FreeCAD.activeDocument() + if doc is None: + doc = FreeCAD.newDocument() + cyl=doc.addObject("Part::Cylinder","Cylinder") + cyl.Radius=16.0 + cyl.Height=800.0 + obj=doc.addObject("Part::FeaturePython","Box") + BoxCylinder(obj) + obj.Source=cyl + obj.Length=800.0 + obj.Width=600.0 + obj.ViewObject.Proxy=0 + doc.recompute()