(I've adjusted the subject line to reflect more recent content)
wmayer wrote: ↑Tue May 14, 2019 6:28 am
... Shape revolve() uses BRepPrimAPI_MakeRevol that accepts a shape as input and Part.makeRevolution() accepts a GeomCurve.
BRepPrimAPI_MakeRevol is the more advanced method because it accepts a wider range of objects:
- for a vertex it creates an edge
- for an edge it creates a face
- for a wire it creates a shell
- for a face it creates a solid
- for a shell it creates a compound solid
[Using FreeCAD 0.18.1 and 0.19 16786 (Git) on Mint 18.1, python 2]
I've been working through examples of all of these, trying to get to a solid sphere at the end. I have had luck with Part.makeRevolution(), and revolve 1/ (but fails trying to revolve a circle), 2/ (with some possible bugs), and 3/. For 4/ and 5/ either there are some bugs, or I misunderstand something, or both.
There are two general sorts of problems. One is that revolving a disk around an axis across its plane should result in a sphere, and it does not. The other is that closed objects are not always being identified as such. That is, constructions that should give closed objects, and appear to achieve that, do not report that the object is closed.
Code: Select all
import Part
from FreeCAD import Vector
o = Vector(0,0,0)
x = Vector(1,0,0)
y = Vector(0,1,0)
z = Vector(0,0,1)
arc = Part.Arc(-10*z, 10*x, 10*z)
arcShapeEdge = arc.toShape()
arcShapeEdge.ShapeType #Edge
arcShapeWire = Part.Wire(arcShapeEdge)
arcShapeWire.ShapeType #Wire
0/ Part.makeRevolution works to give a solid
Code: Select all
s0 =Part.makeRevolution(arc, arc.FirstParameter, arc.LastParameter,
360, o, z, Part.Solid)
Part.show(s0)
s0.ShapeType #Solid
s0.isClosed() #True
s0.isValid() #True
1/ for a vertex it creates an edge.
This works to get to a solid if the vertex is rotated 180 degrees to give a half circle, and that is rotated 360 degrees to give a sphere:
Code: Select all
zp = Part.Point(Vector(10,0,0)).toShape()
zp.ShapeType #Vertex
s1 = Part.makeSolid(Part.makeShell([zp.revolve(o,z,180).revolve(o, x, 360)]))
Part.show(s1)
s1.ShapeType #Solid
s1.isClosed() #True
s1.isValid() #True
It fails if the rotations are 360 first then 180. This is possibly because of the issue mentioned in the revolve doc, that rotation works best about an axis that goes though vertexes. However, the problem here is more than anomolies suggested in the doc. It fails totally:
Code: Select all
#revolve point to get circle (Edge)
zc =zp.revolve(o,z,360)
zc.ShapeType #Edge
zc.isClosed() #True
zc.isValid() #True
#revolve Edge to get sphere (Face). Does not work, around neither x nor y axis.
#zs = zc.revolve(o, y, 180)
zs = zc.revolve(o, x, 180)
zs.ShapeType #Face
zs.isClosed() #False
zs.isValid() #False
Part.show(zs) # shows nothing
2/ for an edge it creates a face.
This works to get to a solid (but isClosed() seems wrong):
Code: Select all
zz = arcShapeEdge.revolve(o, z, 360)
Part.show(zz)
zz.ShapeType #Face
zz.isClosed() #False #Looks like a BUG. The face is the closed surface of a sphere.
zz.isValid() #True
s2 = Part.makeSolid(Part.makeShell([zz]))
s2.ShapeType #Solid
s2.isClosed() #True
s2.isValid() #True
len(s2.Solids) # 1
Part.show(s2)
3/ for a wire it creates a shell.
This works to get to a solid:
Code: Select all
ar = arcShapeWire.revolve(o, z, 360)
ar.ShapeType #Shell
ar.isClosed() #True
ar.isValid() #True
s3 = Part.makeSolid(ar)
Part.show(s3)
s3.ShapeType #Solid
s3.isClosed() #True
s3.isValid() #True
len(s3.Solids) # 1
4/ for a face it creates a solid
Code: Select all
zC = Part.Face(Part.Wire(Part.Circle(o,z,10).toShape()))
Part.show(zC) # closed disk
zC.ShapeType #Face
zC.isClosed() #False (BUG I think) Maybe the source of following problems
zC.isValid() #True
s4 =zC.revolve(o, x, 180) # x or y should work, but next fails for both
s4.ShapeType #Solid
s4.isClosed() #True
s4.isValid() #False no doubt this indicates a problem
Part.show(s4) # BUG still a flat disk
#try with a closed outline
zC = Part.Shape([arc, Part.LineSegment(-10*z, 10*z)])
zC.ShapeType #Compound
zC.isClosed() #False # BUG this should be closed
zC.isValid() #True
zF = Part.makeFilledFace(zC) #Error creating object
s4a =zC.revolve(o, z, 360)
s4a.ShapeType #Compound
s4a.isClosed() #False
s4a.isValid() #True
Part.show(s4a) # looks like a sphere but hollow
Part.show(s4a.cut(Part.makeBox(10,10,10)) ) #cutout shows hollow
s4b = Part.makeSolid(s4a) #Part.OCCError: Creation of solid failed: No shells or compsolids found in shape
s4b = Part.Solid(s4a) #Part.OCCError: Creation of solid failed: No shells or compsolids found in shape
5/ for a shell it creates a compound solid
This fails
Code: Select all
Part.makeShell(Part.Face(Part.Wire(Part.Circle(o,z,10).toShape())))
#TypeError: PyCXX: Error creating object
but this works
Code: Select all
z5 = Part.makeShell([Part.Face(Part.Wire(Part.Circle(o,z,10).toShape()))])
z5.ShapeType #Shell
z5.isClosed() #False seems like a BUG. This is a closed disk
z5.isValid() #True
Part.show(z5) # displays closed disk
However, revolving around x or y give the same bad result.
(Revolves ok around z but that just gives a CompSolid but disk still.)
Code: Select all
s5 = z5.revolve(o, x, 180)
s5.ShapeType #'CompSolid
s5.isClosed() #True
s5.isValid() #False
Part.show(s5) # displays a disk, as if rotating around z BUG?