FreeCAD Logo FreeCAD 1.0
  • Anglais Afrikaans Arabe Biélorusse Catalan Tchèque Allemand Grec Espagnol Espagnol Basque Finnois Philippin Français Galicien Croate Hongrois Indonésien Italien Japonais Kabyle Coréen Lituanien Néerlandais Norvégien classique Polonais Portugais Portugais Roumain Russe Slovaque Slovène Serbe Suédois Turc Ukrainien Valencien Vietnamien Chinois Chinois
  • Fonctions
  • Télécharger
  • Blog
  • Documentation
    Index de la documentation Premiers pas Documentation pour les utilisateurs Manuel de FreeCAD Documentation des ateliers Documentation sur le codage en Python Documentation pour les développeurs Tutoriels Foire aux questions Politique de confidentialité À propos de FreeCAD
  • Contribuer
    Comment aider Sponsor Signaler un bogue Faire une demande de modification (PR) Emplois et financements Guide pour les contributions Manuel pour les développeurs Traductions
  • Communauté
    Code de conduite Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendrier
  • ♥ Donate

Donate

$
Informations SEPA
Veuillez configurer votre virement bancaire SEPA pour:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Agence bancaire: BNP Paribas Fortis
Adresse: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Macro Make Circle 3 Points

Description
Cette macro crée un cercle sur 3 points sélectionnés. Les points peuvent être des objets tels que des cubes, des cylindres, alors les coordonnées sélectionnées seront le centre de ces formes.

Version macro : 01.01
Date dernière modification : 2016-03-23
Version FreeCAD : Toutes
Téléchargement : Icône de la barre d'outils
Auteur: Mario52
Auteur
Mario52
Téléchargement
Icône de la barre d'outils
Liens
Page des macros
Comment installer une macro
Comment créer une barre d'outils
Version Macro
01.01
Dernière modification
2016-03-23
Version(s) FreeCAD
Toutes
Raccourci clavier
None
Voir aussi
None

Description

Cette macro crée un cercle par 3 points sélectionnés. Les points peuvent être des objets tels que des cubes, des cylindres, alors les coordonnées sélectionnées seront le centre de ces formes.

Cercle construit par 3 points sélectionnés

Cercle construit par 3 points sélectionnés

Utilisation

Sélectionnez 3 points, ou formes dans la vue 3D et lancez la macro.
Si la forme est une ligne, le point sera le centre de la ligne.

Options

Si l'objet sélectionné a différents plans, (xy Z10, xy Z2, xy Z5) le cercle est construit aux coordonnées x,y Z=0.
Si tous le objets sélectionnés ont la même hauteur Z ex: (xy Z5, xy Z5, xy Z5), le ercle est construit sur le pla x,y Z=5.

Script

Icône de la barre d'outils

Draft_Circle_3_Points.FCMacro

# -*- coding: utf-8 -*-
# créer un cercle a partir de 3 points séléctionnés
# avec comme options le cercle peut être construit sur un plans au choix
# aa la coordonnée d'une des trois formes sélectionnées au choix
# et création du point central O/N
# 04/03/2013 , 07/09/2018 replace PyQt4 to PySide, 23/03/2026 convert in spaces
# la formule provient de
# http://www-obs.univ-lyon1.fr/labo/fc/Ateliers_archives/ateliers_2005-06/cercle_3pts.pdf
# lire la note dans le pdf, sur l'ordre de sélection des points,
# si la formule renvoie une erreur (exemple les 3 points dans le même alignement)
#
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
from math import sqrt, pi, sin, cos
from FreeCAD import Base
from PySide import QtCore, QtGui

def errorDialog(msg):
    # Create a simple dialog QMessageBox
    # The first argument indicates the icon used: one of QtGui.QMessageBox.{NoIcon, Information, Warning, Critical, Question} 
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_()

def affiche(x,y,z,rayon,r,v,b,afficherPoint):
    pl.Base=FreeCAD.Vector(x,y,z)
    Draft.makeCircle((rayon),placement=pl,face=False,support=None)
    FreeCADGui.activeDocument().activeObject().LineColor = (r,v,b)
    if afficherPoint==1:
        Draft.makePoint(x,y,z)
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Coordinates",u"Coordinates X : "+str(x)+"\r\n"+u"Coordinates Y : "+str(y)+"\n"+u"Coordinates Z : "+str(z)+"\nRayon\t     : "+str(rayon))
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_()

# prendre les objets selectionnes
sel = FreeCADGui.Selection.getSelection()
i=0
centreX=0;centreY=0;rayon=0

# S'il y a 3 points sélectionnés alors..
if len(sel)==3 :
    i=0
    ta=[0,0,0,0,0,0,0,0,0]
    for obj in sel:
        x=(obj.Shape.BoundBox.Center)
        ta[i+0]=(x.x)
        ta[i+1]=(x.y)
        ta[i+2]=(x.z)
        i=i+3
