Macro Cut Circle/fr: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
{{Macro|Icon=Text-x-python|Name=Macro cutCircle|Description=Coupe un cercle ou un arc en nombre d'arcs pécifié.|Author=mario52}} |
{{Macro|Icon=Text-x-python|Name=Macro cutCircle|Description=Coupe un cercle ou un arc en nombre d'arcs pécifié.|Author=mario52}} |
||
==Description== |
==Description== |
||
This macro cut a circle(s) or arc(s) in multiple arcs, the arcs can be coloured alternately to distinguish. |
|||
== |
==Use== |
||
Copy the macro '''cutCirle''' complete in the Python console FreeCAD select the circle(s) and (or) arc(s) type in the console: |
|||
<syntaxhighlight> |
<syntaxhighlight> |
||
cutCircle(5, 1) # here with 5 arcs and coloured |
cutCircle(5, 1) # here with 5 arcs and coloured |
||
Line 18: | Line 18: | ||
<syntaxhighlight> |
<syntaxhighlight> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
# selection circle(s) (circles and arcs) |
# selection circle(s) (circles and arcs) |
||
# give number of cut, biColor 0/1 |
# give number of cut, biColor 0/1 |
||
Line 23: | Line 29: | ||
# if biColor is <> 0 the arcs are colored alternately Red White Red White .... |
# if biColor is <> 0 the arcs are colored alternately Red White Red White .... |
||
# |
# |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
import Draft |
import Draft |
||
Line 76: | Line 77: | ||
pivot1 += pivot0 |
pivot1 += pivot0 |
||
⚫ | |||
</syntaxhighlight> |
</syntaxhighlight> |
||
Line 83: | Line 85: | ||
==Version== |
==Version== |
||
ver 0.1 24/02/2015 : |
|||
ver 00.02 09/03/2015 : adding create arcs coloured altenat alternately Red White Red White .... or not |
ver 00.02 09/03/2015 : adding create arcs coloured altenat alternately Red White Red White .... or not |
Revision as of 11:50, 21 March 2015
File:Text-x-python Macro cutCircle |
Description |
---|
Coupe un cercle ou un arc en nombre d'arcs pécifié. 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, the arcs can be coloured alternately to distinguish.
Use
Copy the macro cutCirle complete in the Python console FreeCAD select the circle(s) and (or) arc(s) type in the console:
cutCircle(5, 1) # here with 5 arcs and coloured
cutCircle(4) #
pour voir les cercles et arcs découpés dans cet exemple cinq arcs contigus.
l'objet(s) original(aux) n'est pas éffacé.
Script
Macro_cutCircle.FCMacro
__title__= "cutCircle"
__author__= "Mario52"
__date__= "09/03/2015"
__version__= "00.02"
# selection circle(s) (circles and arcs)
# give number of cut, biColor 0/1
# cut the circle to x arcs
# if biColor is <> 0 the arcs are colored alternately Red White Red White ....
#
import Draft
global biscolor ; biscolor = 0
def cutCircle(number = 2, biColor = 0):
global biscolor
def defbiColor(objet):
global biscolor
if biscolor == 0:
FreeCADGui.ActiveDocument.getObject(objet.Name).LineColor = (1.0,0.0,0.0) # 255 = 1 (10 = (1/255 * 10 ))
biscolor = 1
else:
FreeCADGui.ActiveDocument.getObject(objet.Name).LineColor = (1.0,1.0,1.0) # 255 = 1 (10 = (1/255 * 10 ))
biscolor = 0
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)
FreeCAD.Console.PrintMessage("Cylinder"+"\n")
else:
pivot0 = float(360/number)
FreeCAD.Console.PrintMessage("Circle"+"\n")
pivot1 = 0.0
for i in range(number):
cercle = Draft.makeCircle(radius=rayon,placement=placem,face=False,startangle=(pivot1),endangle=(pivot0+pivot1),support=None)
if biColor != 0:
defbiColor(cercle)
pivot1 += pivot0
elif nom[:3] == "Arc":
FreeCAD.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):
cercle = Draft.makeCircle(radius=rayon,placement=placem,face=False,startangle=(pivot1+First),endangle=(pivot0+pivot1+First),support=None)
if biColor != 0:
defbiColor(cercle)
pivot1 += pivot0
Projet
Couper les cercles d'un cylindre.
Version
ver 00.02 09/03/2015 : adding create arcs coloured altenat alternately Red White Red White .... or not
ver 00.01 24/02/2015 :