PartDesign: convert indentations to spaces
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<Documentation>
|
||||
<UserDocu>Return the visible feature of this body</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="VisibleFeature" Type="Object" />
|
||||
<Parameter Name="VisibleFeature" Type="Object" />
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<Module Name="PartDesign">
|
||||
<Content>
|
||||
<Feature Name="Box">
|
||||
<Documentation><Author EMail="juergen.riegel@web.de" Name="Juergen Riegel"/></Documentation>
|
||||
<Property Type="App::PropertyDistance" Name="Length"/>
|
||||
<Property Type="App::PropertyDistance" Name="Height"/>
|
||||
<Property Type="App::PropertyDistance" Name="Width"/>
|
||||
<ViewProvider>
|
||||
<Property Type="App::PropertyInt" Name="VisMode"></Property>
|
||||
</ViewProvider>
|
||||
</Feature>
|
||||
</Content>
|
||||
</Module>
|
||||
<Module Name="PartDesign">
|
||||
<Content>
|
||||
<Feature Name="Box">
|
||||
<Documentation><Author EMail="juergen.riegel@web.de" Name="Juergen Riegel"/></Documentation>
|
||||
<Property Type="App::PropertyDistance" Name="Length"/>
|
||||
<Property Type="App::PropertyDistance" Name="Height"/>
|
||||
<Property Type="App::PropertyDistance" Name="Width"/>
|
||||
<ViewProvider>
|
||||
<Property Type="App::PropertyInt" Name="VisMode"></Property>
|
||||
</ViewProvider>
|
||||
</Feature>
|
||||
</Content>
|
||||
</Module>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user