Macro Make Circle 3 Points/cs: Difference between revisions
(Created page with "==Popis== Toto makro vytváří kružnici opsanou 3 vybraným bodům na kolmicích nebo ve 3D zvoleném prostoru. Body mohou být objekty jako jsou krychle válce,..., potom s...") |
(Updating to match new version of source page) |
||
(31 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
{{Macro|Icon=Macro_Draft_Circle_3_Points|Name=Macro_Make_Circle_3_Points|Description=Vytváří kružnici ze 3 vybraných bodů nebo tvarů.|Author=Mario52}} |
|||
{{Macro/cs |
|||
|Name=Macro Make Circle 3 Points |
|||
|Icon=Macro_Make_Circle_3_Points.png |
|||
|Translate=Macro Make Circle 3 Points |
|||
|Description=Vytváří kružnici ze 3 vybraných bodů nebo tvarů. |
|||
|Author=Mario52 |
|||
|Version=1.0 |
|||
|Date=2014-08-08 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/c/c7/Macro_Make_Circle_3_Points.png ToolBar Icon]<br/>[https://www.freecadweb.org/wiki/images/f/fb/View-Top.png Icon View-Top]<br/>[https://www.freecadweb.org/wiki/images/c/ca/View-Left.png Icon View-Left]<br/>[https://www.freecadweb.org/wiki/images/6/64/View-Front.png Icon View-Front]<br/>[https://www.freecadweb.org/wiki/images/1/19/View-C3P.png Icon View-C3P] |
|||
}} |
|||
==Popis== |
==Popis== |
||
Toto makro vytváří kružnici opsanou 3 vybraným bodům na kolmicích nebo ve 3D zvoleném prostoru. Body mohou být objekty jako jsou krychle válce,..., potom souřadnicemi budou středy |
Toto makro vytváří kružnici opsanou 3 vybraným bodům na kolmicích nebo ve 3D zvoleném prostoru. Body mohou být objekty jako jsou krychle, válce,..., potom souřadnicemi budou středy vybraných tvarů. |
||
[[File:Macro Draft Circle 3 Points01.png|480px |
[[File:Macro Draft Circle 3 Points01.png|480px]] |
||
{{Caption|Circle built on 3 selected points}} |
|||
{{clear}} |
|||
==Use== |
|||
<div class="mw-translate-fuzzy"> |
|||
Select 3 points, or forms in the 3D view and run the macro.<br /> |
|||
==Použití== |
|||
If the shape is a line, the coordinate will be the center of the line. |
|||
Vyberte 3 body nebo tvary ve 3D pohledu a spusťte makro.<br /> |
|||
Je-li tvarem přímka, souřadnicí bude střed přímky. |
|||
[[File:Circle_on_3_points.png|Circle_on_3_points]] |
[[File:Circle_on_3_points.png|Circle_on_3_points]] |
||
{{clear}} |
{{clear}} |
||
</div> |
|||
== |
==Volby== |
||
=== |
===Mód :=== |
||
'''Defaut :''' |
'''Defaut(přednastavený) :''' |
||
: Defaultní mód vytváří kružnici podle 3 bodů nebo tvarů ve 3D prostoru. |
|||
: Mode by default, creates a circle on the three points or shapes in 3d space. |
|||
: Pořadí vybíraných bodů u tvarů ovlivňuje úhly odklonu '''OS''' a zpětně odklon kružnice. V případě potřeby se lze vrátit a změnit pořadí výběru tvarů. |
|||
: The order of selection of fear forms influencing the angle '''AXIS''' and reverse the inclination of the circle. In this case, reverse or change the order of selection of the shapes. |
|||
: |
: Souřadnice '''X, Y, Z''' s hodnotou '''0''' nebo zarovnání, které neumožňuje výpočet, může vrátit chybu dělení nulou se zprávou '''Tyto tři body jsou vyrovnány''' |
||
'''Vue Face :''' |
'''Vue Face :''' |
||
: Vytváří kružnici v nárysu vybraného tvaru, 1, 2 or 3 |
|||
: Creates the circle in the front views of the form chosen, 1, 2 or 3 |
|||
'''Vue Dessus :''' |
'''Vue Dessus :''' |
||
:Vytváří kružnici v půdorysu vybraného tvaru, 1, 2 or 3 |
|||
:Creates the circle in the top on the form chosen view, 1, 2 or 3 |
|||
'''Vue Droite :''' |
'''Vue Droite :''' |
||
:Vytváří kružnici v bokorysu vybraného tvaru, 1, 2 or 3 |
|||
:Creates the circle in the view of right on the form chosen, 1, 2 or 3 |
|||
===Alignement sur :=== |
===Alignement sur :=== |
||
'''Forme 1, 2, 3''' |
'''Forme 1, 2, 3''' |
||
: Tvary podle jejich výběru. |
|||
: Forms, in the order of their selections. |
|||
===Afficher le centre :=== |
===Afficher le centre :=== |
||
: Je-li políčko zakliknuto, bude vytvořen i středový bod kružnice |
|||
: If this box is checked, a point on the centre of the built circle will be created |
|||
===Associer les couleurs=== |
===Associer les couleurs=== |
||
:Je-li políčko zakliknuto, kružnice přebere barvu aktuálního pohledu, |
|||
:If this box is checked, the circle will take the colour of the relevant view, |
|||
:: |
::Pohled shora (X,Y) = Modrá(osa Z) |
||
:: |
::Pohled zepředu (Z,X) = Zelená(osa Y) |
||
:: |
::Pohled zleva (Z,Y) = Červená(osa X) |
||
Line 45: | Line 58: | ||
<center> |
<center> |
||
<gallery widths="200" heights="100"> |
<gallery widths="200" heights="100"> |
||
File:Macro Draft Circle 3 Points02.png| |
File:Macro Draft Circle 3 Points02.png|Kružnice na 3 tvarech (pohled zepředu), |
||
File:Macro Draft Circle 3 Points03.png| |
File:Macro Draft Circle 3 Points03.png|na kolmicích na vybraném tvaru (pohled zprava) |
||
File:Macro Draft Circle 3 Points04.png| |
File:Macro Draft Circle 3 Points04.png| |
||
File:Macro Draft Circle 3 Points05.png| |
File:Macro Draft Circle 3 Points05.png|Tři nezávislé kolmé kružnice na vybraném tvaru. |
||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
== |
==Skript== |
||
The file should be copied to " '''C:/Program Files/FreeCAD0.13/''' " If you want to put it in another directory, modify the path to line 53 |
|||
<syntaxhighlight> |
|||
path = FreeCAD.ConfigGet("AppHomePath") # chemin |
|||
</syntaxhighlight> |
|||
[[Image:View-Top.png]] [[Image:View-Left.png]] [[Image:View-Front.png]] [[Image:View-C3P.png]] |
[[Image:View-Top.png]] [[Image:View-Left.png]] [[Image:View-Front.png]] [[Image:View-C3P.png]] |
||
Tyto tři ikony musejí být ve stejném adresáři jako makro.<br /> |
|||
The three icons must be in the same directory as the module.<br /> |
|||
Stáhněte je kliknutím pravou myší na obrázek a dejte ''' Uložit obrázek jako ...''' |
|||
To download them, resting your mouse over the icon and then right-click and ''' save image as...''' |
|||
The file '''Make_Circle_3_Points/fr.FCMacro''': |
|||
ToolBar Icon [[Image:Macro_Make_Circle_3_Points.png]] |
|||
'''Make_Circle_3_Points.FCMacro''' |
|||
<syntaxhighlight> |
|||
{{MacroCode|code= |
|||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||
# Cercle sur 3 points.py |
# Cercle sur 3 points.py |
||
Line 76: | Line 88: | ||
# the options create the circle of orthogonal way on the map and view the choice |
# the options create the circle of orthogonal way on the map and view the choice |
||
# with the creation of a central color related to the axes Y/N Y/N |
# with the creation of a central color related to the axes Y/N Y/N |
||
# 04/03/2013 # 24/03/2013 # by mario52 |
# 04/03/2013 # 24/03/2013 # 08/08/2014 by mario52 |
||
# the formula adapted (with permission of its author) by "mario52" for orthogonal circles comes from |
# the formula adapted (with permission of its author) by "mario52" for orthogonal circles comes from |
||
# http://www-obs.univ-lyon1.fr/labo/fc/Ateliers_archives/ateliers_2005-06/cercle_3pts.pdf |
# http://www-obs.univ-lyon1.fr/labo/fc/Ateliers_archives/ateliers_2005-06/cercle_3pts.pdf |
||
Line 86: | Line 98: | ||
# as for example to select other items in FreeCAD |
# as for example to select other items in FreeCAD |
||
#08/08/2014 PyQt4 and PySide |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, PyQt4 |
|||
#OS: Windows Vista |
|||
#Word size: 32-bit |
|||
#Version: 0.14.3700 (Git) |
|||
#Branch: releases/FreeCAD-0-14 |
|||
#Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1 |
|||
#Python version: 2.6.2 |
|||
#Qt version: 4.5.2 |
|||
#Coin version: 3.1.0 |
|||
#SoQt version: 1.4.1 |
|||
#OCC version: 6.5.1 |
|||
try: |
|||
import PyQt4 |
|||
from PyQt4 import QtCore, QtGui |
|||
except Exception: |
|||
import PySide |
|||
from PySide import QtCore, QtGui |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui |
|||
from math import sqrt, pi, sin, cos, asin |
from math import sqrt, pi, sin, cos, asin |
||
from FreeCAD import Base |
from FreeCAD import Base |
||
from PyQt4 import QtCore, QtGui |
|||
# vueChoix = 0 et alignerSur = 0 , mode par défaut |
# vueChoix = 0 et alignerSur = 0 , mode par défaut |
||
global vueChoix # choix de la vue Dessus=1 XY, vue Face=2 ZX, vue Droite=3 ZY (Orthogonal) |
global vueChoix # choix de la vue Dessus=1 XY, vue Face=2 ZX, vue Droite=3 ZY (Orthogonal) |
||
Line 100: | Line 131: | ||
afficherPoint = 1 |
afficherPoint = 1 |
||
colorer = 1 |
colorer = 1 |
||
try: |
try: |
||
_fromUtf8 = QtCore.QString.fromUtf8 |
_fromUtf8 = QtCore.QString.fromUtf8 |
||
Line 106: | Line 137: | ||
def _fromUtf8(s): |
def _fromUtf8(s): |
||
return s |
return s |
||
try: |
try: |
||
_encoding = QtGui.QApplication.UnicodeUTF8 |
_encoding = QtGui.QApplication.UnicodeUTF8 |
||
Line 114: | Line 145: | ||
def _translate(context, text, disambig): |
def _translate(context, text, disambig): |
||
return QtGui.QApplication.translate(context, text, disambig) |
return QtGui.QApplication.translate(context, text, disambig) |
||
class Ui_MainWindow(object): |
class Ui_MainWindow(object): |
||
def __init__(self, MainWindow): |
def __init__(self, MainWindow): |
||
self.window = MainWindow |
self.window = MainWindow |
||
path = FreeCAD.ConfigGet("AppHomePath") # chemin |
path = FreeCAD.ConfigGet("AppHomePath") # chemin |
||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
||
MainWindow.resize(490, 302) |
MainWindow.resize(490, 302) |
||
Line 126: | Line 157: | ||
self.centralWidget = QtGui.QWidget(MainWindow) |
self.centralWidget = QtGui.QWidget(MainWindow) |
||
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
||
self.groupBox = QtGui.QGroupBox(self.centralWidget) |
self.groupBox = QtGui.QGroupBox(self.centralWidget) |
||
self.groupBox.setGeometry(QtCore.QRect(20, 10, 130, 161)) |
self.groupBox.setGeometry(QtCore.QRect(20, 10, 130, 161)) |
||
self.groupBox.setObjectName(_fromUtf8("groupBox_1")) |
self.groupBox.setObjectName(_fromUtf8("groupBox_1")) |
||
self.radioButton_1 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_1 = QtGui.QRadioButton(self.groupBox) |
||
self.radioButton_1.setGeometry(QtCore.QRect(10, 30, 130, 20)) |
self.radioButton_1.setGeometry(QtCore.QRect(10, 30, 130, 20)) |
||
Line 137: | Line 168: | ||
self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked) #connection radioButton_1 |
self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked) #connection radioButton_1 |
||
self.radioButton_1.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) |
self.radioButton_1.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) |
||
self.radioButton_2 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_2 = QtGui.QRadioButton(self.groupBox) |
||
self.radioButton_2.setGeometry(QtCore.QRect(10, 60, 130, 20)) |
self.radioButton_2.setGeometry(QtCore.QRect(10, 60, 130, 20)) |
||
Line 148: | Line 179: | ||
icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
||
self.radioButton_2.setIcon(icon01) |
self.radioButton_2.setIcon(icon01) |
||
self.radioButton_3 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_3 = QtGui.QRadioButton(self.groupBox) |
||
self.radioButton_3.setGeometry(QtCore.QRect(10, 90, 130, 20)) |
self.radioButton_3.setGeometry(QtCore.QRect(10, 90, 130, 20)) |
||
Line 159: | Line 190: | ||
icon02.addPixmap(QtGui.QPixmap(self.image_02),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
icon02.addPixmap(QtGui.QPixmap(self.image_02),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
||
self.radioButton_3.setIcon(icon02) |
self.radioButton_3.setIcon(icon02) |
||
self.radioButton_4 = QtGui.QRadioButton(self.groupBox) |
self.radioButton_4 = QtGui.QRadioButton(self.groupBox) |
||
self.radioButton_4.setGeometry(QtCore.QRect(10, 120, 130, 20)) |
self.radioButton_4.setGeometry(QtCore.QRect(10, 120, 130, 20)) |
||
Line 170: | Line 201: | ||
icon03.addPixmap(QtGui.QPixmap(self.image_03),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
icon03.addPixmap(QtGui.QPixmap(self.image_03),QtGui.QIcon.Normal, QtGui.QIcon.Off) |
||
self.radioButton_4.setIcon(icon03) |
self.radioButton_4.setIcon(icon03) |
||
self.groupBox_2 = QtGui.QGroupBox(self.centralWidget) |
self.groupBox_2 = QtGui.QGroupBox(self.centralWidget) |
||
self.groupBox_2.setGeometry(QtCore.QRect(170, 10, 120, 161)) |
self.groupBox_2.setGeometry(QtCore.QRect(170, 10, 120, 161)) |
||
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) |
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) |
||
self.radioButton_5 = QtGui.QRadioButton(self.groupBox_2) |
self.radioButton_5 = QtGui.QRadioButton(self.groupBox_2) |
||
self.radioButton_5.setGeometry(QtCore.QRect(10, 30, 95, 20)) |
self.radioButton_5.setGeometry(QtCore.QRect(10, 30, 95, 20)) |
||
Line 181: | Line 212: | ||
self.radioButton_5.clicked.connect(self.on_radioButton_5_clicked) #connection radioButton_5 |
self.radioButton_5.clicked.connect(self.on_radioButton_5_clicked) #connection radioButton_5 |
||
self.radioButton_5.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) |
self.radioButton_5.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) |
||
self.radioButton_6 = QtGui.QRadioButton(self.groupBox_2) |
self.radioButton_6 = QtGui.QRadioButton(self.groupBox_2) |
||
self.radioButton_6.setGeometry(QtCore.QRect(10, 60, 95, 20)) |
self.radioButton_6.setGeometry(QtCore.QRect(10, 60, 95, 20)) |
||
Line 187: | Line 218: | ||
self.radioButton_6.clicked.connect(self.on_radioButton_6_clicked) #connection radioButton_6 |
self.radioButton_6.clicked.connect(self.on_radioButton_6_clicked) #connection radioButton_6 |
||
self.radioButton_6.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 1", None)) |
self.radioButton_6.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 1", None)) |
||
self.radioButton_7 = QtGui.QRadioButton(self.groupBox_2) |
self.radioButton_7 = QtGui.QRadioButton(self.groupBox_2) |
||
self.radioButton_7.setGeometry(QtCore.QRect(10, 90, 95, 20)) |
self.radioButton_7.setGeometry(QtCore.QRect(10, 90, 95, 20)) |
||
Line 193: | Line 224: | ||
self.radioButton_7.clicked.connect(self.on_radioButton_7_clicked) #connection radioButton_7 |
self.radioButton_7.clicked.connect(self.on_radioButton_7_clicked) #connection radioButton_7 |
||
self.radioButton_7.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 2", None)) |
self.radioButton_7.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 2", None)) |
||
self.radioButton_8 = QtGui.QRadioButton(self.groupBox_2) |
self.radioButton_8 = QtGui.QRadioButton(self.groupBox_2) |
||
self.radioButton_8.setGeometry(QtCore.QRect(10, 120, 95, 20)) |
self.radioButton_8.setGeometry(QtCore.QRect(10, 120, 95, 20)) |
||
Line 199: | Line 230: | ||
self.radioButton_8.clicked.connect(self.on_radioButton_8_clicked) #connection radioButton_8 |
self.radioButton_8.clicked.connect(self.on_radioButton_8_clicked) #connection radioButton_8 |
||
self.radioButton_8.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 3", None)) |
self.radioButton_8.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 3", None)) |
||
self.checkBox_1 = QtGui.QCheckBox(self.centralWidget) |
self.checkBox_1 = QtGui.QCheckBox(self.centralWidget) |
||
self.checkBox_1.setGeometry(QtCore.QRect(20, 190, 140, 20)) |
self.checkBox_1.setGeometry(QtCore.QRect(20, 190, 140, 20)) |
||
Line 206: | Line 237: | ||
self.checkBox_1.setToolTip(_translate("MainWindow", "Affiche un point sur le centre du cercle", None)) |
self.checkBox_1.setToolTip(_translate("MainWindow", "Affiche un point sur le centre du cercle", None)) |
||
# self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked) #connection checkBox_1 |
# self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked) #connection checkBox_1 |
||
self.checkBox_2 = QtGui.QCheckBox(self.centralWidget) |
self.checkBox_2 = QtGui.QCheckBox(self.centralWidget) |
||
self.checkBox_2.setGeometry(QtCore.QRect(170, 190, 150, 20)) |
self.checkBox_2.setGeometry(QtCore.QRect(170, 190, 150, 20)) |
||
Line 213: | Line 244: | ||
self.checkBox_2.setToolTip(_translate("MainWindow", "Associe la couleur du cercle à la couleur des axes X,Y,Z (Orthogonal)", None)) |
self.checkBox_2.setToolTip(_translate("MainWindow", "Associe la couleur du cercle à la couleur des axes X,Y,Z (Orthogonal)", None)) |
||
# self.checkBox_2.clicked.connect(self.on_checkBox_2_clicked) #connection checkBox_1 |
# self.checkBox_2.clicked.connect(self.on_checkBox_2_clicked) #connection checkBox_1 |
||
self.lineEdit_1 = QtGui.QLineEdit(self.centralWidget) |
self.lineEdit_1 = QtGui.QLineEdit(self.centralWidget) |
||
self.lineEdit_1.setGeometry(QtCore.QRect(320, 30, 151, 22)) |
self.lineEdit_1.setGeometry(QtCore.QRect(320, 30, 151, 22)) |
||
self.lineEdit_1.setObjectName(_fromUtf8("lineEdit_1")) |
self.lineEdit_1.setObjectName(_fromUtf8("lineEdit_1")) |
||
self.lineEdit_1.setReadOnly(True) |
self.lineEdit_1.setReadOnly(True) |
||
self.lineEdit_2 = QtGui.QLineEdit(self.centralWidget) |
self.lineEdit_2 = QtGui.QLineEdit(self.centralWidget) |
||
self.lineEdit_2.setGeometry(QtCore.QRect(320, 80, 151, 22)) |
self.lineEdit_2.setGeometry(QtCore.QRect(320, 80, 151, 22)) |
||
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) |
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) |
||
self.lineEdit_2.setReadOnly(True) |
self.lineEdit_2.setReadOnly(True) |
||
self.lineEdit_3 = QtGui.QLineEdit(self.centralWidget) |
self.lineEdit_3 = QtGui.QLineEdit(self.centralWidget) |
||
self.lineEdit_3.setGeometry(QtCore.QRect(320, 130, 151, 22)) |
self.lineEdit_3.setGeometry(QtCore.QRect(320, 130, 151, 22)) |
||
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) |
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) |
||
self.lineEdit_3.setReadOnly(True) |
self.lineEdit_3.setReadOnly(True) |
||
self.lineEdit_4 = QtGui.QLineEdit(self.centralWidget) |
self.lineEdit_4 = QtGui.QLineEdit(self.centralWidget) |
||
self.lineEdit_4.setGeometry(QtCore.QRect(320, 180, 151, 22)) |
self.lineEdit_4.setGeometry(QtCore.QRect(320, 180, 151, 22)) |
||
self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4")) |
self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4")) |
||
self.lineEdit_4.setReadOnly(True) |
self.lineEdit_4.setReadOnly(True) |
||
self.lineEdit_5 = QtGui.QLineEdit(self.centralWidget) |
self.lineEdit_5 = QtGui.QLineEdit(self.centralWidget) |
||
self.lineEdit_5.setGeometry(QtCore.QRect(320, 230, 151, 22)) |
self.lineEdit_5.setGeometry(QtCore.QRect(320, 230, 151, 22)) |
||
self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5")) |
self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5")) |
||
self.lineEdit_5.setReadOnly(True) |
self.lineEdit_5.setReadOnly(True) |
||
self.label_1 = QtGui.QLabel(self.centralWidget) |
self.label_1 = QtGui.QLabel(self.centralWidget) |
||
self.label_1.setGeometry(QtCore.QRect(320, 10, 91, 16)) |
self.label_1.setGeometry(QtCore.QRect(320, 10, 91, 16)) |
||
self.label_1.setObjectName(_fromUtf8("label_1")) |
self.label_1.setObjectName(_fromUtf8("label_1")) |
||
self.label_2 = QtGui.QLabel(self.centralWidget) |
self.label_2 = QtGui.QLabel(self.centralWidget) |
||
self.label_2.setGeometry(QtCore.QRect(320, 60, 91, 16)) |
self.label_2.setGeometry(QtCore.QRect(320, 60, 91, 16)) |
||
self.label_2.setObjectName(_fromUtf8("label_2")) |
self.label_2.setObjectName(_fromUtf8("label_2")) |
||
self.label_3 = QtGui.QLabel(self.centralWidget) |
self.label_3 = QtGui.QLabel(self.centralWidget) |
||
self.label_3.setGeometry(QtCore.QRect(320, 110, 91, 16)) |
self.label_3.setGeometry(QtCore.QRect(320, 110, 91, 16)) |
||
self.label_3.setObjectName(_fromUtf8("label_3")) |
self.label_3.setObjectName(_fromUtf8("label_3")) |
||
self.label_4 = QtGui.QLabel(self.centralWidget) |
self.label_4 = QtGui.QLabel(self.centralWidget) |
||
self.label_4.setGeometry(QtCore.QRect(320, 160, 53, 16)) |
self.label_4.setGeometry(QtCore.QRect(320, 160, 53, 16)) |
||
self.label_4.setObjectName(_fromUtf8("label_4")) |
self.label_4.setObjectName(_fromUtf8("label_4")) |
||
self.label_5 = QtGui.QLabel(self.centralWidget) |
self.label_5 = QtGui.QLabel(self.centralWidget) |
||
self.label_5.setGeometry(QtCore.QRect(320, 210, 81, 16)) |
self.label_5.setGeometry(QtCore.QRect(320, 210, 81, 16)) |
||
self.label_5.setObjectName(_fromUtf8("label_5")) |
self.label_5.setObjectName(_fromUtf8("label_5")) |
||
self.pushButton_1 = QtGui.QPushButton(self.centralWidget) |
self.pushButton_1 = QtGui.QPushButton(self.centralWidget) |
||
self.pushButton_1.setGeometry(QtCore.QRect(20, 230, 90, 28)) |
self.pushButton_1.setGeometry(QtCore.QRect(20, 230, 90, 28)) |
||
Line 264: | Line 295: | ||
self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked) #connection pushButton_1 |
self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked) #connection pushButton_1 |
||
self.pushButton_1.setToolTip(_translate("MainWindow", "Quitte la fonction", None)) |
self.pushButton_1.setToolTip(_translate("MainWindow", "Quitte la fonction", None)) |
||
self.pushButton_2 = QtGui.QPushButton(self.centralWidget) |
self.pushButton_2 = QtGui.QPushButton(self.centralWidget) |
||
self.pushButton_2.setGeometry(QtCore.QRect(110, 230, 90, 28)) |
self.pushButton_2.setGeometry(QtCore.QRect(110, 230, 90, 28)) |
||
Line 273: | Line 304: | ||
#self.pushButton_2.setStyleSheet("color : #ff0000") #cette fonction donne une couleur au texte du bouton |
#self.pushButton_2.setStyleSheet("color : #ff0000") #cette fonction donne une couleur au texte du bouton |
||
#self.pushButton_2.setStyleSheet("color : #ff0000; background-color : #0000ff;" ) #combinaison des deux |
#self.pushButton_2.setStyleSheet("color : #ff0000; background-color : #0000ff;" ) #combinaison des deux |
||
self.pushButton_3 = QtGui.QPushButton(self.centralWidget) |
self.pushButton_3 = QtGui.QPushButton(self.centralWidget) |
||
self.pushButton_3.setGeometry(QtCore.QRect(200, 230, 90, 28)) |
self.pushButton_3.setGeometry(QtCore.QRect(200, 230, 90, 28)) |
||
Line 279: | Line 310: | ||
self.pushButton_3.clicked.connect(self.on_pushButton_3_clicked) #connection pushButton_3 |
self.pushButton_3.clicked.connect(self.on_pushButton_3_clicked) #connection pushButton_3 |
||
self.pushButton_3.setToolTip(_translate("MainWindow", "Définit le mode par défaut (Cercle sur 3 points dans l'espace)", None)) |
self.pushButton_3.setToolTip(_translate("MainWindow", "Définit le mode par défaut (Cercle sur 3 points dans l'espace)", None)) |
||
MainWindow.setCentralWidget(self.centralWidget) |
MainWindow.setCentralWidget(self.centralWidget) |
||
self.statusBar = QtGui.QStatusBar(MainWindow) |
self.statusBar = QtGui.QStatusBar(MainWindow) |
||
self.statusBar.setObjectName(_fromUtf8("statusBar")) |
self.statusBar.setObjectName(_fromUtf8("statusBar")) |
||
MainWindow.setStatusBar(self.statusBar) |
MainWindow.setStatusBar(self.statusBar) |
||
self.retranslateUi(MainWindow) |
self.retranslateUi(MainWindow) |
||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
||
def retranslateUi(self, MainWindow): |
def retranslateUi(self, MainWindow): |
||
try: |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # cette fonction met la fenêtre en avant |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
#MainWindow.setStyleSheet("background-color: red") #cette fonction donne une couleur à la fenêtre |
#MainWindow.setStyleSheet("background-color: red") #cette fonction donne une couleur à la fenêtre |
||
#MainWindow.setWindowOpacity(0.5) #cette fonction donne une transparence à la fenêtre |
#MainWindow.setWindowOpacity(0.5) #cette fonction donne une transparence à la fenêtre |
||
Line 343: | Line 377: | ||
App.Console.PrintMessage("Terminé\r\n") |
App.Console.PrintMessage("Terminé\r\n") |
||
self.window.hide() |
self.window.hide() |
||
def on_pushButton_2_clicked(self): # Bouton Appliquer |
def on_pushButton_2_clicked(self): # Bouton Appliquer |
||
if self.radioButton_1.isChecked(): |
if self.radioButton_1.isChecked(): |
||
Line 353: | Line 387: | ||
if self.radioButton_4.isChecked(): |
if self.radioButton_4.isChecked(): |
||
vueChoix=3 |
vueChoix=3 |
||
if self.radioButton_5.isChecked(): |
if self.radioButton_5.isChecked(): |
||
alignerSur=0 |
alignerSur=0 |
||
Line 362: | Line 396: | ||
if self.radioButton_8.isChecked(): |
if self.radioButton_8.isChecked(): |
||
alignerSur=3 |
alignerSur=3 |
||
if self.checkBox_1.checkState()==0: |
if self.checkBox_1.checkState()==0: |
||
afficherPoint=0 |
afficherPoint=0 |
||
Line 371: | Line 405: | ||
else: |
else: |
||
colorer=1 |
colorer=1 |
||
# App.Console.PrintMessage("Appliquer\r\n") |
# App.Console.PrintMessage("Appliquer\r\n") |
||
# App.Console.PrintMessage(str(vueChoix)+" \t") |
# App.Console.PrintMessage(str(vueChoix)+" \t") |
||
Line 377: | Line 411: | ||
# App.Console.PrintMessage(str(afficherPoint)+" \t") |
# App.Console.PrintMessage(str(afficherPoint)+" \t") |
||
# App.Console.PrintMessage(str(colorer)+" \r\n") |
# App.Console.PrintMessage(str(colorer)+" \r\n") |
||
def errorDialog(msg): |
def errorDialog(msg): |
||
# Create a simple dialog QMessageBox |
# Create a simple dialog QMessageBox |
||
# The first argument indicates the icon used: one of QtGui.QMessageBox.{NoIcon, Information, Warning, Critical, Question} |
# 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 = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg) |
||
try: |
|||
diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # cette fonction met la fenêtre en avant |
|||
diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
#diag.setWindowModality(QtCore.Qt.ApplicationModal) # la fonction a été désactivée pour favoriser "WindowStaysOnTopHint" |
#diag.setWindowModality(QtCore.Qt.ApplicationModal) # la fonction a été désactivée pour favoriser "WindowStaysOnTopHint" |
||
diag.exec_() |
diag.exec_() |
||
def affiche(x,y,z,rayon,r,v,b,afficherPoint,angle): |
def affiche(x,y,z,rayon,r,v,b,afficherPoint,angle): |
||
pl.Base=FreeCAD.Vector(x,y,z) |
pl.Base=FreeCAD.Vector(x,y,z) |
||
Line 400: | Line 437: | ||
str(self.lineEdit_4.setText(str(rayon))) |
str(self.lineEdit_4.setText(str(rayon))) |
||
str(self.lineEdit_5.setText(str(angle))) |
str(self.lineEdit_5.setText(str(angle))) |
||
# prendre les objets selectionnes |
# prendre les objets selectionnes |
||
sel = FreeCADGui.Selection.getSelection() |
sel = FreeCADGui.Selection.getSelection() |
||
i=0 |
i=0 |
||
centreX=0;centreY=0;rayon=0 |
centreX=0;centreY=0;rayon=0 |
||
# S'il y a 3 points sélectionnés alors.. |
# S'il y a 3 points sélectionnés alors.. |
||
if len(sel)==3 : |
if len(sel)==3 : |
||
Line 416: | Line 453: | ||
ta[i+2]=(x.z) |
ta[i+2]=(x.z) |
||
i=i+3 |
i=i+3 |
||
if vueChoix==3: # Vue de droite ZY (Rouge) |
if vueChoix==3: # Vue de droite ZY (Rouge) |
||
z_point_1=ta[0] |
z_point_1=ta[0] |
||
x_point_1=ta[1] |
x_point_1=ta[1] |
||
y_point_1=ta[2] |
y_point_1=ta[2] |
||
z_point_2=ta[3] |
z_point_2=ta[3] |
||
x_point_2=ta[4] |
x_point_2=ta[4] |
||
y_point_2=ta[5] |
y_point_2=ta[5] |
||
z_point_3=ta[6] |
z_point_3=ta[6] |
||
x_point_3=ta[7] |
x_point_3=ta[7] |
||
y_point_3=ta[8] |
y_point_3=ta[8] |
||
elif vueChoix==2: # Vue de face ZX (Vert) |
elif vueChoix==2: # Vue de face ZX (Vert) |
||
y_point_1=ta[0] |
y_point_1=ta[0] |
||
z_point_1=ta[1] |
z_point_1=ta[1] |
||
x_point_1=ta[2] |
x_point_1=ta[2] |
||
y_point_2=ta[3] |
y_point_2=ta[3] |
||
z_point_2=ta[4] |
z_point_2=ta[4] |
||
x_point_2=ta[5] |
x_point_2=ta[5] |
||
y_point_3=ta[6] |
y_point_3=ta[6] |
||
z_point_3=ta[7] |
z_point_3=ta[7] |
||
x_point_3=ta[8] |
x_point_3=ta[8] |
||
else: # Vue de dessus XY (Bleu) |
else: # Vue de dessus XY (Bleu) |
||
x_point_1=ta[0] |
x_point_1=ta[0] |
||
y_point_1=ta[1] |
y_point_1=ta[1] |
||
z_point_1=ta[2] |
z_point_1=ta[2] |
||
x_point_2=ta[3] |
x_point_2=ta[3] |
||
y_point_2=ta[4] |
y_point_2=ta[4] |
||
z_point_2=ta[5] |
z_point_2=ta[5] |
||
x_point_3=ta[6] |
x_point_3=ta[6] |
||
y_point_3=ta[7] |
y_point_3=ta[7] |
||
z_point_3=ta[8] |
z_point_3=ta[8] |
||
# Calcul des coordonnées du centre du cercle |
# Calcul des coordonnées du centre du cercle |
||
try: |
try: |
||
Line 497: | Line 534: | ||
P2 = sel[1].Shape.BoundBox.Center |
P2 = sel[1].Shape.BoundBox.Center |
||
P3 = sel[2].Shape.BoundBox.Center |
P3 = sel[2].Shape.BoundBox.Center |
||
P1P2 = (P2 - P1).Length |
P1P2 = (P2 - P1).Length |
||
P2P3 = (P3 - P2).Length |
P2P3 = (P3 - P2).Length |
||
P3P1 = (P1 - P3).Length |
P3P1 = (P1 - P3).Length |
||
# Circle radius. |
# Circle radius. |
||
l = ((P1 - P2).cross(P2 - P3)).Length |
l = ((P1 - P2).cross(P2 - P3)).Length |
||
Line 519: | Line 556: | ||
P3.multiply(c) |
P3.multiply(c) |
||
PC = P1 + P2 + P3 |
PC = P1 + P2 + P3 |
||
# Creation of a circle |
# Creation of a circle |
||
pl = Base.Placement() |
pl = Base.Placement() |
||
Line 529: | Line 566: | ||
pl = Base.Placement(PC, axis, angle) |
pl = Base.Placement(PC, axis, angle) |
||
affiche((PC.x),(PC.y),(PC.z),r,0.0,0.0,0.0,afficherPoint,angle) |
affiche((PC.x),(PC.y),(PC.z),r,0.0,0.0,0.0,afficherPoint,angle) |
||
else: |
else: |
||
# Si la condition n'est pas remplie, recommencer |
# Si la condition n'est pas remplie, recommencer |
||
Line 545: | Line 582: | ||
colorer=1 # colorer suivant l'axe 1=Ok 0=Couleur courante uniquement Orthogonal ! |
colorer=1 # colorer suivant l'axe 1=Ok 0=Couleur courante uniquement Orthogonal ! |
||
self.checkBox_2.setChecked(True) |
self.checkBox_2.setChecked(True) |
||
#______________________________________________________________________________________ |
#______________________________________________________________________________________ |
||
MainWindow = QtGui.QMainWindow() |
MainWindow = QtGui.QMainWindow() |
||
ui = Ui_MainWindow(MainWindow) |
ui = Ui_MainWindow(MainWindow) |
||
MainWindow.show() |
MainWindow.show() |
||
}} |
|||
==Cesta== |
|||
</syntaxhighlight> |
|||
Soubor by měl být zkopírován do " '''C:/Program Files/FreeCAD0.13/''' " Chcete-li jej uložit do jiného adresáře, upravte cestu k němu na řádku 53 |
|||
{{Code|code= |
|||
path = FreeCAD.ConfigGet("AppHomePath") # chemin |
|||
}} |
|||
==Anaglyphe== |
==Anaglyphe (3D zobrazení)== |
||
Zde je 3D zobrazení, které umožňuje vidět 2 různé pozice pohledu použitím brýlí s filtry pro červenou a cyan barvu [[Image:Anaglyph_Tango.png|24px]].<br /> |
|||
Podívejte se střídavě pravým a levým okem abyste viděli pohledy samostatně.<br /> |
|||
Watch alternately with the left eye and the right eye to see the views separately.<br /> |
|||
<center> |
<center> |
||
[[File:Cercle3Points2D_anaglyphe.png|480px| |
[[File:Cercle3Points2D_anaglyphe.png|480px|3D pohled]] |
||
</center> |
</center> |
||
{{clear}} |
{{clear}} |
||
== |
==Poděkování== |
||
Geneze makra '''Draft_Circle_3_Points''' [http://forum.freecadweb.org/viewtopic.php?f=12&t=3696&sid=17886f953113e162dc9a4a843e1fce94 sur le forum (PYTHON) coordonnées d'un point] s pomocí flachyjoe díky.<br /> |
|||
Vzorec je od [http://www-obs.univ-lyon1.fr/labo/fc/Ateliers_archives/ateliers_2005-06/cercle_3pts.pdf cercle_3pts.pdf] a je použit s laskavým svolením autora.<br /> |
|||
Vzorec kružnice upravený " galou_breizh " do 3D prostoru pochází z |
|||
[http://en.wikipedia.org/wiki/Circumscribed_circle Circumscribed_circle]<br /> |
[http://en.wikipedia.org/wiki/Circumscribed_circle Circumscribed_circle]<br /> |
||
Samostatné programy jsou umístěny zde,<br /> |
|||
[[Macro_Draft_Circle_3_Points|Macro_Draft_Circle_3_Points]]<br /> |
[[Macro_Draft_Circle_3_Points|Macro_Draft_Circle_3_Points]]<br /> |
||
[[Macro_Draft_Circle_3_Points_3D|Macro_Draft_Circle_3_Points_3D]] |
[[Macro_Draft_Circle_3_Points_3D|Macro_Draft_Circle_3_Points_3D]] |
||
<languages/> |
Latest revision as of 11:07, 23 May 2020
Popis |
---|
Vytváří kružnici ze 3 vybraných bodů nebo tvarů. Version macro : 1.0 Date last modification : 2014-08-08 FreeCAD version : All Download : ToolBar Icon Icon View-Top Icon View-Left Icon View-Front Icon View-C3P Autor: Mario52 |
Autor |
Mario52 |
Download |
ToolBar Icon Icon View-Top Icon View-Left Icon View-Front Icon View-C3P |
Odkazy |
Makro recepty| Jak nainstalovat makra Jak přizpůsobit panely nástrojů |
Verze |
1.0 |
Datum poslední úpravy |
2014-08-08 |
Verze FreeCAD |
All |
Výchozí zástupce |
None |
Viz též |
None |
Popis
Toto makro vytváří kružnici opsanou 3 vybraným bodům na kolmicích nebo ve 3D zvoleném prostoru. Body mohou být objekty jako jsou krychle, válce,..., potom souřadnicemi budou středy vybraných tvarů.
Circle built on 3 selected points
Použití
Vyberte 3 body nebo tvary ve 3D pohledu a spusťte makro.
Je-li tvarem přímka, souřadnicí bude střed přímky.
Volby
Mód :
Defaut(přednastavený) :
- Defaultní mód vytváří kružnici podle 3 bodů nebo tvarů ve 3D prostoru.
- Pořadí vybíraných bodů u tvarů ovlivňuje úhly odklonu OS a zpětně odklon kružnice. V případě potřeby se lze vrátit a změnit pořadí výběru tvarů.
- Souřadnice X, Y, Z s hodnotou 0 nebo zarovnání, které neumožňuje výpočet, může vrátit chybu dělení nulou se zprávou Tyto tři body jsou vyrovnány
Vue Face :
- Vytváří kružnici v nárysu vybraného tvaru, 1, 2 or 3
Vue Dessus :
- Vytváří kružnici v půdorysu vybraného tvaru, 1, 2 or 3
Vue Droite :
- Vytváří kružnici v bokorysu vybraného tvaru, 1, 2 or 3
Alignement sur :
Forme 1, 2, 3
- Tvary podle jejich výběru.
Afficher le centre :
- Je-li políčko zakliknuto, bude vytvořen i středový bod kružnice
Associer les couleurs
- Je-li políčko zakliknuto, kružnice přebere barvu aktuálního pohledu,
- Pohled shora (X,Y) = Modrá(osa Z)
- Pohled zepředu (Z,X) = Zelená(osa Y)
- Pohled zleva (Z,Y) = Červená(osa X)
-
Kružnice na 3 tvarech (pohled zepředu),
-
na kolmicích na vybraném tvaru (pohled zprava)
-
-
Tři nezávislé kolmé kružnice na vybraném tvaru.
Skript
Tyto tři ikony musejí být ve stejném adresáři jako makro.
Stáhněte je kliknutím pravou myší na obrázek a dejte Uložit obrázek jako ...
Make_Circle_3_Points.FCMacro
# -*- coding: utf-8 -*- # Cercle sur 3 points.py # create a circle from 3 points selected # combination of the two programs 'create a circle from 3 points selected' # with as options (orthogonal) circle can be built on a choice plans # to coordinate one of the three selected choice shapes # mode by default, creates the circle in 3D space # the options create the circle of orthogonal way on the map and view the choice # with the creation of a central color related to the axes Y/N Y/N # 04/03/2013 # 24/03/2013 # 08/08/2014 by mario52 # the formula adapted (with permission of its author) by "mario52" for orthogonal circles comes from # http://www-obs.univ-lyon1.fr/labo/fc/Ateliers_archives/ateliers_2005-06/cercle_3pts.pdf # read the note in pdf, on the order of selection points, # If the formula returns an error (example the 3 points in the same alignment) # the formula adapted by "galou_breizh" for the cecle in 3D space comes from # http://en.wikipedia.org/wiki/Circumscribed_circle # the window is always visible and allows you to work on other programs # as for example to select other items in FreeCAD #08/08/2014 PyQt4 and PySide #OS: Windows Vista #Word size: 32-bit #Version: 0.14.3700 (Git) #Branch: releases/FreeCAD-0-14 #Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1 #Python version: 2.6.2 #Qt version: 4.5.2 #Coin version: 3.1.0 #SoQt version: 1.4.1 #OCC version: 6.5.1 try: import PyQt4 from PyQt4 import QtCore, QtGui except Exception: import PySide from PySide import QtCore, QtGui import Draft, Part, FreeCAD, math, PartGui, FreeCADGui from math import sqrt, pi, sin, cos, asin from FreeCAD import Base # vueChoix = 0 et alignerSur = 0 , mode par défaut global vueChoix # choix de la vue Dessus=1 XY, vue Face=2 ZX, vue Droite=3 ZY (Orthogonal) global alignerSur # aligne le cercle sur une forme au choix (1,2 ou 3) ou sur Z=0 (Orthogonal) global afficherPoint# affiche le point central du cercle global colorer # colorer suivant l'axe 1=Ok 0=Couleur courante uniquement Orthogonal ! vueChoix = 0 alignerSur = 0 afficherPoint = 1 colorer = 1 try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_MainWindow(object): def __init__(self, MainWindow): self.window = MainWindow path = FreeCAD.ConfigGet("AppHomePath") # chemin MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(490, 302) MainWindow.setWindowIcon(QtGui.QIcon(path+'View-C3P.png')) self.centralWidget = QtGui.QWidget(MainWindow) self.centralWidget.setObjectName(_fromUtf8("centralWidget")) self.groupBox = QtGui.QGroupBox(self.centralWidget) self.groupBox.setGeometry(QtCore.QRect(20, 10, 130, 161)) self.groupBox.setObjectName(_fromUtf8("groupBox_1")) self.radioButton_1 = QtGui.QRadioButton(self.groupBox) self.radioButton_1.setGeometry(QtCore.QRect(10, 30, 130, 20)) self.radioButton_1.setChecked(True) self.radioButton_1.setObjectName(_fromUtf8("radioButton_1")) self.radioButton_1.clicked.connect(self.on_radioButton_1_clicked) #connection radioButton_1 self.radioButton_1.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) self.radioButton_2 = QtGui.QRadioButton(self.groupBox) self.radioButton_2.setGeometry(QtCore.QRect(10, 60, 130, 20)) self.radioButton_2.setObjectName(_fromUtf8("radioButton_2")) self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) #connection radioButton_2 self.radioButton_2.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la vue de face", None)) #self.image_01 = "C:\Program Files\FreeCAD0.13\View-Front.png" self.image_01 = path+"View-Front.png" icon01 = QtGui.QIcon() icon01.addPixmap(QtGui.QPixmap(self.image_01),QtGui.QIcon.Normal, QtGui.QIcon.Off) self.radioButton_2.setIcon(icon01) self.radioButton_3 = QtGui.QRadioButton(self.groupBox) self.radioButton_3.setGeometry(QtCore.QRect(10, 90, 130, 20)) self.radioButton_3.setObjectName(_fromUtf8("radioButton_3")) self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) #connection radioButton_3 self.radioButton_3.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la vue de dessus", None)) #self.image_02 = "C:\Program Files\FreeCAD0.13\View-Top.png" self.image_02 = path+"View-Top.png" icon02 = QtGui.QIcon() icon02.addPixmap(QtGui.QPixmap(self.image_02),QtGui.QIcon.Normal, QtGui.QIcon.Off) self.radioButton_3.setIcon(icon02) self.radioButton_4 = QtGui.QRadioButton(self.groupBox) self.radioButton_4.setGeometry(QtCore.QRect(10, 120, 130, 20)) self.radioButton_4.setObjectName(_fromUtf8("radioButton_4")) self.radioButton_4.clicked.connect(self.on_radioButton_4_clicked) #connection radioButton_4 self.radioButton_4.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la vue de droite", None)) #self.image_03 = "C:\Program Files\FreeCAD0.13\View-Left.png" self.image_03 = path+"View-Left.png" icon03 = QtGui.QIcon() icon03.addPixmap(QtGui.QPixmap(self.image_03),QtGui.QIcon.Normal, QtGui.QIcon.Off) self.radioButton_4.setIcon(icon03) self.groupBox_2 = QtGui.QGroupBox(self.centralWidget) self.groupBox_2.setGeometry(QtCore.QRect(170, 10, 120, 161)) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.radioButton_5 = QtGui.QRadioButton(self.groupBox_2) self.radioButton_5.setGeometry(QtCore.QRect(10, 30, 95, 20)) self.radioButton_5.setChecked(True) self.radioButton_5.setObjectName(_fromUtf8("radioButton_5")) self.radioButton_5.clicked.connect(self.on_radioButton_5_clicked) #connection radioButton_5 self.radioButton_5.setToolTip(_translate("MainWindow", "Cercle sur 3 points dans l'espace", None)) self.radioButton_6 = QtGui.QRadioButton(self.groupBox_2) self.radioButton_6.setGeometry(QtCore.QRect(10, 60, 95, 20)) self.radioButton_6.setObjectName(_fromUtf8("radioButton_6")) self.radioButton_6.clicked.connect(self.on_radioButton_6_clicked) #connection radioButton_6 self.radioButton_6.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 1", None)) self.radioButton_7 = QtGui.QRadioButton(self.groupBox_2) self.radioButton_7.setGeometry(QtCore.QRect(10, 90, 95, 20)) self.radioButton_7.setObjectName(_fromUtf8("radioButton_7")) self.radioButton_7.clicked.connect(self.on_radioButton_7_clicked) #connection radioButton_7 self.radioButton_7.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 2", None)) self.radioButton_8 = QtGui.QRadioButton(self.groupBox_2) self.radioButton_8.setGeometry(QtCore.QRect(10, 120, 95, 20)) self.radioButton_8.setObjectName(_fromUtf8("radioButton_8")) self.radioButton_8.clicked.connect(self.on_radioButton_8_clicked) #connection radioButton_8 self.radioButton_8.setToolTip(_translate("MainWindow", "Cercle orthogonal sur la forme 3", None)) self.checkBox_1 = QtGui.QCheckBox(self.centralWidget) self.checkBox_1.setGeometry(QtCore.QRect(20, 190, 140, 20)) self.checkBox_1.setChecked(True) self.checkBox_1.setObjectName(_fromUtf8("checkBox_1")) self.checkBox_1.setToolTip(_translate("MainWindow", "Affiche un point sur le centre du cercle", None)) # self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked) #connection checkBox_1 self.checkBox_2 = QtGui.QCheckBox(self.centralWidget) self.checkBox_2.setGeometry(QtCore.QRect(170, 190, 150, 20)) self.checkBox_2.setChecked(True) self.checkBox_2.setObjectName(_fromUtf8("checkBox_2")) self.checkBox_2.setToolTip(_translate("MainWindow", "Associe la couleur du cercle à la couleur des axes X,Y,Z (Orthogonal)", None)) # self.checkBox_2.clicked.connect(self.on_checkBox_2_clicked) #connection checkBox_1 self.lineEdit_1 = QtGui.QLineEdit(self.centralWidget) self.lineEdit_1.setGeometry(QtCore.QRect(320, 30, 151, 22)) self.lineEdit_1.setObjectName(_fromUtf8("lineEdit_1")) self.lineEdit_1.setReadOnly(True) self.lineEdit_2 = QtGui.QLineEdit(self.centralWidget) self.lineEdit_2.setGeometry(QtCore.QRect(320, 80, 151, 22)) self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) self.lineEdit_2.setReadOnly(True) self.lineEdit_3 = QtGui.QLineEdit(self.centralWidget) self.lineEdit_3.setGeometry(QtCore.QRect(320, 130, 151, 22)) self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) self.lineEdit_3.setReadOnly(True) self.lineEdit_4 = QtGui.QLineEdit(self.centralWidget) self.lineEdit_4.setGeometry(QtCore.QRect(320, 180, 151, 22)) self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4")) self.lineEdit_4.setReadOnly(True) self.lineEdit_5 = QtGui.QLineEdit(self.centralWidget) self.lineEdit_5.setGeometry(QtCore.QRect(320, 230, 151, 22)) self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5")) self.lineEdit_5.setReadOnly(True) self.label_1 = QtGui.QLabel(self.centralWidget) self.label_1.setGeometry(QtCore.QRect(320, 10, 91, 16)) self.label_1.setObjectName(_fromUtf8("label_1")) self.label_2 = QtGui.QLabel(self.centralWidget) self.label_2.setGeometry(QtCore.QRect(320, 60, 91, 16)) self.label_2.setObjectName(_fromUtf8("label_2")) self.label_3 = QtGui.QLabel(self.centralWidget) self.label_3.setGeometry(QtCore.QRect(320, 110, 91, 16)) self.label_3.setObjectName(_fromUtf8("label_3")) self.label_4 = QtGui.QLabel(self.centralWidget) self.label_4.setGeometry(QtCore.QRect(320, 160, 53, 16)) self.label_4.setObjectName(_fromUtf8("label_4")) self.label_5 = QtGui.QLabel(self.centralWidget) self.label_5.setGeometry(QtCore.QRect(320, 210, 81, 16)) self.label_5.setObjectName(_fromUtf8("label_5")) self.pushButton_1 = QtGui.QPushButton(self.centralWidget) self.pushButton_1.setGeometry(QtCore.QRect(20, 230, 90, 28)) self.pushButton_1.setObjectName(_fromUtf8("pushButton_1")) self.pushButton_1.clicked.connect(self.on_pushButton_1_clicked) #connection pushButton_1 self.pushButton_1.setToolTip(_translate("MainWindow", "Quitte la fonction", None)) self.pushButton_2 = QtGui.QPushButton(self.centralWidget) self.pushButton_2.setGeometry(QtCore.QRect(110, 230, 90, 28)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton_2.clicked.connect(self.on_pushButton_2_clicked) #connection pushButton_2 self.pushButton_2.setToolTip(_translate("MainWindow", "Applique la fonction sans quitter", None)) #self.pushButton_2.setStyleSheet("background-color: red") #cette fonction donne une couleur au bouton #self.pushButton_2.setStyleSheet("color : #ff0000") #cette fonction donne une couleur au texte du bouton #self.pushButton_2.setStyleSheet("color : #ff0000; background-color : #0000ff;" ) #combinaison des deux self.pushButton_3 = QtGui.QPushButton(self.centralWidget) self.pushButton_3.setGeometry(QtCore.QRect(200, 230, 90, 28)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) self.pushButton_3.clicked.connect(self.on_pushButton_3_clicked) #connection pushButton_3 self.pushButton_3.setToolTip(_translate("MainWindow", "Définit le mode par défaut (Cercle sur 3 points dans l'espace)", None)) MainWindow.setCentralWidget(self.centralWidget) self.statusBar = QtGui.QStatusBar(MainWindow) self.statusBar.setObjectName(_fromUtf8("statusBar")) MainWindow.setStatusBar(self.statusBar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): try: MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant except Exception: MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant #MainWindow.setStyleSheet("background-color: red") #cette fonction donne une couleur à la fenêtre #MainWindow.setWindowOpacity(0.5) #cette fonction donne une transparence à la fenêtre MainWindow.setWindowTitle(_translate("MainWindow", "Cercle sur 3 points", None)) self.groupBox.setTitle(_translate("MainWindow", "Mode", None)) self.radioButton_1.setText(_translate("MainWindow", "Défaut", None)) self.radioButton_2.setText(_translate("MainWindow", "Vue Face", None)) self.radioButton_3.setText(_translate("MainWindow", "Vue Dessus", None)) self.radioButton_4.setText(_translate("MainWindow", "Vue Droite", None)) self.groupBox_2.setTitle(_translate("MainWindow", "Alignement sur", None)) self.radioButton_5.setText(_translate("MainWindow", "Défaut", None)) self.radioButton_6.setText(_translate("MainWindow", "Forme 1", None)) self.radioButton_7.setText(_translate("MainWindow", "Forme 2", None)) self.radioButton_8.setText(_translate("MainWindow", "Forme 3", None)) self.checkBox_1.setText(_translate("MainWindow", "Afficher le centre", None)) self.checkBox_2.setText(_translate("MainWindow", "Associer les couleurs", None)) self.label_1.setText(_translate("MainWindow", "Coordonnée X", None)) self.label_2.setText(_translate("MainWindow", "Coordonnée Y", None)) self.label_3.setText(_translate("MainWindow", "Coordonnée Z", None)) self.label_4.setText(_translate("MainWindow", "Rayon", None)) self.label_5.setText(_translate("MainWindow", "Angle", None)) self.pushButton_1.setText(_translate("MainWindow", "Quitter", None)) self.pushButton_2.setText(_translate("MainWindow", "Appliquer", None)) self.pushButton_3.setText(_translate("MainWindow", "Défaut", None)) # première série de radioboutons def on_radioButton_1_clicked(self): if self.radioButton_1.isChecked(): self.radioButton_5.setChecked(True) def on_radioButton_2_clicked(self): if self.radioButton_5.isChecked(): self.radioButton_6.setChecked(True) def on_radioButton_3_clicked(self): if self.radioButton_5.isChecked(): self.radioButton_6.setChecked(True) def on_radioButton_4_clicked(self): if self.radioButton_5.isChecked(): self.radioButton_6.setChecked(True) # deuxième série de radioboutons def on_radioButton_5_clicked(self): if self.radioButton_5.isChecked(): self.radioButton_1.setChecked(True) def on_radioButton_6_clicked(self): if self.radioButton_1.isChecked(): self.radioButton_2.setChecked(True) def on_radioButton_7_clicked(self): if self.radioButton_1.isChecked(): self.radioButton_2.setChecked(True) def on_radioButton_8_clicked(self): if self.radioButton_1.isChecked(): self.radioButton_2.setChecked(True) # Boutons def on_pushButton_1_clicked(self): # Bouton Quitte la fonction App.Console.PrintMessage("Terminé\r\n") self.window.hide() def on_pushButton_2_clicked(self): # Bouton Appliquer if self.radioButton_1.isChecked(): vueChoix=0 if self.radioButton_2.isChecked(): vueChoix=1 if self.radioButton_3.isChecked(): vueChoix=2 if self.radioButton_4.isChecked(): vueChoix=3 if self.radioButton_5.isChecked(): alignerSur=0 if self.radioButton_6.isChecked(): alignerSur=1 if self.radioButton_7.isChecked(): alignerSur=2 if self.radioButton_8.isChecked(): alignerSur=3 if self.checkBox_1.checkState()==0: afficherPoint=0 else: afficherPoint=1 if self.checkBox_2.checkState()==0: colorer=0 else: colorer=1 # App.Console.PrintMessage("Appliquer\r\n") # App.Console.PrintMessage(str(vueChoix)+" \t") # App.Console.PrintMessage(str(alignerSur)+" \t") # App.Console.PrintMessage(str(afficherPoint)+" \t") # App.Console.PrintMessage(str(colorer)+" \r\n") 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) try: diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant except Exception: diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant #diag.setWindowModality(QtCore.Qt.ApplicationModal) # la fonction a été désactivée pour favoriser "WindowStaysOnTopHint" diag.exec_() def affiche(x,y,z,rayon,r,v,b,afficherPoint,angle): pl.Base=FreeCAD.Vector(x,y,z) Draft.makeCircle((rayon),placement=pl,face=False,support=None) if colorer==1: FreeCADGui.activeDocument().activeObject().LineColor = (r,v,b) if afficherPoint==1: Draft.makePoint(x,y,z) if colorer==1: FreeCADGui.activeDocument().activeObject().PointColor = (r,v,b) str(self.lineEdit_1.setText(str(x))) str(self.lineEdit_2.setText(str(y))) str(self.lineEdit_3.setText(str(z))) str(self.lineEdit_4.setText(str(rayon))) str(self.lineEdit_5.setText(str(angle))) # 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 if vueChoix==3: # Vue de droite ZY (Rouge) 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: # Vue de face ZX (Vert) 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: # Vue de dessus XY (Bleu) 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] # Calcul des coordonnées du centre du cercle 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"Calcul impossible trop d'élements alignés") else: #finally: # si finally est présent, il sera TOUJOURS exécuté # Définition de la coordonnée 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,0) elif alignerSur==2: affiche(centreX,centreY,z_point_2,rayon,0.0,0.0,1.0,afficherPoint,0) elif alignerSur==3: affiche(centreX,centreY,z_point_3,rayon,0.0,0.0,1.0,afficherPoint,0) 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,0) elif alignerSur==2: affiche(centreY,z_point_2,centreX,rayon,0.0,1.0,0.0,afficherPoint,0) elif alignerSur==3: affiche(centreY,z_point_3,centreX,rayon,0.0,1.0,0.0,afficherPoint,0) 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,0) elif alignerSur==2: affiche(z_point_2,centreX,centreY,rayon,1.0,0.0,0.0,afficherPoint,0) elif alignerSur==3: affiche(z_point_3,centreX,centreY,rayon,1.0,0.0,0.0,afficherPoint,0) else: # 3D XYZ P1 = sel[0].Shape.BoundBox.Center P2 = sel[1].Shape.BoundBox.Center P3 = sel[2].Shape.BoundBox.Center P1P2 = (P2 - P1).Length P2P3 = (P3 - P2).Length P3P1 = (P1 - P3).Length # Circle radius. l = ((P1 - P2).cross(P2 - P3)).Length try: #if l < 1e-8: # errorDialog("The three points are aligned") r = P1P2 * P2P3 * P3P1 / 2 / l except: errorDialog("The three points are aligned") else: # Sphere center. a = P2P3**2 * (P1 - P2).dot(P1 - P3) / 2 / l**2 b = P3P1**2 * (P2 - P1).dot(P2 - P3) / 2 / l**2 c = P1P2**2 * (P3 - P1).dot(P3 - P2) / 2 / l**2 P1.multiply(a) P2.multiply(b) P3.multiply(c) PC = P1 + P2 + P3 # Creation of a circle pl = Base.Placement() v = (P1 - P2).cross(P3 - P2) v.normalize() axis = Base.Vector(0, 0, 1).cross(v) angle = asin(axis.Length) * 180 / pi axis.normalize() pl = Base.Placement(PC, axis, angle) affiche((PC.x),(PC.y),(PC.z),r,0.0,0.0,0.0,afficherPoint,angle) else: # Si la condition n'est pas remplie, recommencer errorDialog(u"Sélectionnez 3 points et recommencez") #FreeCAD.Console.PrintError("Sélectionnez 3 points et recommencez\r\n") #________________________________________________________________________________ def on_pushButton_3_clicked(self): # Valeurs d'origine App.Console.PrintMessage("Défaut\r\n") vueChoix=0 # choix de la vue Dessus=1 XY, vue Face=2 ZX, vue Droite=3 ZY self.radioButton_1.setChecked(True) alignerSur=0 # aligne le cercle sur une forme au choix (1,2 ou 3) ou sur Z=0 self.radioButton_5.setChecked(True) afficherPoint=1 # affiche le point central du cercle self.checkBox_1.setChecked(True) colorer=1 # colorer suivant l'axe 1=Ok 0=Couleur courante uniquement Orthogonal ! self.checkBox_2.setChecked(True) #______________________________________________________________________________________ MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow(MainWindow) MainWindow.show()
Cesta
Soubor by měl být zkopírován do " C:/Program Files/FreeCAD0.13/ " Chcete-li jej uložit do jiného adresáře, upravte cestu k němu na řádku 53
path = FreeCAD.ConfigGet("AppHomePath") # chemin
Anaglyphe (3D zobrazení)
Zde je 3D zobrazení, které umožňuje vidět 2 různé pozice pohledu použitím brýlí s filtry pro červenou a cyan barvu .
Podívejte se střídavě pravým a levým okem abyste viděli pohledy samostatně.
Poděkování
Geneze makra Draft_Circle_3_Points sur le forum (PYTHON) coordonnées d'un point s pomocí flachyjoe díky.
Vzorec je od cercle_3pts.pdf a je použit s laskavým svolením autora.
Vzorec kružnice upravený " galou_breizh " do 3D prostoru pochází z
Circumscribed_circle
Samostatné programy jsou umístěny zde,
Macro_Draft_Circle_3_Points
Macro_Draft_Circle_3_Points_3D