Macro Cut Circle
File:Text-x-python Macro cutCircle |
Description |
---|
Cut a circle or arc in x arcs. Author: mario52 |
Author |
mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Description
This macro cut a circle(s) or arc(s) in multiple arcs. This macro must be used with the macro circle or it will not work.
Use
Copy the macro circle and cutCirle in Python console FreeCAD select the circle(s) and arc(s) type in the console:
cutCircle (5)
to see the circles and arcs cut here in the example 5 contiguous arcs. The original macro circle can be used independently of cutCircle.
The original object is not deleted.
Script
Macro_cutCircle.FCMacro
# selection circle(s) (circle and arcs)
# give number of cut
# cut the circle to x parts
# this macro work with the "macro_circle" same author
# http://www.freecadweb.org/wiki/index.php?title=Macro_circle
__title__ = "cutCircle"
__author__ = "Mario52"
__date__ = "24/02/2015"
def cutCircle(number):
selection = FreeCADGui.Selection.getSelection()
for piece in selection:
nom = piece.Name
if (nom[:6] == "Circle") or (nom[:8] == "Cylinder"):
circonference = piece.Shape.Length
rayon = piece.Radius
placem = piece.Placement
if (nom[:8] == "Cylinder"):
pivot0 = float(piece.Angle/number)
App.Console.PrintMessage("Cylinder"+"\n")
else:
pivot0 = float(360/number)
App.Console.PrintMessage("Circle"+"\n")
pivot1 = 0.0
for i in range(number):
circle(radius=rayon,arc=(circonference/number),startangle=(pivot1), endangle=(pivot0+pivot1),placemObject=placem) #anglecenter=(360/number),
pivot1 += pivot0
elif nom[:3] == "Arc":
App.Console.PrintMessage("Arc"+"\n")
circonference = piece.Shape.Length
rayon = piece.Radius
placem = piece.Placement
First = float(piece.FirstAngle)
Last = float(piece.LastAngle)
pivot0 = abs((First - Last) / number)
pivot1 = 0.0
for i in range(number):
circle(radius=rayon,arc=(circonference/number),startangle=(pivot1+First), endangle=(pivot0+pivot1+First),placemObject=placem) #anglecenter=(360/number),
pivot1 += pivot0
Project
Cut circle to cylinder
Version
ver 0.1 24/02/2015 :