# Change the values here below
            # mode by default vueChoix = 0 and alignerSur = 0
    vueChoix=0  # choice of the top view = 1 XY, view Front = 2 ZX, Right view = 3 ZY
    alignerSur=0    # Aligns the circle shaped the choice (1,2 or 3) or Z = 0
    afficherPoint=1 # Displays the center point of the circle

    # Affectation des variables
    if vueChoix==3:     # View of right ZY (Red)
        z_point_1=ta[0]
        x_point_1=ta[1]
        y_point_1=ta[2]
    
        z_point_2=ta[3]
        x_point_2=ta[4]
        y_point_2=ta[5]
    
        z_point_3=ta[6]
        x_point_3=ta[7]
        y_point_3=ta[8]

    elif vueChoix==2:   # Front view ZX (Green)
        y_point_1=ta[0]
        z_point_1=ta[1]
        x_point_1=ta[2]
    
        y_point_2=ta[3]
        z_point_2=ta[4]
        x_point_2=ta[5]
    
        y_point_3=ta[6]
        z_point_3=ta[7]
        x_point_3=ta[8]

    else:           # Top view XY (blue)
        x_point_1=ta[0]
        y_point_1=ta[1]
        z_point_1=ta[2]
    
        x_point_2=ta[3]
        y_point_2=ta[4]
        z_point_2=ta[5]
    
        x_point_3=ta[6]
        y_point_3=ta[7]
        z_point_3=ta[8]

    # Calculation of coordinates of the center of the circle    
    try:
        centreX =((x_point_3**2-x_point_2**2+y_point_3**2-y_point_2**2)/(2*(y_point_3-y_point_2))-(x_point_2**2-x_point_1**2+y_point_2**2-y_point_1**2)/(2*(y_point_2-y_point_1)))/((x_point_3-x_point_2)/(y_point_3-y_point_2)-(x_point_2-x_point_1)/(y_point_2-y_point_1))
        centreY =-(x_point_2-x_point_1)/(y_point_2-y_point_1)*centreX+(x_point_2**2-x_point_1**2+y_point_2**2-y_point_1**2)/(2*(y_point_2-y_point_1))
        rayon =sqrt((x_point_1-centreX)**2+(y_point_1-centreY)**2)
    except:
        errorDialog(u"Impossible calculation too aligned elements")
    else:
    #finally: sera TOUJOURS execute
       # Definition of the coordinate Z
        centreZ=0
        # Création du cercle
        pl=FreeCAD.Placement()
        if vueChoix==1: # Plan XY Dessus
            pl.Rotation.Q=(0,0,0,1.0)
            if alignerSur==1:   
                affiche(centreX,centreY,z_point_1,rayon,0.0,0.0,1.0,afficherPoint)
            elif alignerSur==2:
                affiche(centreX,centreY,z_point_2,rayon,0.0,0.0,1.0,afficherPoint)
            elif alignerSur==3:
                affiche(centreX,centreY,z_point_3,rayon,0.0,0.0,1.0,afficherPoint)
        elif vueChoix==2: # Plan XZ Face
            pl.Rotation.Q=(1,0,0,1.0)
            if alignerSur==1:   
                affiche(centreY,z_point_1,centreX,rayon,0.0,1.0,0.0,afficherPoint)
            elif alignerSur==2:
                affiche(centreY,z_point_2,centreX,rayon,0.0,1.0,0.0,afficherPoint)
            elif alignerSur==3:
                affiche(centreY,z_point_3,centreX,rayon,0.0,1.0,0.0,afficherPoint)
        elif vueChoix==3: # Plan YZ Droite
            pl.Rotation.Q=(0,1,0,1.0)
            if alignerSur==1:   
                affiche(z_point_1,centreX,centreY,rayon,1.0,0.0,0.0,afficherPoint)
            elif alignerSur==2:
                affiche(z_point_2,centreX,centreY,rayon,1.0,0.0,0.0,afficherPoint)
            elif alignerSur==3:
                affiche(z_point_3,centreX,centreY,rayon,1.0,0.0,0.0,afficherPoint)
        else:   # modifier pour avoir XYZ
            # si les coordonnées Z sont égales alors le cercle s'aligne à Z
            if z_point_1==z_point_2 and z_point_2==z_point_3:
                centreZ=z_point_1
                affiche(centreX,centreY,z_point_1,rayon,0.0,0.0,0.0,afficherPoint)
            else:
                # Si une coordonnée est différente alors Z=0
                affiche(centreX,centreY,0,rayon,0.0,0.0,0.0,afficherPoint)

else:
    # Si la condition n'est pas remplie, recommencer
    errorDialog(u"Select 3 points and repeat")
    #FreeCAD.Console.PrintError("Select 3 points and repeatr\n")

Anaglyphe

Voici une vue Anaglyphe qui vous permet de voir deux positions différentes de la vue en utilisant des lunettes avec des filtres rouges et Cyan .
Regardez en alternance avec l'oeil gauche et l'oeil droit pour voir les vues séparément.

Anaglyphe

Crédits

La genèse de la macro Draft Circle 3 Points on the forum (PYTHON) coordonnées d'un point avec l'aide flachyjoe merci.
La formule vient de cercle_3pts.pdf et utilisée avec l'aimable permission de son auteur.

Cette page est extraite de https://wiki.freecad.org/Macro_Draft_Circle_3_Points

Contactez-nous !
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© L'équipe FreeCAD. Crédits des images de la page d'accueil (de haut en bas) : ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Ce projet est soutenu par : , KiCad Services Corp. et autres parrains

GitHubAméliorer cette page sur GitHub