Helix not cut by cylinder

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
iperov
Posts: 2
Joined: Thu Mar 09, 2017 8:32 am
Location: Russia

Helix not cut by cylinder

Post by iperov »

Code: Select all

import FreeCAD, Draft, Part, math
from FreeCAD import Base
from FreeCAD import Vector
import DraftVecUtils

try:
	FreeCAD.closeDocument("test")
except NameError:
	pass

doc = FreeCAD.newDocument("test") 
doc.Label = "test"

p1 = Vector ( 0, 0, 0)
p2 = Vector ( 0, 2, 0)
p3 = Vector ( 1, 1, 0)

thread_section = Part.Wire([Part.makeLine (p1, p2), Part.makeLine (p2, p3), Part.makeLine (p1, p3)])
thread_section.rotate 	 ( Vector(0,0,0),Vector(1,0,0),90)
thread_section_pipe = Part.Wire( Part.makeHelix(2, 5, 1) ).makePipeShell([thread_section],True,True)
#Part.show(thread_section_pipe)

cyl = Part.makeCylinder(1,1)
#Part.show(cyl)

result = thread_section_pipe.cut(cyl)
Part.show(result)

Gui.activateWorkbench("ArchWorkbench")
Gui.activateWorkbench("DraftWorkbench")
helix:
Image

cylinder:
Image

result (and also result helix became full black) :
Image
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Helix not cut by cylinder

Post by ickby »

I suppose the error is coming from the fact that you create a selfintersecting shape and that is invalid geometry for any further operation. There are two points: for one the profile hight ratio to helix hight. On every rotation the top touches the bottom round, hence having a selfintersection. The second issue is IMHO the profile being in the excact center of the helix: there will be a selfintersection in the center line of the resulting shape.
User avatar
iperov
Posts: 2
Joined: Thu Mar 09, 2017 8:32 am
Location: Russia

Re: Helix not cut by cylinder

Post by iperov »

yeah fixed, thanks!

i removed self-intersection by translate

Code: Select all

thread_section.translate ( Vector(0.3,0,0) )
and make cylinder little bit bigger than outer radius of thread
now works
Image
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Helix not cut by cylinder

Post by ickby »

ah nice. you should still be carefull about the profile hight being equal to helix hight of a single turn, i think this still cauasing trouble later on.
Post Reply