Macro Circle/fr: Difference between revisions
m (Created page with "Le cercle fait toujours face à l'écran (avec la commande getCameraOrientation)") |
m (Created page with "==Utilisation== Copiez le code et collez le dans la console Python de FreeCAD, la fonction sera disponible tout le temps de votre cession (vous pouvez aussi utiliser ce code d...") |
||
Line 6: | Line 6: | ||
Le cercle fait toujours face à l'écran (avec la commande getCameraOrientation) |
Le cercle fait toujours face à l'écran (avec la commande getCameraOrientation) |
||
== |
==Utilisation== |
||
Copiez le code et collez le dans la console Python de FreeCAD, la fonction sera disponible tout le temps de votre cession (vous pouvez aussi utiliser ce code dans une macro). |
|||
Donnez les paramètres au choix : |
|||
give the parameter on choice : |
|||
* '''x y z''' : coordinates of circle if not coordinates the circle is created on point 0,0,0 |
* '''x y z''' : coordinates of circle if not coordinates the circle is created on point 0,0,0 |
Revision as of 10:09, 6 February 2015
File:Text-x-python Macro circle |
Description |
---|
Crée un cercle en donnant différents paramètres. 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
Cette petite macro vous permet de créer un cercle en donnant comme argument différents paramètres comme le rayon, le diamètre, la circonférence, la surface, début d'angle, fin d'angle, arc, angle central, corde, flèche, point au centre du cercle au choix.
Le cercle fait toujours face à l'écran (avec la commande getCameraOrientation)
Utilisation
Copiez le code et collez le dans la console Python de FreeCAD, la fonction sera disponible tout le temps de votre cession (vous pouvez aussi utiliser ce code dans une macro). Donnez les paramètres au choix :
- x y z : coordinates of circle if not coordinates the circle is created on point 0,0,0
- radius : radius of cicle
- diameter : diameter of circle
- circumference : circumference of circle
- area : area of circle
- startangle : start angle for arc
- endangle : end angle for arc
- arc and anglecenter : arc in combination with anglecenter
- arc = length of arc
- anglecenter = angle of center circle to extremities of arc
- cord and arrow : cord in combination with arrow of circle
- cord : length of cord of circle
- arrow : length of arrow of circle
- center : if center as different 0 one point is created on center of circle
if there is no parameter "circle()" a list of functions is displayed in the report view
Example entrance :
circle(arc=50,anglecenter=20,center=1)
circle(cord = 100,arrow = 20,center=1)
circle(circumference = 100,center=1)
Script
Macro_circle.FCMacro
# -*- coding: utf-8 -*-
# creer un cercle ou un arc entierement parametrabel en utilisant :
# create a circle or arc fully parametrabel using:
# x y z coordinates
#with radius
#with diameter
#with circumference
#with area
#with startangle
#with endangle
#with [arc and anglecenter] in combination
#with [cord and arrow] in combination
#with center (if center as different 0 one point is created on center of circle)
# s'il n'y a pas de parametre "circle()" une liste des fonctions s'affiche dans la Vue rapport
# if there is no parameter "circle()" a list of functions is displayed in the report view
__title__ = "circle"
__author__ = "Mario52"
__date__ = "31/01/2015"
import Draft #, Part
def circle(x=0.0,y=0.0,z=0.0,radius=0.0,diameter=0.0,circumference=0.0,area=0.0,startangle=0.0,endangle=0.0,arc=0.0,anglecenter=0.0,cord=0.0,arrow=0.0,center=0):
from math import sqrt, pi
pl = FreeCAD.Placement()
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
pl.Base=FreeCAD.Vector(x,y,z)
if diameter != 0: # with diameter
radius = diameter / 2
elif circumference != 0: # with circumference
radius = (circumference / pi) / 2
elif area != 0: # with area
radius = sqrt((area / pi))
elif (cord != 0) and (arrow != 0): # with cord and arrow
radius = ((arrow**2) + (cord**2) / 4) / (arrow*2)
elif (arc != 0) and (anglecenter != 0): # with arc and anglecenter central
radius = ((360/anglecenter)*arc) / pi/2
if endangle != 0:
startangle = endangle - anglecenter
endangle = anglecenter + startangle
startangle = endangle - anglecenter
if radius != 0:
Draft.makeCircle(radius,placement=pl,face=False,startangle=startangle,endangle=endangle,support=None)
if center != 0:
Draft.makePoint(x,y,z)
else:
App.Console.PrintMessage("unexpected keyword argument" + "\n")
App.Console.PrintMessage("circle(x,y,z,radius,diameter,circumference,area,startangle,endangle,[arc,anglecenter],[cord,arrow],center)" + "\n")
#example
#circle(arc=50,anglecenter=20,center=1)
Memo of circle
Examples codes
circle(radius=10)
circle(x=15,diameter=20)
circle(y=45,circumference=100)
circle(y=-15,area=100)
circle(y=-15,x=15,startangle=60,endangle=-20,center=1)
circle(y=-15,x=45,cord=9,arrow=3,center=1)
circle(x=65,y=-15,arc=3.5,anglecenter=40,startangle=20,center=1)