Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active December 18, 2021 19:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mario52a/0ed8129bacbe9124a41e3ae1d378d5b7 to your computer and use it in GitHub Desktop.
Save mario52a/0ed8129bacbe9124a41e3ae1d378d5b7 to your computer and use it in GitHub Desktop.
This small macro create a circle or arc giving radius, diameter, circumference, area, startangle, endangle, arc, anglecenter, cord, arrow, center (point), placemObject on choice. And ccreate sector.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
#
"""
***************************************************************************
* Copyright (c) 2018 2019 <mario52> *
* *
* This file is a supplement to the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
** **
* Use at your own risk. The author assumes no liability for data loss. *
* It is advised to backup your data frequently. *
* If you do not trust the software do not use it. *
** **
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
#Circle_Plus 2018/07/10 2018/07/14 2019/04/05 (incrementDS) 2019/04/06 2019/04/07
#
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.18.16093 (Git)
#Build type: Release
#Branch: releases/FreeCAD-0-18
#Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
#Python version: 2.7.14
#Qt version: 4.8.7
#Coin version: 4.0.0a
#OCC version: 7.2.0
#
__title__ = "CirclePlus"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_CirclePlus"
__version__ = "00.04"
__date__ = "2019/04/07"
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import pivy
from pivy import coin
import OpenSCAD2Dgeom
import time
import Draft, Part, PartGui, FreeCADGui, FreeCAD
from FreeCAD import Base
import math
from math import sqrt, pi, sin, cos, asin
Gui = FreeCADGui
App = FreeCAD
############################
# create a circle or arc fully parametrabel using:
# x x x coordinates
#with radius
#with diameter
#with circumference
#with area
#with startangle
#with endangle
#with [arc and anglecenter] in combination (angle in degrees)
#with [cord and arrow] in combination
############################
#### Config begin ####
global decimales ; decimales = 4
global incrementDS; incrementDS = 1.0 # 0.1 # step for increment on begin
#### Config end ######
global ui ; ui = ""
global s ; s = ""
global sourisPass ; sourisPass = 0
global positionX ; positionX = 0.0
global positionY ; positionY = 0.0
global positionZ ; positionZ = 0.0
class Ui_MainWindow(object):
def __init__(self ):
self.window = MainWindow
#self.path = FreeCAD.ConfigGet("AppHomePath")
#self.path = FreeCAD.ConfigGet("UserAppData")
#self.path = "your path"
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
self.path = param.GetString("MacroPath","") + "/" # macro path
self.path = self.path.replace("\\","/")
# print "Path for the icons : " , self.path
self.PointSize = 8 #heigth text
self.Radius = 0.0
self.Diameter = self.Radius * 2.0
self.Circumference = 0.0
self.Area = 0.0
self.StartAngle = 0.0
self.EndAngle = 0.0
self.Arc = 0.0
self.AngleCenter = 0.0
self.Cord = 0.0
self.Arrow = 0.0
self.Face = False
self.vueActive = FreeCADGui.ActiveDocument.ActiveView
self.click = self.vueActive.addEventCallback("SoMouseButtonEvent",self.souris)
def souris(self,info):
global sourisPass
global positionX
global positionY
global positionZ
if (info["Button"] == "BUTTON1") and (info["State"] == "DOWN"):
sourisPass = 0
positionX = positionY = positionZ = 0.0
self.DS_01_Coord_X.setValue(positionX)
self.DS_02_Coord_Y.setValue(positionY)
self.DS_03_Coord_Z.setValue(positionZ)
def setupUi(self, MainWindow):
global decimales
global incrementDS
self.window = MainWindow
MainWindow.setObjectName("MainWindow")
MainWindow.resize(226, 295)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
############################################
self.fontGlobal_08 = QtGui.QFont() # Windows Linux pour tous les textes
self.fontGlobal_08.setFamily("Arial") # Windows Linux pour tous les textes
self.fontGlobal_08.setPointSize(self.PointSize) # Windows Linux pour tous les textes
#self.xxxxx.setFont(self.fontGlobal_08) # Windows Linux
#self.xxxxx.setFont(QtGui.QFont("",weight=QtGui.QFont.Bold)) # Windows Linux Bold
#self.xxxxx.setStyleSheet("color: red; font: bold "+str(self.PointSize+3)+"px;")# Bold
#self.xxxxx.setIcon(QtGui.QIcon.fromTheme("media-playback-start")) # icone resource
############################################
self.GBox_01_Coordinate = QtGui.QGroupBox(self.centralwidget)
self.GBox_01_Coordinate.setGeometry(QtCore.QRect(5, 10, 216, 181))
self.GBox_01_Coordinate.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_01_Coordinate.setObjectName("GBox_01_Coordinate")
self.DS_01_Coord_X = QtGui.QDoubleSpinBox(self.GBox_01_Coordinate)
self.DS_01_Coord_X.setGeometry(QtCore.QRect(10, 20, 91, 22))
self.DS_01_Coord_X.setFont(self.fontGlobal_08) # Windows Linux
self.DS_01_Coord_X.setObjectName("DS_01_Coord_X")
self.DS_01_Coord_X.setDecimals(decimales)
self.DS_01_Coord_X.setMinimum(-9999999.9999999)
self.DS_01_Coord_X.setMaximum(9999999.9999999)
self.DS_01_Coord_X.setSuffix(" mm")
self.DS_01_Coord_X.setWrapping(True)
self.DS_01_Coord_X.setAccelerated(True)
self.DS_01_Coord_X.valueChanged.connect(self.on_DS_01_Coord_X_valueChanged)
self.label_01_X = QtGui.QLabel(self.GBox_01_Coordinate)
self.label_01_X.setGeometry(QtCore.QRect(110, 25, 51, 16))
self.label_01_X.setFont(self.fontGlobal_08) # Windows Linux
self.label_01_X.setObjectName("label_01_X")
self.DS_02_Coord_Y = QtGui.QDoubleSpinBox(self.GBox_01_Coordinate)
self.DS_02_Coord_Y.setGeometry(QtCore.QRect(10, 50, 91, 22))
self.DS_02_Coord_Y.setFont(self.fontGlobal_08) # Windows Linux
self.DS_02_Coord_Y.setObjectName("DS_02_Coord_Y")
self.DS_02_Coord_Y.setDecimals(decimales)
self.DS_02_Coord_Y.setMinimum(-9999999.9999999)
self.DS_02_Coord_Y.setMaximum(9999999.9999999)
self.DS_02_Coord_Y.setSuffix(" mm")
self.DS_02_Coord_Y.setWrapping(True)
self.DS_02_Coord_Y.setAccelerated(True)
self.DS_02_Coord_Y.valueChanged.connect(self.on_DS_02_Coord_Y_valueChanged)
self.label_02_Y = QtGui.QLabel(self.GBox_01_Coordinate)
self.label_02_Y.setGeometry(QtCore.QRect(110, 55, 16, 16))
self.label_02_Y.setFont(self.fontGlobal_08) # Windows Linux
self.label_02_Y.setObjectName("label_02_Y")
self.DS_03_Coord_Z = QtGui.QDoubleSpinBox(self.GBox_01_Coordinate)
self.DS_03_Coord_Z.setGeometry(QtCore.QRect(10, 80, 91, 22))
self.DS_03_Coord_Z.setFont(self.fontGlobal_08) # Windows Linux
self.DS_03_Coord_Z.setObjectName("DS_03_Coord_Z")
self.DS_03_Coord_Z.setDecimals(decimales)
self.DS_03_Coord_Z.setMinimum(-9999999.9999999)
self.DS_03_Coord_Z.setMaximum(9999999.9999999)
self.DS_03_Coord_Z.setSuffix(" mm")
self.DS_03_Coord_Z.setWrapping(True)
self.DS_03_Coord_Z.setAccelerated(True)
self.DS_03_Coord_Z.valueChanged.connect(self.on_DS_03_Coord_Z_valueChanged)
self.label_03_Z = QtGui.QLabel(self.GBox_01_Coordinate)
self.label_03_Z.setGeometry(QtCore.QRect(110, 85, 16, 16))
self.label_03_Z.setFont(self.fontGlobal_08) # Windows Linux
self.label_03_Z.setObjectName("label_03_Z")
self.PB_03_Reset_Coordinate = QtGui.QPushButton(self.GBox_01_Coordinate)
self.PB_03_Reset_Coordinate.setGeometry(QtCore.QRect(160, 20, 41, 83))
self.PB_03_Reset_Coordinate.setFont(self.fontGlobal_08) # Windows Linux
self.PB_03_Reset_Coordinate.setObjectName("PB_03_Reset_Coordinate")
self.PB_03_Reset_Coordinate.setIcon(QtGui.QIcon.fromTheme("view-refresh"))# icone resource
self.PB_03_Reset_Coordinate.clicked.connect(self.on_PB_03_Reset_Coordinate_clicked)
self.PB_03_Egual = QtGui.QPushButton(self.GBox_01_Coordinate)
self.PB_03_Egual.setGeometry(QtCore.QRect(160, 20, 15, 15))
self.PB_03_Egual.setFont(self.fontGlobal_08) # Windows Linux
self.PB_03_Egual.setObjectName("PB_03_Egual")
self.PB_03_Egual.clicked.connect(self.on_PB_03_Egual_clicked)
self.DS_04_Radius = QtGui.QDoubleSpinBox(self.GBox_01_Coordinate)
self.DS_04_Radius.setGeometry(QtCore.QRect(10, 115, 91, 22))
self.DS_04_Radius.setFont(self.fontGlobal_08) # Windows Linux
self.DS_04_Radius.setObjectName("DS_04_Radius")
self.DS_04_Radius.setDecimals(decimales)
self.DS_04_Radius.setSingleStep(incrementDS)
self.DS_04_Radius.setMinimum(0.0)
self.DS_04_Radius.setMaximum(9999999.9999999)
self.DS_04_Radius.setSuffix(" mm")
self.DS_04_Radius.setWrapping(True)
self.DS_04_Radius.setAccelerated(True)
self.DS_04_Radius.setValue(self.Radius)
self.DS_04_Radius.valueChanged.connect(self.on_DS_04_Radius_valueChanged)
self.label_DS_04_Radius = QtGui.QLabel(self.GBox_01_Coordinate)
self.label_DS_04_Radius.setGeometry(QtCore.QRect(110, 115, 91, 22))
self.label_DS_04_Radius.setFont(self.fontGlobal_08) # Windows Linux
self.label_DS_04_Radius.setObjectName("label_DS_04_Radius")
self.DS_05_Diameter = QtGui.QDoubleSpinBox(self.GBox_01_Coordinate)
self.DS_05_Diameter.setGeometry(QtCore.QRect(10, 145, 91, 22))
self.DS_05_Diameter.setFont(self.fontGlobal_08) # Windows Linux
self.DS_05_Diameter.setObjectName("DS_05_Diameter")
self.DS_05_Diameter.setDecimals(decimales)
self.DS_05_Diameter.setSingleStep(incrementDS)
self.DS_05_Diameter.setMinimum(0.0)
self.DS_05_Diameter.setMaximum(9999999.9999999)
self.DS_05_Diameter.setSuffix(" mm")
self.DS_05_Diameter.setWrapping(True)
self.DS_05_Diameter.setAccelerated(True)
self.DS_05_Diameter.setValue(self.Diameter)
self.DS_05_Diameter.valueChanged.connect(self.on_DS_05_Diameter_valueChanged)
self.label_DS_05_Diameter = QtGui.QLabel(self.GBox_01_Coordinate)
self.label_DS_05_Diameter.setGeometry(QtCore.QRect(110, 145, 91, 22))
self.label_DS_05_Diameter.setFont(self.fontGlobal_08) # Windows Linux
self.label_DS_05_Diameter.setObjectName("label_DS_05_Diameter")
####
self.GBox_02_Options = QtGui.QGroupBox(self.centralwidget)
self.GBox_02_Options.setGeometry(QtCore.QRect(5, 195, 216, 21))
self.GBox_02_Options.setFont(self.fontGlobal_08) # Windows Linux
self.GBox_02_Options.setCheckable(True)
self.GBox_02_Options.setChecked(False)
self.GBox_02_Options.setObjectName("GBox_02_Options")
self.GBox_02_Options.clicked.connect(self.on_GBox_02_Options)
self.DS_06_Circumference = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_06_Circumference.setGeometry(QtCore.QRect(10, 25, 91, 22))
self.DS_06_Circumference.setFont(self.fontGlobal_08) # Windows Linux
self.DS_06_Circumference.setObjectName("DS_06_Circumference")
self.DS_06_Circumference.setDecimals(decimales)
self.DS_06_Circumference.setSingleStep(incrementDS)
self.DS_06_Circumference.setMinimum(0.0)
self.DS_06_Circumference.setMaximum(9999999.9999999)
self.DS_06_Circumference.setSuffix(" mm")
self.DS_06_Circumference.setWrapping(True)
self.DS_06_Circumference.setAccelerated(True)
self.DS_06_Circumference.setValue(0.0)
self.DS_06_Circumference.valueChanged.connect(self.on_DS_06_Circumference_valueChanged)
self.label_06_Circumference = QtGui.QLabel(self.GBox_02_Options)
self.label_06_Circumference.setGeometry(QtCore.QRect(110, 25, 91, 22))
self.label_06_Circumference.setFont(self.fontGlobal_08) # Windows Linux
self.label_06_Circumference.setObjectName("label_06_Circumference")
self.DS_07_Area = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_07_Area.setGeometry(QtCore.QRect(10, 55, 91, 22))
self.DS_07_Area.setFont(self.fontGlobal_08) # Windows Linux
self.DS_07_Area.setObjectName("DS_07_Area")
self.DS_07_Area.setDecimals(decimales)
self.DS_07_Area.setSingleStep(incrementDS)
self.DS_07_Area.setMinimum(0.0)
self.DS_07_Area.setMaximum(9999999.9999999)
self.DS_07_Area.setSuffix(" mm2")
self.DS_07_Area.setWrapping(True)
self.DS_07_Area.setAccelerated(True)
self.DS_07_Area.valueChanged.connect(self.on_DS_07_Area_valueChanged)
self.label_07_Area = QtGui.QLabel(self.GBox_02_Options)
self.label_07_Area.setGeometry(QtCore.QRect(110, 55, 91, 22))
self.label_07_Area.setFont(self.fontGlobal_08) # Windows Linux
self.label_07_Area.setObjectName("label_07_Area")
self.DS_08_StartAngle = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_08_StartAngle.setGeometry(QtCore.QRect(10, 85, 91, 22))
self.DS_08_StartAngle.setFont(self.fontGlobal_08) # Windows Linux
self.DS_08_StartAngle.setObjectName("DS_08_StartAngle")
self.DS_08_StartAngle.setDecimals(decimales)
self.DS_08_StartAngle.setSingleStep(incrementDS)
self.DS_08_StartAngle.setMinimum(-360.0)
self.DS_08_StartAngle.setMaximum(360.0)
self.DS_08_StartAngle.setSuffix(" deg")
self.DS_08_StartAngle.setWrapping(True)
self.DS_08_StartAngle.setAccelerated(True)
self.DS_08_StartAngle.valueChanged.connect(self.on_DS_08_StartAngle_valueChanged)
self.label_08_StartAngle = QtGui.QLabel(self.GBox_02_Options)
self.label_08_StartAngle.setGeometry(QtCore.QRect(110, 85, 91, 22))
self.label_08_StartAngle.setFont(self.fontGlobal_08) # Windows Linux
self.label_08_StartAngle.setObjectName("label_08_StartAngle")
self.DS_09_EndAngle = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_09_EndAngle.setGeometry(QtCore.QRect(10, 115, 91, 22))
self.DS_09_EndAngle.setFont(self.fontGlobal_08) # Windows Linux
self.DS_09_EndAngle.setObjectName("DS_09_EndAngle")
self.DS_09_EndAngle.setDecimals(decimales)
self.DS_09_EndAngle.setSingleStep(incrementDS)
self.DS_09_EndAngle.setMinimum(-360.0)
self.DS_09_EndAngle.setMaximum(360.0)
self.DS_09_EndAngle.setSuffix(" deg")
self.DS_09_EndAngle.setWrapping(True)
self.DS_09_EndAngle.setAccelerated(True)
self.DS_09_EndAngle.valueChanged.connect(self.on_DS_09_EndAngle_valueChanged)
self.label_09_EndAngle = QtGui.QLabel(self.GBox_02_Options)
self.label_09_EndAngle.setGeometry(QtCore.QRect(110, 115, 91, 22))
self.label_09_EndAngle.setFont(self.fontGlobal_08) # Windows Linux
self.label_09_EndAngle.setObjectName("label_09_EndAngle")
self.DS_10_Arc = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_10_Arc.setGeometry(QtCore.QRect(10, 145, 91, 22))
self.DS_10_Arc.setFont(self.fontGlobal_08) # Windows Linux
self.DS_10_Arc.setObjectName("DS_10_Arc")
self.DS_10_Arc.setDecimals(decimales)
self.DS_10_Arc.setSingleStep(incrementDS)
self.DS_10_Arc.setMinimum(0.0)
self.DS_10_Arc.setMaximum(9999999.9999999)
self.DS_10_Arc.setSuffix(" mm")
self.DS_10_Arc.setWrapping(True)
self.DS_10_Arc.setAccelerated(True)
self.DS_10_Arc.valueChanged.connect(self.on_DS_10_Arc_valueChanged)
self.label_10_Arc = QtGui.QLabel(self.GBox_02_Options)
self.label_10_Arc.setGeometry(QtCore.QRect(110, 145, 91, 22))
self.label_10_Arc.setFont(self.fontGlobal_08) # Windows Linux
self.label_10_Arc.setObjectName("label_10_Arc")
self.DS_11_AngleCenter = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_11_AngleCenter.setGeometry(QtCore.QRect(10, 175, 91, 22))
self.DS_11_AngleCenter.setFont(self.fontGlobal_08) # Windows Linux
self.DS_11_AngleCenter.setObjectName("DS_11_AngleCenter")
self.DS_11_AngleCenter.setDecimals(decimales)
self.DS_11_AngleCenter.setSingleStep(incrementDS)
self.DS_11_AngleCenter.setMinimum(0.0)
self.DS_11_AngleCenter.setMaximum(360.0)
self.DS_11_AngleCenter.setSuffix(" deg")
self.DS_11_AngleCenter.setWrapping(True)
self.DS_11_AngleCenter.setAccelerated(True)
self.DS_11_AngleCenter.valueChanged.connect(self.on_DS_11_AngleCenter_valueChanged)
self.label_11_AngleCenter = QtGui.QLabel(self.GBox_02_Options)
self.label_11_AngleCenter.setGeometry(QtCore.QRect(110, 175, 91, 22))
self.label_11_AngleCenter.setFont(self.fontGlobal_08) # Windows Linux
self.label_11_AngleCenter.setObjectName("label_11_AngleCenter")
self.DS_12_Cord = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_12_Cord.setGeometry(QtCore.QRect(10, 205, 91, 22))
self.DS_12_Cord.setFont(self.fontGlobal_08) # Windows Linux
self.DS_12_Cord.setObjectName("DS_12_Cord")
self.DS_12_Cord.setDecimals(decimales)
self.DS_12_Cord.setSingleStep(incrementDS)
self.DS_12_Cord.setMinimum(0.0)
self.DS_12_Cord.setMaximum(9999999.9999999)
self.DS_12_Cord.setSuffix(" mm")
self.DS_12_Cord.setWrapping(True)
self.DS_12_Cord.setAccelerated(True)
self.DS_12_Cord.valueChanged.connect(self.on_DS_12_Cord_valueChanged)
self.label_12_Cord = QtGui.QLabel(self.GBox_02_Options)
self.label_12_Cord.setGeometry(QtCore.QRect(110, 205, 91, 22))
self.label_12_Cord.setFont(self.fontGlobal_08) # Windows Linux
self.label_12_Cord.setObjectName("label_12_Cord")
self.DS_13_Arrow = QtGui.QDoubleSpinBox(self.GBox_02_Options)
self.DS_13_Arrow.setGeometry(QtCore.QRect(10, 235, 91, 22))
self.DS_13_Arrow.setFont(self.fontGlobal_08) # Windows Linux
self.DS_13_Arrow.setObjectName("DS_13_Arrow")
self.DS_13_Arrow.setDecimals(decimales)
self.DS_13_Arrow.setSingleStep(incrementDS)
self.DS_13_Arrow.setMinimum(0.0)
self.DS_13_Arrow.setMaximum(9999999.9999999)
self.DS_13_Arrow.setSuffix(" mm")
self.DS_13_Arrow.setWrapping(True)
self.DS_13_Arrow.setAccelerated(True)
self.DS_13_Arrow.valueChanged.connect(self.on_DS_13_Arrow_valueChanged)
self.label_13_Arrow = QtGui.QLabel(self.GBox_02_Options)
self.label_13_Arrow.setGeometry(QtCore.QRect(110, 235, 91, 22))
self.label_13_Arrow.setFont(self.fontGlobal_08) # Windows Linux
self.label_13_Arrow.setObjectName("label_13_Arrow")
####
self.CB_01_Center = QtGui.QCheckBox(self.centralwidget)
self.CB_01_Center.setGeometry(QtCore.QRect(5, 220, 61, 18))
self.CB_01_Center.setFont(self.fontGlobal_08) # Windows Linux
self.CB_01_Center.setObjectName("CB_01_Center")
self.CB_01_Center.setChecked(False)
# self.CB_01_Center.clicked.connect(self.on_CB_01_Center_clicked)
self.CB_02_Info = QtGui.QCheckBox(self.centralwidget)
self.CB_02_Info.setGeometry(QtCore.QRect(90, 220, 61, 18))
self.CB_02_Info.setFont(self.fontGlobal_08) # Windows Linux
self.CB_02_Info.setObjectName("CB_02_Info")
self.CB_02_Info.setChecked(False)
# self.CB_02_Info.clicked.connect(self.on_CB_02_Info_clicked)
self.CB_03_Face = QtGui.QCheckBox(self.centralwidget)
self.CB_03_Face.setGeometry(QtCore.QRect(170, 220, 61, 18))
self.CB_03_Face.setFont(self.fontGlobal_08) # Windows Linux
self.CB_03_Face.setObjectName("CB_03_Face")
self.CB_03_Face.setChecked(False)
# self.CB_03_Face.clicked.connect(self.on_CB_03_Face_clicked)
self.CB_04_Sector = QtGui.QCheckBox(self.centralwidget)
self.CB_04_Sector.setGeometry(QtCore.QRect(5, 240, 61, 18))
self.CB_04_Sector.setFont(self.fontGlobal_08) # Windows Linux
self.CB_04_Sector.setObjectName("CB_04_Sector")
self.CB_04_Sector.setChecked(False)
# self.CB_04_Sector.clicked.connect(self.on_CB_04_Sector_clicked)
self.CB_05_Segment = QtGui.QCheckBox(self.centralwidget)
self.CB_05_Segment.setGeometry(QtCore.QRect(90, 240, 61, 18))
self.CB_05_Segment.setFont(self.fontGlobal_08) # Windows Linux
self.CB_05_Segment.setObjectName("CB_05_Segment")
self.CB_05_Segment.setChecked(False)
# self.CB_05_Segment.clicked.connect(self.on_CB_05_Segment_clicked)
# self.CB_06_incrementDS = QtGui.QCheckBox(self.centralwidget)
# self.CB_06_incrementDS.setGeometry(QtCore.QRect(170, 240, 61, 18))
# self.CB_06_incrementDS.setFont(self.fontGlobal_08) # Windows Linux
# self.CB_06_incrementDS.setObjectName("CB_06_incrementDS")
# self.CB_06_incrementDS.setText("(" + str(incrementDS) + ")")
# self.CB_06_incrementDS.setChecked(False)
# self.CB_06_incrementDS.clicked.connect(self.on_CB_06_incrementDS_clicked)
self.DS_06_incrementDS = QtGui.QDoubleSpinBox(self.centralwidget)
self.DS_06_incrementDS.setGeometry(QtCore.QRect(170, 240, 50, 18))
self.DS_06_incrementDS.setFont(self.fontGlobal_08) # Windows Linux
self.DS_06_incrementDS.setObjectName("DS_06_incrementDS")
self.DS_06_incrementDS.setDecimals(3)
self.DS_06_incrementDS.setSingleStep(0.01) #0.001
self.DS_06_incrementDS.setMinimum(0.0)
self.DS_06_incrementDS.setMaximum(9999999.9999999)
self.DS_06_incrementDS.setValue(incrementDS)
self.DS_06_incrementDS.setWrapping(True)
self.DS_06_incrementDS.setAccelerated(True)
self.DS_06_incrementDS.valueChanged.connect(self.on_DS_06_incrementDS_clicked)
self.SP_01_Caracter = QtGui.QDoubleSpinBox(self.centralwidget)
self.SP_01_Caracter.setGeometry(QtCore.QRect(5, 265, 50, 22))
self.SP_01_Caracter.setFont(self.fontGlobal_08) # Windows Linux
self.SP_01_Caracter.setObjectName("SP_01_Caracter")
self.SP_01_Caracter.setMinimum(0.0)
self.SP_01_Caracter.setMaximum(9999999)
self.SP_01_Caracter.setValue(self.PointSize)
self.SP_01_Caracter.valueChanged.connect(self.on_SP_01_Caracter_valueChanged)
self.PB_01_Quit = QtGui.QPushButton(self.centralwidget)
self.PB_01_Quit.setGeometry(QtCore.QRect(115, 265, 50, 23))
self.PB_01_Quit.setFont(self.fontGlobal_08) # Windows Linux
self.PB_01_Quit.setObjectName("PB_01_Quit")
self.PB_01_Quit.setIcon(QtGui.QIcon.fromTheme("application-exit")) # icone resource
self.PB_01_Quit.clicked.connect(self.on_PB_01_Quit_clicked)
self.PB_02_Create = QtGui.QPushButton(self.centralwidget)
self.PB_02_Create.setGeometry(QtCore.QRect(170, 265, 50, 23))
self.PB_02_Create.setFont(self.fontGlobal_08) # Windows Linux
self.PB_02_Create.setObjectName("PB_02_Create")
self.PB_02_Create.setIcon(QtGui.QIcon.fromTheme("media-playback-start")) # icone resource
self.PB_02_Create.clicked.connect(self.on_PB_02_Create_clicked)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowIcon(QtGui.QIcon(self.path + 'Macro_CirclePlus.png')) # change l'icone de la fenetre principale
MainWindow.setWindowTitle(__title__+" ("+__version__+", "+__date__+")")
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)
self.GBox_01_Coordinate.setTitle("Coordinate (v."+__version__+")")
self.label_01_X.setText("X")
self.label_01_X.setStyleSheet("color: red; font: bold "+str(self.PointSize+3)+"px;")
self.label_02_Y.setText("Y")
self.label_02_Y.setStyleSheet("color: green; font: bold "+str(self.PointSize+3)+"px;")
self.label_03_Z.setText("Z")
self.label_03_Z.setStyleSheet("color: blue; font: bold "+str(self.PointSize+3)+"px;")
#self.PB_03_Reset_Coordinate.setText("Reset")
self.PB_03_Reset_Coordinate.setToolTip("Reset the coordinate value " + "\n"
"Same click mouse in the 3D view")
self.PB_03_Egual.setText("=")
self.PB_03_Egual.setToolTip("This button copy the X value in the Y and Z window")
self.GBox_02_Options.setTitle("Options")
self.label_DS_04_Radius.setText("Radius")
self.label_DS_05_Diameter.setText("Diameter")
self.label_06_Circumference.setText("Circumference")
self.label_07_Area.setText("Area")
self.label_08_StartAngle.setText("StartAngle")
self.label_09_EndAngle.setText("EndAngle")
self.label_10_Arc.setText("Arc")
self.label_11_AngleCenter.setText("AngleCenter")
self.label_12_Cord.setText("Cord")
self.label_13_Arrow.setText("Arrow")
self.CB_01_Center.setText("Point")
self.CB_02_Info.setText("Info")
self.CB_03_Face.setText("Face")
self.CB_04_Sector.setText("Sector")
self.CB_05_Segment.setText("Segment")
# self.CB_06_incrementDS.setToolTip("Step increment")
self.DS_06_incrementDS.setToolTip("Step increment")
self.PB_01_Quit.setText("Quit")
self.PB_02_Create.setText("Ok")
#### ToolTip
self.DS_01_Coord_X.setToolTip("Coordinate X center circle " + "\n")
self.DS_02_Coord_Y.setToolTip("Coordinate Y center circle " + "\n")
self.DS_03_Coord_Z.setToolTip("Coordinate Z center circle " + "\n")
self.DS_04_Radius.setToolTip("Radius of circle " + "\n" + "(The diameter is automatically adapted) " + "\n")
self.DS_05_Diameter.setToolTip("Diameter of circle " + "\n" + "(The radius is automatically adapted) " + "\n")
self.GBox_02_Options.setToolTip("Option availlable " + "\n"
"If the command work with another command " + "\n"
"the frame of the command are colored in green " + "\n"
"If one facultative option is avaiabl , the is colored in orange " + "\n"
"Close this option window reset all value given" )
self.DS_06_Circumference.setToolTip("Length Circumference of circle " + "\n" )
self.DS_07_Area.setToolTip("Area of circle " + "\n"
"The circle is create with face " + "\n" )
self.DS_08_StartAngle.setToolTip("Start angle of circle " + "\n"
"The Start angle work with" + "\n"
"Start angle, End angle, Radius, Diameter " + "\n" )
self.DS_09_EndAngle.setToolTip("End angle of circle " + "\n"
"The End angle work with" + "\n"
"Start angle, End angle, Radius, Diameter " + "\n" )
self.DS_10_Arc.setToolTip("Length Arc of circle " + "\n"
"The Arc work with" + "\n"
"Arc, Angle center" + "\n"
"(option: startangle) " + "\n" )
self.DS_11_AngleCenter.setToolTip("Angle center Arc in degrees " + "\n"
"The radius is automaticly calculated" + "\n"
"The Angle center work with" + "\n"
"Arc, Angle center" + "\n"
"(option: startangle) " + "\n" )
self.DS_12_Cord.setToolTip("Length of Cord" + "\n"
"The Cord work with" + "\n"
"Cord, Arrow" )
self.DS_13_Arrow.setToolTip("Length of Arrow " + "\n"
"The Arrow work with" + "\n"
"Cord, Arrow" + "\n" )
self.CB_01_Center.setToolTip("Create Point center circle " + "\n")
self.CB_02_Info.setToolTip("Display info in the Report View " + "\n")
self.CB_03_Face.setToolTip("Create face on circle " + "\n" )
self.CB_04_Sector.setToolTip("Create on Sector " + "\n"
"If availlable")
self.CB_05_Segment.setToolTip("Create on Segment " + "\n"
"If availlable")
self.SP_01_Caracter.setToolTip("Change the height of the text " )
self.PB_01_Quit.setToolTip("Quit the macro Circle " + "\n" + "Good bye ")
self.PB_02_Create.setToolTip("Create the circle" + "\n"
"If one error is detected te buttom is colored in red" )
####
def reset_Label(self):
self.label_DS_04_Radius.setText("Radius")
self.label_DS_05_Diameter.setText("Diameter")
self.label_06_Circumference.setText("Circumference")
self.label_07_Area.setText("Area")
self.label_08_StartAngle.setText("StartAngle")
self.label_09_EndAngle.setText("EndAngle")
self.label_10_Arc.setText("Arc")
self.label_11_AngleCenter.setText("AngleCenter")
self.label_12_Cord.setText("Cord")
self.label_13_Arrow.setText("Arrow")
def on_DS_01_Coord_X_valueChanged(self, value): #
global positionX
positionX = value
def on_DS_02_Coord_Y_valueChanged(self, value): #
global positionY
positionY = value
def on_DS_03_Coord_Z_valueChanged(self, value): #
global positionZ
positionZ = value
def on_PB_03_Reset_Coordinate_clicked(self):
global positionX
global positionY
global positionZ
positionX = positionY = positionZ = 0.0
self.DS_01_Coord_X.setValue(positionX)
self.DS_02_Coord_Y.setValue(positionY)
self.DS_03_Coord_Z.setValue(positionZ)
def on_PB_03_Egual_clicked(self):
global positionX
global positionY
global positionZ
positionY = positionZ = positionX
self.DS_01_Coord_X.setValue(positionX)
self.DS_02_Coord_Y.setValue(positionY)
self.DS_03_Coord_Z.setValue(positionZ)
def on_DS_04_Radius_valueChanged(self, value): # radius
self.Radius = value
self.Face = False
ui.reset_Label()
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.PB_02_Create.setStyleSheet( "background-color: QPalette.Base")
#self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(0, 187, 0);") # bord white and green
self.DS_05_Diameter.setValue(self.Radius * 2.0)
self.label_DS_05_Diameter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(0, 187, 0);") # bord white and green
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
#self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(245, 121, 0);") # bord white and orange
#self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(245, 121, 0);") # bord white and orange
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_05_Diameter_valueChanged(self, value): # diameter
self.Diameter = value
self.DS_04_Radius.setValue(self.Diameter / 2.0)
ui.reset_Label()
def on_GBox_02_Options(self): #
self.Face = False
ui.reset_Label()
if self.GBox_02_Options.isChecked():
MainWindow.resize(226, 545)
self.GBox_02_Options.setGeometry(QtCore.QRect(5, 195, 216, 271))
self.CB_01_Center.setGeometry(QtCore.QRect(5, 470, 61, 18))
self.CB_02_Info.setGeometry(QtCore.QRect(90, 470, 61, 18))
self.CB_03_Face.setGeometry(QtCore.QRect(170, 470, 61, 18))
self.CB_04_Sector.setGeometry(QtCore.QRect(5, 490, 61, 18))
self.CB_05_Segment.setGeometry(QtCore.QRect(90, 490, 61, 18))
# self.CB_06_incrementDS.setGeometry(QtCore.QRect(170, 490, 61, 18))
self.DS_06_incrementDS.setGeometry(QtCore.QRect(170, 490, 50, 18))
self.SP_01_Caracter.setGeometry(QtCore.QRect(5, 515, 61, 22))
self.PB_01_Quit.setGeometry(QtCore.QRect(115, 515, 50, 23))
self.PB_02_Create.setGeometry(QtCore.QRect(170, 515, 50, 23))
else:
MainWindow.resize(226, 295)
self.GBox_02_Options.setGeometry(QtCore.QRect(5, 195, 216, 21))
self.CB_01_Center.setGeometry(QtCore.QRect(5, 220, 61, 18))
self.CB_02_Info.setGeometry(QtCore.QRect(90, 220, 61, 18))
self.CB_03_Face.setGeometry(QtCore.QRect(170, 220, 61, 18))
self.CB_04_Sector.setGeometry(QtCore.QRect(5, 240, 61, 18))
self.CB_05_Segment.setGeometry(QtCore.QRect(90, 240, 61, 18))
# self.CB_06_incrementDS.setGeometry(QtCore.QRect(170, 240, 61, 18))
self.DS_06_incrementDS.setGeometry(QtCore.QRect(170, 240, 50, 18))
self.SP_01_Caracter.setGeometry(QtCore.QRect(5, 265, 50, 22))
self.PB_01_Quit.setGeometry(QtCore.QRect(115, 265, 50, 23))
self.PB_02_Create.setGeometry(QtCore.QRect(170, 265, 50, 23))
#self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
#self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0 ; self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0 ; self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0 ; self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0 ; self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0 ; self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0 ; self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0 ; self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0 ; self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_06_Circumference_valueChanged(self, value): # Circumference
self.Circumference = value
self.Face = False
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
# self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(0, 187, 0);") # bord white and green
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_07_Area_valueChanged(self, value): # Area
self.Area = value
self.Face = True
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
# self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(0, 187, 0);") # bord white and green
self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_08_StartAngle_valueChanged(self, value): # StartAngle
self.StartAngle = value
self.Face = False
ui.reset_Label()
if self.Arc == 0:
#self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
else:
self.Radius = 0.0
self.EndAngle = 0.0
self.label_10_Arc.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.label_11_AngleCenter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
#self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_09_EndAngle_valueChanged(self, value): # EndAngle
self.EndAngle = value
self.Face = False
ui.reset_Label()
#self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
#self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_10_Arc_valueChanged(self, value): # Arc
#with [arc and anglecenter] + radius in combination (angle in degrees)
self.Arc = value
self.Face = False
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
#self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(245, 121, 0);") # bord white and orange
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
#self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_11_AngleCenter_valueChanged(self, value): # AngleCenter
#with [arc and anglecenter] + radius in combination (angle in degrees)
self.AngleCenter = value
self.Face = False
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
#self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(245, 121, 0);") # bord white and orange
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
#self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base")
self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base")
def on_DS_12_Cord_valueChanged(self, value): # Cord
#with [cord and arrow] in combination
self.Cord = value
self.Face = False
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
#self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
def on_DS_13_Arrow_valueChanged(self, value): # Arrow
#with [cord and arrow] in combination
self.Arrow = value
self.Face = False
ui.reset_Label()
self.DS_04_Radius.setValue(0.0) ; self.Radius = 0.0
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base")
self.DS_05_Diameter.setValue(0.0) ; self.Diameter = 0.0
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base")
self.DS_06_Circumference.setValue(0.0) ; self.Circumference = 0.0
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base")
self.DS_07_Area.setValue(0.0) ; self.Area = 0.0
self.label_07_Area.setStyleSheet("background-color: QPalette.Base")
self.DS_08_StartAngle.setValue(0.0) ; self.StartAngle = 0.0
self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_09_EndAngle.setValue(0.0) ; self.EndAngle = 0.0
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base")
self.DS_10_Arc.setValue(0.0) ; self.Arc = 0.0
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base")
self.DS_11_AngleCenter.setValue(0.0) ; self.AngleCenter = 0.0
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base")
#self.DS_12_Cord.setValue(0.0) ; self.Cord = 0.0
self.label_12_Cord.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
#self.DS_13_Arrow.setValue(0.0) ; self.Arrow = 0.0
self.label_13_Arrow.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
# def on_CB_06_incrementDS_clicked(self):
# global incrementDS
#
# if self.CB_06_incrementDS.isChecked():
# incrementDS = 0.1
# else:
# incrementDS = 1.0
# self.CB_06_incrementDS.setText("(" + str(incrementDS) + ")")
# self.DS_04_Radius.setSingleStep(incrementDS)
# self.DS_05_Diameter.setSingleStep(incrementDS)
## self.DS_06_Circumference.setSingleStep(incrementDS)
## self.DS_07_Area.setSingleStep(incrementDS)
## self.DS_08_StartAngle.setSingleStep(incrementDS)
## self.DS_09_EndAngle.setSingleStep(incrementDS)
## self.DS_10_Arc.setSingleStep(incrementDS)
## self.DS_11_AngleCenter.setSingleStep(incrementDS)
## self.DS_12_Cord.setSingleStep(incrementDS)
## self.DS_13_Arrow.setSingleStep(incrementDS)
def on_DS_06_incrementDS_clicked(self, value):
global incrementDS
incrementDS = value
self.DS_04_Radius.setSingleStep(incrementDS)
self.DS_05_Diameter.setSingleStep(incrementDS)
self.DS_06_Circumference.setSingleStep(incrementDS)
self.DS_07_Area.setSingleStep(incrementDS)
self.DS_08_StartAngle.setSingleStep(incrementDS)
self.DS_09_EndAngle.setSingleStep(incrementDS)
self.DS_10_Arc.setSingleStep(incrementDS)
self.DS_11_AngleCenter.setSingleStep(incrementDS)
self.DS_12_Cord.setSingleStep(incrementDS)
self.DS_13_Arrow.setSingleStep(incrementDS)
def on_SP_01_Caracter_valueChanged(self, value):
self.PointSize = value
self.fontGlobal_08.setPointSize(self.PointSize)
self.GBox_01_Coordinate.setFont(self.fontGlobal_08)
self.DS_01_Coord_X.setFont(self.fontGlobal_08)
self.label_01_X.setFont(self.fontGlobal_08)
self.label_01_X.setStyleSheet("color: red; font: bold "+str(self.PointSize+3)+"px;")
self.DS_02_Coord_Y.setFont(self.fontGlobal_08)
self.label_02_Y.setFont(self.fontGlobal_08)
self.label_02_Y.setStyleSheet("color: green; font: bold "+str(self.PointSize+3)+"px;")
self.DS_03_Coord_Z.setFont(self.fontGlobal_08)
self.label_03_Z.setFont(self.fontGlobal_08)
self.label_03_Z.setStyleSheet("color: blue; font: bold "+str(self.PointSize+3)+"px;")
self.PB_03_Reset_Coordinate.setFont(self.fontGlobal_08)
self.GBox_02_Options.setFont(self.fontGlobal_08)
self.DS_04_Radius.setFont(self.fontGlobal_08)
self.label_DS_04_Radius.setFont(self.fontGlobal_08)
self.DS_05_Diameter.setFont(self.fontGlobal_08)
self.label_DS_05_Diameter.setFont(self.fontGlobal_08)
self.DS_06_Circumference.setFont(self.fontGlobal_08)
self.label_06_Circumference.setFont(self.fontGlobal_08)
self.DS_07_Area.setFont(self.fontGlobal_08)
self.label_07_Area.setFont(self.fontGlobal_08)
self.DS_08_StartAngle.setFont(self.fontGlobal_08)
self.label_08_StartAngle.setFont(self.fontGlobal_08)
self.DS_09_EndAngle.setFont(self.fontGlobal_08)
self.label_09_EndAngle.setFont(self.fontGlobal_08)
self.DS_10_Arc.setFont(self.fontGlobal_08)
self.label_10_Arc.setFont(self.fontGlobal_08)
self.DS_11_AngleCenter.setFont(self.fontGlobal_08)
self.label_11_AngleCenter.setFont(self.fontGlobal_08)
self.DS_12_Cord.setFont(self.fontGlobal_08)
self.label_12_Cord.setFont(self.fontGlobal_08)
self.DS_13_Arrow.setFont(self.fontGlobal_08)
self.label_13_Arrow.setFont(self.fontGlobal_08)
self.SP_01_Caracter.setFont(self.fontGlobal_08)
self.PB_02_Create.setFont(self.fontGlobal_08)
self.PB_01_Quit.setFont(self.fontGlobal_08)
def on_PB_01_Quit_clicked(self):
global s
self.vueActive.removeEventCallback("SoMouseButtonEvent",self.click) # desinstalle la fonction souris
FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente SelObserver
self.window.hide()
FreeCAD.Console.PrintMessage("Quit" + "\n")
def on_PB_02_Create_clicked(self):
global positionX
global positionY
global positionZ
if self.Circumference != 0: # with circumference
self.Radius = (self.Circumference / pi) / 2.0
elif self.Area != 0: # with area
self.Radius = sqrt((self.Area / pi))
elif (self.Cord != 0) and (self.Arrow != 0): # with cord and arrow
self.Radius = ((self.Arrow**2) + (self.Cord**2) / 4.0) / (self.Arrow*2.0)
elif (self.Arc != 0) and (self.AngleCenter != 0): # with arc and anglecenter central in degrees
self.Radius = ((360.0 / self.AngleCenter)*self.Arc) / pi/2.0
if self.EndAngle != 0:
self.StartAngle = self.EndAngle - self.AngleCenter
self.EndAngle = self.AngleCenter + self.StartAngle
self.StartAngle = self.EndAngle - self.AngleCenter
if self.Radius != 0:
if self.CB_03_Face.isChecked():
self.Face = True
try:
pl=FreeCAD.Placement()
r = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() # get camera orientation
pl=FreeCAD.Placement() # placement object
pl.Rotation.Q = r.Q # set camera orientation
pl.Base = App.Vector(positionX, positionY, positionZ)
circle = Draft.makeCircle(self.Radius, placement=pl, face=self.Face, startangle=self.StartAngle, endangle=self.EndAngle, support=None)
Draft.autogroup(circle)
if self.CB_01_Center.isChecked():
Draft.makePoint(pl.Base)
try:
if (self.CB_04_Sector.isChecked()): #Sector
pointsC = []
pointsC = circle.Shape.discretize(3)
line01 = Draft.makeWire([pl.Base, pointsC[0]],closed=False,face=False,support=None); Draft.autogroup(line01)
line02 = Draft.makeWire([pl.Base, pointsC[2]],closed=False,face=False,support=None); Draft.autogroup(line02)
##Compound
secteur = App.activeDocument().addObject("Part::Compound","Sector")
secteur.Links = [line01, circle, line02]
##face #https://www.freecadweb.org/wiki/Macro_Creating_faces_from_a_DXF_file
if self.CB_03_Face.isChecked():
try:
edges = sum((line01.Shape.Edges, circle.Shape.Edges, line02.Shape.Edges),[])
face = OpenSCAD2Dgeom.edgestofaces(edges)
faceobj = doc.addObject("Part::Feature","Sector")
faceobj.Label = "Sector"
faceobj.Shape = face
except Exception:
None
App.activeDocument().recompute()
except Exception:
App.Console.PrintError("Sector not possible" + "\n")
try:
if (self.CB_05_Segment.isChecked()): #Segment
pointsC = []
pointsC = circle.Shape.discretize(3)
line01 = Draft.makeWire([pointsC[0], pointsC[2]],closed=False,face=False,support=None); Draft.autogroup(line01)
##Compound
secteur = App.activeDocument().addObject("Part::Compound","Segment")
secteur.Links = [line01, circle]
##face #https://www.freecadweb.org/wiki/Macro_Creating_faces_from_a_DXF_file
if self.CB_03_Face.isChecked():
try:
edges = sum((line01.Shape.Edges, circle.Shape.Edges),[])
face = OpenSCAD2Dgeom.edgestofaces(edges)
faceobj = doc.addObject("Part::Feature","Segment")
faceobj.Label = "Segment"
faceobj.Shape = face
except Exception:
None
App.activeDocument().recompute()
except Exception:
App.Console.PrintError("Segment not possible" + "\n")
self.Face = False
self.label_DS_04_Radius.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_DS_05_Diameter.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_06_Circumference.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_07_Area.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_08_StartAngle.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_09_EndAngle.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_10_Arc.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_11_AngleCenter.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_12_Cord.setStyleSheet("background-color: QPalette.Base") # origin system
self.label_13_Arrow.setStyleSheet("background-color: QPalette.Base") # origin system
self.Circumference = ((self.Radius * 2.0) * pi)
self.Area = ((self.Radius ** 2.0) * pi)
if self.CB_02_Info.isChecked():
FreeCAD.Console.PrintMessage("Radius : " + str(self.Radius) + "\n")
FreeCAD.Console.PrintMessage("Diameter : " + str(self.Radius * 2.0) + "\n")
FreeCAD.Console.PrintMessage("Circumference : " + str(self.Circumference) + "\n")
FreeCAD.Console.PrintMessage("Area : " + str(self.Area) + "\n")
FreeCAD.Console.PrintMessage("StartAngle : " + str(self.StartAngle) + "\n")
FreeCAD.Console.PrintMessage("EndAngle : " + str(self.EndAngle) + "\n")
FreeCAD.Console.PrintMessage("Arc : " + str(self.Arc) + "\n")
FreeCAD.Console.PrintMessage("AngleCenter : " + str(self.AngleCenter) + "\n")
FreeCAD.Console.PrintMessage("Cord : " + str(self.Cord) + "\n")
FreeCAD.Console.PrintMessage("Arrow : " + str(self.Arrow) + "\n")
FreeCAD.Console.PrintMessage("________________" + "\n")
self.label_DS_04_Radius.setText("Rad" + " (" + str(round(self.Radius,2)) + ")")
self.label_DS_05_Diameter.setText("Dia" + " (" + str(round(self.Radius * 2.0,2)) + ")")
self.label_06_Circumference.setText("Cir" + " (" + str(round(self.Circumference,2)) + ")")
self.label_07_Area.setText("Arc" + " (" + str(round(self.Area,2)) + ")")
self.label_08_StartAngle.setText("Sta" + " (" + str(round(self.StartAngle,2)) + ")")
self.label_09_EndAngle.setText("End" + " (" + str(round(self.EndAngle,2)) + ")")
self.label_10_Arc.setText("Arc" + " (" + str(round(self.Arc,2)) + ")")
self.label_11_AngleCenter.setText("ACe" + " (" + str(round(self.AngleCenter,2)) + ")")
self.label_12_Cord.setText("Cor" + " (" + str(round(self.Cord,2)) + ")")
self.label_13_Arrow.setText("Arr" + " (" + str(round(self.Arrow,2)) + ")")
self.PB_02_Create.setStyleSheet("background-color: QPalette.Base")
except Exception:
App.Console.PrintError("Unexpected keyword argument" + "\n")
else:
App.Console.PrintError("Unexpected keyword argument" + "\n")
#self.DS_04_Radius.setStyleSheet("background-color: red")
#self.DS_05_Diameter.setStyleSheet("background-color: red")
self.PB_02_Create.setStyleSheet("background-color: red") # This function gives a color button
#################################################################################################
class SelObserver:
def addSelection(self, document, object, element, position): # Selection
global ui
global sourisPass
global positionX
global positionY
global positionZ
positionX = positionY = positionZ =0.0
if sourisPass == 0:
sourisPass = 1
#print position
positionX = position[0]
positionY = position[1]
positionZ = position[2]
ui.DS_01_Coord_X.setValue(positionX)
ui.DS_02_Coord_Y.setValue(positionY)
ui.DS_03_Coord_Z.setValue(positionZ)
else:
sourisPass = 0
## def setPreselection(self,doc,obj,sub): # preselection
## print "setPreselection"
## def removeSelection(self,doc,obj,sub): # Effacer l'objet selectionne
## print "removeSelection"
## def setSelection(self,doc): # Selection dans ComboView
## print "SelObserver quit macro"
## def clearSelection(self,doc): # Si clic sur l'ecran, effacer la selection
## print "clearSelection" # Si clic sur un autre objet, efface le precedent
s=SelObserver()
FreeCADGui.Selection.addObserver(s) # installe la fonction en mode resident
##################################################################################################
doc = FreeCAD.ActiveDocument
if doc == None:
doc = FreeCAD.newDocument()
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
@mario52a
Copy link
Author

This macro utility is intended for the use of the program FreeCAD http://www.freecadweb.org/
The icon for your toolbar, it is to place in your macros directory (all in the same location of the macro)

macro_circleplus Icon for the toolbar Rename in Macro_CirclePlus.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment