Stretching shapes
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Stretching shapes
Hi,
I would like to make a shape that is a circle in the bottom and an ellipse on the top. I thought of making it by making a cylinder and then stretching one of its faces in one direction, but I don't seem to find that option. How would you use FreeCAD to make this shape? Thanks very much in advance. JR
I would like to make a shape that is a circle in the bottom and an ellipse on the top. I thought of making it by making a cylinder and then stretching one of its faces in one direction, but I don't seem to find that option. How would you use FreeCAD to make this shape? Thanks very much in advance. JR
Re: Stretching shapes
With the GUI you currently can't do it but it's possible via Python scripting. Here is the code snippet you can use:
As you can see the trick to make an ellipse is by stretching a circle and to make the surface is done by makeLoft().
Code: Select all
import Part
from FreeCAD import Base
c=Part.makeCircle(5.0,Base.Vector(0,0,0))
e=Part.makeCircle(5.0,Base.Vector(0,0,10))
m=Base.Matrix()
m.A11=2.0
e=e.transformGeometry(m)
cw=Part.Wire(c)
ew=Part.Wire(e)
l=Part.makeLoft([cw,ew])
Part.show(l)
Re: Stretching shapes
wmayer,
Thank you very much. How do I make this surface into a filled solid? I tried for a bit using the makeSolid command from the Part API (http://sourceforge.net/apps/mediawiki/f ... e=Part_API) but I wasn't able to get it.
JR
Thank you very much. How do I make this surface into a filled solid? I tried for a bit using the makeSolid command from the Part API (http://sourceforge.net/apps/mediawiki/f ... e=Part_API) but I wasn't able to get it.
JR
Re: Stretching shapes
Code: Select all
import Part
from FreeCAD import Base
c=Part.makeCircle(5.0,Base.Vector(0,0,0))
e=Part.makeCircle(5.0,Base.Vector(0,0,10))
m=Base.Matrix()
m.A11=2.0
bot=Part.Face(Part.Wire(c))
top=Part.Face(Part.Wire(e))
top=Part.Face(top.transformGeometry(m))
e=e.transformGeometry(m)
cw=Part.Wire(c)
ew=Part.Wire(e)
l=Part.makeLoft([cw,ew])
shell=Part.Shell(l.Faces)
shell.add(top)
shell.add(bot)
solid=Part.Solid(shell)
Part.show(solid)
Re: Stretching shapes
The loft function of our cad kernel also offers a parameter to build directly a solid. So, I have now added an optional parameter (default: False) to makeLoft() to create directly the solid. This change will be available with the next release, then.
Re: Stretching shapes
Excellent, thank you very much. Thanks for the feature addition too.
Re: Stretching shapes
Hi Werner,wmayer wrote:I have now added an optional parameter (default: False) to makeLoft() to create directly the solid. This change will be available with the next release, then.
How do we set the parameter to true in Python to create the solid directly?
Thanks!
Re: Stretching shapes
wmayer,
The solid you made from the stretched circle and the normal circle works pretty well when trying to apply boolean operations (cut, fuse, common, ...etc.). I tried my own version of that, trying to make a solid between a circle and a rectangle, and while it looks pretty swell, it will not work for boolean operations, so there must be something wrong with it. Is there something I am missing? Or I am just asking the loft/solid commands too much? Thank you very much. Here is my version of your code:
The solid you made from the stretched circle and the normal circle works pretty well when trying to apply boolean operations (cut, fuse, common, ...etc.). I tried my own version of that, trying to make a solid between a circle and a rectangle, and while it looks pretty swell, it will not work for boolean operations, so there must be something wrong with it. Is there something I am missing? Or I am just asking the loft/solid commands too much? Thank you very much. Here is my version of your code:
Code: Select all
import Part
from FreeCAD import Base
# make a circle and a rectangle
c=Part.makeCircle(5.0,Base.Vector(0,0,0))
e=Part.makePolygon([Base.Vector(-8,-2,-8),Base.Vector(8,-2,-8),Base.Vector(8,2,-8),Base.Vector(-8,2,-8),Base.Vector(-8,-2,-8)])
# make shapes into wires
cw=Part.Wire(c)
ew=Part.Wire(e)
# make faces from wires
bot=Part.Face(cw)
top=Part.Face(ew)
# make loft
l=Part.makeLoft([cw,ew])
# make shell from loft's faces
shell=Part.Shell(l.Faces)
# add top and bottom to make closed shell
shell.add(top)
shell.add(bot)
# make into a solid and close
solid=Part.Solid(shell)
Part.show(solid)
Re: Stretching shapes
normandc wrote:Hi Werner,wmayer wrote:I have now added an optional parameter (default: False) to makeLoft() to create directly the solid. This change will be available with the next release, then.
How do we set the parameter to true in Python to create the solid directly?
Thanks!
Code: Select all
import Part
from FreeCAD import Base
c=Part.makeCircle(5.0,Base.Vector(0,0,0))
e=Part.makeCircle(5.0,Base.Vector(0,0,10))
m=Base.Matrix()
m.A11=2.0
e=e.transformGeometry(m)
cw=Part.Wire(c)
ew=Part.Wire(e)
l=Part.makeLoft([cw,ew],True) ## <<<============
shell=Part.Shell(l.Faces)
solid=Part.Solid(shell)
Part.show(solid)
Re: Stretching shapes
Indeed your shape is broken. When selecting the object and setting "Lightning" to "One side" in the property editor you'll see that your shape is inverted, i.e. it has the wrong orientation and thus appears black. Since boolean operations must rely on a proper orientation it will (often) fail if it's incorrect. To fix this just call this additional line:The solid you made from the stretched circle and the normal circle works pretty well when trying to apply boolean operations (cut, fuse, common, ...etc.). I tried my own version of that, trying to make a solid between a circle and a rectangle, and while it looks pretty swell, it will not work for boolean operations, so there must be something wrong with it. Is there something I am missing? Or I am just asking the loft/solid commands too much? Thank you very much. Here is my version of your code:
Code: Select all
solid.reverse()