Macro Cut Circle: Difference between revisions
(use Draft.Arc) |
m (→Use: minor) |
||
Line 7: | Line 7: | ||
==Use== |
==Use== |
||
Copy the macro '''cutCirle''' in Python console FreeCAD select the circle(s) and arc(s) type in the console: |
Copy the macro '''cutCirle''' in Python console FreeCAD select the circle(s) and (or) arc(s) type in the console: |
||
<syntaxhighlight> |
<syntaxhighlight> |
||
cutCircle |
cutCircle(5) |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Revision as of 09:51, 26 February 2015
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.
Use
Copy the macro cutCirle in Python console FreeCAD select the circle(s) and (or) arc(s) type in the console:
cutCircle(5)
to see the circles and arcs cut here in the example 5 contiguous arcs.
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
#
#
__title__ = "cutCircle"
__author__ = "Mario52"
__date__ = "24/02/2015"
import Draft
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):
Draft.makeCircle(radius=rayon,placement=placem,face=False,startangle=(pivot1),endangle=(pivot0+pivot1),support=None)
# circle(radius=rayon,arc=(circonference/number),startangle=(pivot1), endangle=(pivot0+pivot1),placemObject=placem) #
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):
Draft.makeCircle(radius=rayon,placement=placem,face=False,startangle=(pivot1+First),endangle=(pivot0+pivot1+First),support=None)
# circle(radius=rayon,arc=(circonference/number),startangle=(pivot1+First), endangle=(pivot0+pivot1+First),placemObject=placem) #
pivot1 += pivot0
Project
Cut circle to cylinder
Version
ver 0.1 24/02/2015 :