coil spring and helix
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
coil spring and helix
Werner added into PartDesing/Scripts Spring and Epitrochoid examples I see...
Re: Show your FreeCAD projects here!
I just checked it out (as in both svn and literally ) and they are coolkwahooo wrote:Werner added into PartDesing/Scripts Spring and Epitrochoid examples I see...
Jim
Re: Show your FreeCAD projects here!
Full credit to the Kwahooo spring, this is an example of how easy it is to extend/modify something after someone has done all the hard work of creating the first version.
I have made a loop of pipe by creating two springs and subtracting one from the other.
Jim
A jpeg, just delete ".notreallyzipped.zip"....
I have made a loop of pipe by creating two springs and subtracting one from the other.
Jim
A jpeg, just delete ".notreallyzipped.zip"....
Code: Select all
from __future__ import division # allows floating point division from integers
import FreeCAD, Part
from FreeCAD import Base
class MySpring:
def __init__(self, obj):
''' Add the properties: Pitch, Diameter, Height, BarDiameter '''
obj.addProperty("App::PropertyLength","Pitch","MySpring","Pitch of the helix").Pitch=5.0
obj.addProperty("App::PropertyLength","Diameter","MySpring","Diameter of the helix").Diameter=6.0
obj.addProperty("App::PropertyLength","Height","MySpring","Height of the helix").Height=5.0
obj.addProperty("App::PropertyLength","BarDiameter","MySpring","Diameter of the bar").BarDiameter=3.0
obj.Proxy = self
def onChanged(self, fp, prop):
if prop == "Pitch" or prop == "Diameter" or prop == "Height" or prop == "BarDiameter":
self.execute(fp)
def execute(self, fp):
pitch = fp.Pitch
radius = fp.Diameter/2
height = fp.Height
barradius = fp.BarDiameter/2
myhelix=Part.makeHelix(pitch,height,radius)
g=myhelix.Edges[0].Curve
c=Part.Circle()
c.Center=g.value(0) # start point of the helix
c.Axis=(0,1,0)
c.Radius=barradius
p=c.toShape()
section = Part.Wire([p])
makeSolid=1 #change to 1 to make a solid
isFrenet=1
myspring=Part.Wire(myhelix).makePipeShell([section],makeSolid,isFrenet)
fp.Shape = myspring
class MySpringid:
def __init__(self, obj):
''' Add the properties: Pitch, Diameter, Height, BarDiameter '''
obj.addProperty("App::PropertyLength","Pitch","MySpringid","Pitch of the helix").Pitch=5.0
obj.addProperty("App::PropertyLength","Diameter","MySpringid","Diameter of the helix").Diameter=6.0
obj.addProperty("App::PropertyLength","Height","MySpringid","Height of the helix").Height=5.0
obj.addProperty("App::PropertyLength","BarBore","MySpringid","Bore of the bar").BarBore=2.0
obj.Proxy = self
def onChanged(self, fpid, prop):
if prop == "Pitch" or prop == "Diameter" or prop == "Height" or prop == "BarBore":
self.execute(fp)
def execute(self, fpid):
pitch = fpid.Pitch
radius = fpid.Diameter/2
height = fpid.Height
barboreradius = fpid.BarBore/2
myhelix=Part.makeHelix(pitch,height,radius)
g=myhelix.Edges[0].Curve
cid=Part.Circle()
cid.Center=g.value(0) # start point of the helix
cid.Axis=(0,1,0)
cid.Radius=barboreradius
pid=cid.toShape()
sectionid = Part.Wire([pid])
makeSolid=1 #change to 1 to make a solid
isFrenet=1
myspringid=Part.Wire(myhelix).makePipeShell([sectionid],makeSolid,isFrenet)
fpid.Shape = myspringid
def makeMySpring():
doc = FreeCAD.activeDocument()
if doc == None:
doc = FreeCAD.newDocument()
spring=doc.addObject("Part::FeaturePython","My_Spring")
spring.Label = "My Spring"
MySpring(spring)
spring.ViewObject.Proxy=0
def makeMySpringid():
doc = FreeCAD.activeDocument()
if doc == None:
doc = FreeCAD.newDocument()
springid=doc.addObject("Part::FeaturePython","My_Springid")
springid.Label = "My Springid"
MySpringid(springid)
springid.ViewObject.Proxy=0
if __name__ == "__main__":
makeMySpring()
if __name__ == "__main__":
makeMySpringid()
#App.ActiveDocument.recompute()
App.activeDocument().addObject("Part::Cut","Cut")
App.activeDocument().Cut.Base = App.activeDocument().My_Spring
App.activeDocument().Cut.Tool = App.activeDocument().My_Springid
Gui.activeDocument().hide('My_Spring')
Gui.activeDocument().hide('My_Springid')
Gui.activeDocument().Cut.ShapeColor = Gui.activeDocument().My_Spring.ShapeColor
App.ActiveDocument.recompute()
Re: Show your FreeCAD projects here!
the kwahoo spring will become famous in history, a bit like the pythagore theorem or the columbus egg... Generations of students will study it and try to reproduce
Re: Show your FreeCAD projects here!
Thanks, I added the aeroponics screenshot to the wiki. I forgot to give you credits in the file's comments though, sorry for that.casper-nilsson wrote:Sure its ok to use them, but reupload it to sourceforge, since its a dropbox link, you never know how long it will be in my folder.
On what distro are you and what theme/mod do you use? The wheel with bearing screenshot you posted on Wikimedia has me intrigued, with the tabs at the top of the screen!
I have to say your screenshots all look amazing. You have an eye for presentation/render.
Thanks for the color gradient, I'll try it out.
Re: coil spring and helix
Hi,
I'm trying to use this script to do some coil springs. However, it isn't perfect. When you decrease the pitch, some surfaces are missing (try 2 mm for example), and below 5 mm, it never starts with a vertical circular cross section, instead the half top part of the starting point is missing. Is there a newer more refined script for coil springs ? Thanks.
I'm trying to use this script to do some coil springs. However, it isn't perfect. When you decrease the pitch, some surfaces are missing (try 2 mm for example), and below 5 mm, it never starts with a vertical circular cross section, instead the half top part of the starting point is missing. Is there a newer more refined script for coil springs ? Thanks.
Re: coil spring and helix
Nevermind, I found my mistake, didn't realize it was a substraction of the 2.