Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active August 12, 2021 23:51
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/3ec67a3711202dab69592ce53b938924 to your computer and use it in GitHub Desktop.
Save mario52a/3ec67a3711202dab69592ce53b938924 to your computer and use it in GitHub Desktop.
This macro easily creates a connection between two objects, an object and a point or between two points (the center of the objects are the starting and ending points of the sweep) can be selected form a configurable ellipse polygon circle
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2016 2017 2018 2019 2020 <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 *
***************************************************************************
"""
#Macro_Connect_And_Sweep.FCMacro
# This macro is based to the microelly2 code see "http://forum.freecadweb.org/viewtopic.php?t=7029#p56746"
#
#05/04/2019 Py3, 26/06/2019, 23/12/2019 discretize, 2020/01/06 sweep et outils, 2020/01/09 centrage sur face, 2020/02/13 Layout rmu
#2020/02/22 try:except Error Dialog, 05/07/2020 icon
#
#OS: Windows 10 (10.0) #OS: Windows 10 (10.0)
#Word size of OS: 64-bit #Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit #Word size of FreeCAD: 64-bit
#Version: 0.19.16993 (Git) #Version: 0.19.18990 (Git)
#Build type: Release #Build type: Release
#Branch: master #Branch: master
#Hash: 5ea062f6699666b2f284f6a52105acf20828b481#Hash: e499f384240196c415f207520bfbcb8df9d1b0d2
#Python version: 3.6.8 #Python version: 3.6.8
#Qt version: 5.12.1 #Qt version: 5.12.1
#Coin version: 4.0.0a #Coin version: 4.0.0a
#OCC version: 7.3.0 #OCC version: 7.3.0
#
#
__title__ = "Macro_Connect_And_Sweep"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Connect_And_Sweep"
__version__ = "00.12"
__date__ = "2020/07/05" #YYYY/MM/DD
__Comment__ = "This macro connect 2 objects (boundingBox center) or one object (boundingBox center) and one point or two points selected one wire selected (straight)"
__Help__ = "Start the macro select 2 objects choice the form and validate"
#### Section Icones ####
## icon fromTheme by FreeCAD
## base64 easyw-fc method
## https://forum.freecadweb.org/viewtopic.php?f=9&t=24742&start=100#p363271
import base64
CenterTop_b64=\
"""
iVBORw0KGgoAAAANSUhEUgAAAE8AAAAxCAYAAACbHPQ3AAACvklEQVRo3u2bT3LaMBTGnzzcoTfqgk7T3sNyI7NLKF2Uku5sAc49GvJn0Rv1FOoCSGVbcq1nSZaJ3oyHUbCt7/30PUk4QPK8EhADFYnvDsuCdrb7vvcm4eWL6hVKWVDIF1V0niuHhuy+UeCd3Tdl1wXrPBmsXOa+oyjp9OAJEFAUae11jFjkFRQl1UIkjLnfqnCemsFTKSIkmMHN2bEqZiHPKYT8A0kM3cfYvZ0phNMaMDm8whO/3+lH8+Wb1EpbDmzCKOff1cDf/3l9v35PHDgVNOfw5ORUZTs0seb1Kpjy3zD9dYE7zXl7YRfaWusGxtxvTfipzHQuz19WYW5VVOBsijVz5krZt0rj6PCaonTiQ4DYB2DJs842AEAixHFixh7lfN0Sw55XtXPkLYjrQ9cXe24DLOfrzvuUPDvmeALXPGeQ8/iH9gg2RYYUKm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c6rP7BoFXu2/MrvPWeSxYtswneJLOFLV9iSDLhr1V2V7/7BZ39Q/o309i0G8/BtMe+QTLxPlcwox8AcZN+iruhNF1Tvb3tkFGQwHrm1izP2882yAjAGoY2lqQ8IppyY5LJWGuhBpqkOcaPHIeT7RJsfKu7Aa5vV4b0xTaApe/rQYBxwPZ1CGqDiXn0Z5VW9y0hWSv5qBRQ7NK9ro601oD7KM1SFNCbYMrS80dAg0AAj15aVpZv9jG5jyTbrMZtU4eRGfw2MFlwXW5oStKnT6SLmfLuLhZa1380FS5jj10cgo/Srna0B66KNexAFR1X0R73Auo9tUZS1efi37aZZv++W7NDWWZQFkmQIEeX9uMrlxKjNzsMN5jpAhDiVEnxMhn8UFw2mFccsHp9ubwOaw4GG70F7gwRdh/eOz0Uwu+yADvSxwhojZVfN5wS7iGxhtfe2+r06/PPlW1r4m8MEGAkgM0arBs8e0G0IudRUPVNX0D3274OhJ8aXvW57EFtfx5cKhNvZ/yaotelswVux/9isrmwObmZHs2ZoAi7ZikwjYAQEjpfpJUOZLdsjXJig7Zz5k4VMZiI9ktW+9hkgKlJ3DN/toLRrJbApntrxyZ3beA8qKqkDeuq7XXubTyi0sgVXrWtnaTXIuRgegLtIsGOQDkgQMACOK4oP3EPHBcufAUnJpWUmWQxMXxp/EFI9ktWgJ4In0Dx9PdBCdqay8YvCN+bgMkswcni4ToqHWwET8vpBaTeF7sc5sX3AUjmM8Lo3eu1Zdu1zUB2wpXGozDk0nABkjX41mFp5KYTnI2zuklPNWk+4SrqeHwSMrtH4bOf387a//6+mj0fC4fPgz+MLSd/Hhi+g5jgjfBG11EdPqfx8l5gzjP7fcK7yv+AxcwYgOsAbMUAAAAAElFTkSuQmCC
"""
arrowUp = [
"24 24 3 1",
" c None",
". c #4e9a06",
"+ c #FFFFFF",
" ...... ",
" .....+...... ",
" ......+....... ",
" ......+++....... ",
" .......+++........ ",
" .......+++++........ ",
" ........+++++......... ",
" .......+++++++........ ",
" .......+++++++........ ",
"........+++++++.........",
".......+++++++++........",
".......+++++++++........",
"......+++++++++++.......",
"......+++++++++++.......",
".....+++++++++++++......",
" ....+++++++++++++..... ",
" ...+++...+++...+++.... ",
" ...+.....+++.....+.... ",
" ........+++......... ",
" .......+++........ ",
" ......+++....... ",
" .....+++...... ",
" ....+++..... ",
" ...... "]
#### Section Icones ####
####
import WebGui
try:
def errorDialog(msg):
import PySide
from PySide import QtGui
import sys, os
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error FreeCAD Version",msg )
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide #cette fonction met la fenetre en avant
diag.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300; font: bold}")
FreeCAD.Console.PrintMessage("https://gist.githubusercontent.com/mario52a/3ec67a3711202dab69592ce53b938924/raw/5adea7e9362849fa04d28e5a4065cd4129ea707a/Macro_Connect_And_Sweep.FCMacro" + "\n\n")
diag.exec_()
diag.setStyleSheet("Base")
quit("None")
if int(FreeCAD.Version()[1]) < 18: # Version de FreeCAD
errorDialog("This version " + __title__ + " work with the FreeCAD 0.18 or higher. " + "\n"
"PySide2 Qt version: 5" + "\n"
"See the page (Report view) for copy the link of the precedent version. " + "\n")
#
except Exception:
None
####
import PySide2
from PySide2 import (QtWidgets, QtCore, QtGui)
from PySide2.QtWidgets import (QWidget, QApplication, QSlider, QGraphicsView, QGraphicsScene, QVBoxLayout, QStyle)
from PySide2.QtGui import (QPainter, QColor, QIcon)
from PySide2.QtSvg import *
import PySide2.QtXml
######import for WebPage
#import WebGui
#from PySide2 import QtUiTools, QtNetwork
#from PySide2.QtCore import QUrl
######import for WebPage
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
import DraftVecUtils
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
#import time
#time.sleep(0.1)
App = FreeCAD
global ui ; ui = ""
global path
##path###########################################################################
#path = FreeCAD.ConfigGet("AppHomePath")
#path = FreeCAD.ConfigGet("UserAppData")
#path = "your path"
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
path = param.GetString("MacroPath","") + "/" # macro path
path = path.replace("\\","/")
#App.Console.PrintMessage(str("Path for the icons : ") + path + "\n" + __title__ + " : " +__version__ + " " + __date__ + "\n")
#################################################################################
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)
####nouveau objectRealPlacement3D#######################################################################
####return objectRealPlacement3DX, objectPlacementAngle (avec bbox = "BB")
def objectRealPlacement3D(obj, mode = 0, bbox = "" ): #obj : object, mode : 0=Base, 1=BoundBox.Center, 2=CenterOfMass
try:
try:
objectPlacement = obj.Shape.Placement
except Exception:
objectPlacement = obj.Placement
objectPlacementBase = FreeCAD.Vector(objectPlacement.Base)
objectPlacementAngle = objectPlacement.Rotation.toEuler()
####
if mode == 0: # 0=Base
objectWorkCenter = objectPlacementBase
elif mode == 1: # 1=BoundBox.Center
objectBoundBoxCenter = FreeCAD.Vector(obj.Shape.BoundBox.Center)
objectWorkCenter = objectBoundBoxCenter
elif mode == 2: # 2=CenterOfMass
try:
objectCenterOfMass = FreeCAD.Vector(obj.Shape.CenterOfMass)
except Exception:
objectCenterOfMass = FreeCAD.Vector(0.0, 0.0, 0.0)
objectWorkCenter = objectCenterOfMass
####
if hasattr(obj, "getGlobalPlacement"):
globalPlacement = obj.getGlobalPlacement()
globalPlacementBase = FreeCAD.Vector(globalPlacement.Base)
if bbox != "BB":
objectRealPlacement3DX = globalPlacementBase.add(objectWorkCenter).sub(objectPlacementBase)
else:
objectRealPlacement3DX = globalPlacementBase.sub(objectWorkCenter)#mode=0 adapte pour BBox + Centerpoints
objectPlacementAngle = globalPlacement.Rotation.toEuler()
else:
objectRealPlacement3DX = objectWorkCenter
objectPlacementAngle = obj.Placement.Rotation.toEuler()
#print(objectRealPlacement3DX," : ", objectPlacementAngle)
if bbox != "BB":
return objectRealPlacement3DX, objectPlacementAngle
else:
return objectRealPlacement3DX
except Exception:
return FreeCAD.Vector(0.0, 0.0, 0.0), (0.0, 0.0, 0.0)
####nouveau objectRealPlacement3D#######################################################################
class Ui_MainWindow(object):
global path
def __init__(self):
global path
self.path = path
self.Polyline_Number_Faces = 3
self.Polyline_CirCon = 5.0
self.Rectangle_X = 5.0
self.Rectangle_Y = 3.0
self.Circle_Radius = 1.0
self.Circle_Radius_Sbs = 0.5
self.Circle_Diameter = self.Circle_Radius * 2.0
self.Thickness = 0.0
self.FcSweep = ""
self.FcSweepS = ""
self.Forme = ""
self.FormeSubtract = ""
self.cutFcSweep = ""
self.ligne = ""
self.sweepForme = ""
self.discretize = 1.0
#01 self.nameL = [] # contener en attente
self.CASweep = "" # conteneur dossier
self.ElementName = ""
self.sweepFace = ""
self.sweepFaceName = ""
self.selectForDuplicate = []
size_ecran = QtWidgets.QDesktopWidget().screenGeometry() # donne les dimensions de l'ecran
self.orgWidth = size_ecran.width()
self.orgHeight = size_ecran.height()
def setupUi(self, MainWindow):
self.window = MainWindow
MainWindow.resize(360, 570)
#MainWindow.setGeometry(50, 50, 360, 570)
# MainWindow.move(900,115)
self.centralwidget = QtWidgets.QWidget(MainWindow)
######################################################################
#### #Titre
self.widget = QtWidgets.QWidget(self.centralwidget)
grid = QtWidgets.QGridLayout(self.centralwidget)
grid.addWidget(self.widget)
####
self.label = QtWidgets.QLabel()
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.PB_Help = QtWidgets.QPushButton()
self.PB_Help.setToolTip(_fromUtf8("Help on line " + __version__ + " " + __date__ + " rmu"))
self.PB_Help.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_MessageBoxQuestion)))
self.PB_Help.clicked.connect(self.on_PB_Help) ###
grid.addWidget(self.widget, 0, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid01 = QtWidgets.QGridLayout(self.widget)
grid01.addWidget(self.label, 0, 0)
grid01.addWidget(self.PB_Help, 0, 1)
#### #Titre
#### #Mode
self.GBox_00 = QtWidgets.QGroupBox()
self.RB_01_BBox_Oject = QtWidgets.QRadioButton()
#self.RB_01_BBox_Oject.setChecked(True)
self.RB_01_BBox_Oject.clicked.connect(self.on_RB_00_Mode_clicked)
self.RB_03_Subo_Subo = QtWidgets.QRadioButton()
self.RB_03_Subo_Subo.setChecked(True)#
self.RB_03_Subo_Subo.clicked.connect(self.on_RB_00_Mode_clicked)
self.RB_02_BBox_Subo = QtWidgets.QRadioButton()
#self.RB_02_BBox_Subo.setChecked(True)
self.RB_02_BBox_Subo.clicked.connect(self.on_RB_00_Mode_clicked)
self.label_Info = QtWidgets.QLabel()
# ####
grid.addWidget(self.GBox_00, 1, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid02 = QtWidgets.QGridLayout(self.GBox_00)
grid02.addWidget(self.RB_01_BBox_Oject, 0, 0)
grid02.addWidget(self.RB_02_BBox_Subo, 1, 0)
grid02.addWidget(self.RB_03_Subo_Subo, 0, 1)
#### #Mode
#### #Forme
self.GBox_02_ = QtWidgets.QGroupBox()
self.DS_Polyline_CirCon = QtWidgets.QDoubleSpinBox()
self.DS_Polyline_CirCon.setDecimals(3)
self.DS_Polyline_CirCon.setMinimum(0.00001)
self.DS_Polyline_CirCon.setMaximum(999999.999999)
self.DS_Polyline_CirCon.setValue(self.Polyline_CirCon)
self.DS_Polyline_CirCon.valueChanged.connect(self.on_DS_Polyline_CirCon) ###
self.SB_Polyline_Number_Faces = QtWidgets.QSpinBox()
self.SB_Polyline_Number_Faces.setPrefix(_fromUtf8(""))
self.SB_Polyline_Number_Faces.setMinimum(3)
self.SB_Polyline_Number_Faces.setMaximum(999999)
self.SB_Polyline_Number_Faces.setValue(self.Polyline_Number_Faces )
self.SB_Polyline_Number_Faces.valueChanged.connect(self.on_SB_Polyline_Number_Faces) ###
self.RB_Polyline = QtWidgets.QRadioButton()
self.RB_Polyline.setChecked(True)
self.RB_Polyline.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/Draft_Polygon.svg")))
self.RB_Polyline.clicked.connect(self.on_RB_Polyline_clicked)
self.CB_Insc_Circon = QtWidgets.QCheckBox()
self.CB_Insc_Circon.setEnabled(True)
self.CB_Insc_Circon.setText(_fromUtf8("Polygon Circumscribed"))
self.CB_Insc_Circon.clicked.connect(self.on_CB_Insc_Circon_clicked)
self.DS_Rectangle_X = QtWidgets.QDoubleSpinBox()
self.DS_Rectangle_X.setDecimals(3)
self.DS_Rectangle_X.setDecimals(3)
self.DS_Rectangle_X.setMinimum(0.00001)
self.DS_Rectangle_X.setMaximum(999999.999999)
self.DS_Rectangle_X.setValue(self.Rectangle_X)
self.DS_Rectangle_X.valueChanged.connect(self.on_DS_Rectangle_X) ###
self.DS_Rectangle_Y = QtWidgets.QDoubleSpinBox()
self.DS_Rectangle_Y.setDecimals(3)
self.DS_Rectangle_Y.setDecimals(3)
self.DS_Rectangle_Y.setMinimum(0.00001)
self.DS_Rectangle_Y.setMaximum(999999.999999)
self.DS_Rectangle_Y.setValue(self.Rectangle_Y)
self.DS_Rectangle_Y.valueChanged.connect(self.on_DS_Rectangle_Y) ###
self.RB_Rectangle = QtWidgets.QRadioButton()
self.RB_Rectangle.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/Draft_Rectangle.svg")))
self.RB_Rectangle.clicked.connect(self.on_RB_Rectangle_clicked)
self.RB_Ellipse = QtWidgets.QRadioButton()
self.RB_Ellipse.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/Draft_Ellipse.svg")))
self.RB_Ellipse.clicked.connect(self.on_RB_Ellipse_clicked)
self.DS_Circle_Radius = QtWidgets.QDoubleSpinBox()
self.DS_Circle_Radius.setDecimals(3)
self.DS_Circle_Radius.setMinimum(0.00001)
self.DS_Circle_Radius.setMaximum(999999.999999)
self.DS_Circle_Radius.setValue(self.Circle_Radius)
self.DS_Circle_Radius.valueChanged.connect(self.on_DS_Circle_Radius) ###
self.DS_Circle_Diameter = QtWidgets.QDoubleSpinBox()
self.DS_Circle_Diameter.setDecimals(3)
self.DS_Circle_Diameter.setMinimum(0.00001)
self.DS_Circle_Diameter.setMaximum(999999.999999)
self.DS_Circle_Diameter.setValue(self.Circle_Diameter)
self.DS_Circle_Diameter.valueChanged.connect(self.on_DS_Circle_Diameter) ###
self.RB_Circle = QtWidgets.QRadioButton()
self.RB_Circle.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/Draft_Circle.svg")))
self.RB_Circle.clicked.connect(self.on_RB_Circle_clicked)
self.RB_Line = QtWidgets.QRadioButton()
self.RB_Line.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/Draft_Line.svg")))
self.RB_Line.clicked.connect(self.on_RB_Line_clicked)
self.CB_Solid = QtWidgets.QCheckBox()
self.CB_Solid.setChecked(True)
self.CB_Solid.clicked.connect(self.on_CB_Solid_clicked)
self.label_Pipe = QtWidgets.QLabel()
self.DS_Pipe = QtWidgets.QDoubleSpinBox()
self.DS_Pipe.setDecimals(3)
self.DS_Pipe.setMinimum(0.00001)
self.DS_Pipe.setMaximum(999999.999999)
self.DS_Pipe.setValue(self.Thickness)
self.DS_Pipe.valueChanged.connect(self.on_DS_Pipe) ###
grid.addWidget(self.GBox_02_, 2, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
self.grid03 = QtWidgets.QGridLayout(self.GBox_02_)
self.grid03.addWidget(self.CB_Insc_Circon, 0, 1)
self.grid03.addWidget(self.RB_Polyline, 1, 0)
self.grid03.addWidget(self.DS_Polyline_CirCon,1, 1)
self.grid03.addWidget(self.SB_Polyline_Number_Faces, 1, 2)
self.grid03.addWidget(self.RB_Rectangle, 2, 0)
self.grid03.addWidget(self.DS_Rectangle_X, 2, 1)
self.grid03.addWidget(self.DS_Rectangle_Y, 2, 2)
self.grid03.addWidget(self.RB_Ellipse, 3, 0)
self.grid03.addWidget(self.RB_Circle, 4, 0)
self.grid03.addWidget(self.DS_Circle_Radius, 4, 1)
self.grid03.addWidget(self.DS_Circle_Diameter, 4, 2)
self.grid03.addWidget(self.RB_Line, 5, 0)
self.grid03.addWidget(self.CB_Solid, 6, 0)
self.grid03.addWidget(self.label_Pipe, 7, 0)
self.grid03.addWidget(self.DS_Pipe, 7, 1)
#### #Forme
#### #Graphique
self.GBox_07_ = QtWidgets.QGroupBox()
self.GBox_07_.setVisible(False)
# self.GBox_07_.setVisible(True)
self.RB_Top_Left = QtWidgets.QRadioButton()
self.RB_Top_Left.setLayoutDirection(QtCore.Qt.RightToLeft)
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(-45), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Top_Left.setIconSize(QtCore.QSize(24, 24))
self.RB_Top_Left.setIcon(iconRotate)
self.RB_Top_Left.clicked.connect(self.on_RB_Image_clicked)
self.RB_Center_Top = QtWidgets.QRadioButton()
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(0), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Center_Top.setIcon(iconRotate)
self.RB_Center_Top.clicked.connect(self.on_RB_Image_clicked)
self.RB_Top_Rigth = QtWidgets.QRadioButton()
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(45), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Top_Rigth.setIconSize(QtCore.QSize(24, 24))
self.RB_Top_Rigth.setIcon(iconRotate)
self.RB_Top_Rigth.clicked.connect(self.on_RB_Image_clicked)
self.RB_Center_Left = QtWidgets.QRadioButton()
self.RB_Center_Left.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowLeft))) #
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(-90), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Center_Left.setIcon(iconRotate)
self.RB_Center_Left.setLayoutDirection(QtCore.Qt.RightToLeft)
self.RB_Center_Left.clicked.connect(self.on_RB_Image_clicked)
self.RB_Center_Right = QtWidgets.QRadioButton()
self.RB_Center_Right.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowRight))) #
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(90), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Center_Right.setIcon(iconRotate)
self.RB_Center_Right.clicked.connect(self.on_RB_Image_clicked)
self.RB_Low_Left = QtWidgets.QRadioButton()
self.RB_Low_Left.setLayoutDirection(QtCore.Qt.RightToLeft)
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(225), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Low_Left.setIconSize(QtCore.QSize(24, 24))
self.RB_Low_Left.setIcon(iconRotate)
self.RB_Low_Left.clicked.connect(self.on_RB_Image_clicked)
self.RB_Center_Bottom = QtWidgets.QRadioButton()
self.RB_Center_Bottom.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowDown))) #
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(180), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Center_Bottom.setIcon(iconRotate)
self.RB_Center_Bottom.clicked.connect(self.on_RB_Image_clicked)
self.RB_Low_Rigth = QtWidgets.QRadioButton()
iconRotate = QtGui.QPixmap(arrowUp).transformed(QtGui.QTransform().rotate(135), QtCore.Qt.SmoothTransformation)#Rotation
self.RB_Low_Rigth.setIconSize(QtCore.QSize(24, 24))
self.RB_Low_Rigth.setIcon(iconRotate)
self.RB_Low_Rigth.clicked.connect(self.on_RB_Image_clicked)
self.RB_Center = QtWidgets.QRadioButton()
self.RB_Center.setStyleSheet("")
self.RB_Center.setChecked(True)
self.RB_Center.setChecked(True)
self.RB_Center.clicked.connect(self.on_RB_Image_clicked)
####Screen Graphic BitMap
##https://doc.qt.io/qtforpython/PySide2/QtCore/Qt.html
self.graphicsView = QtWidgets.QGraphicsView()
pic = QtGui.QPixmap()
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_CE))
self.scene = QtWidgets.QGraphicsScene()
self.scene.addPixmap(QtGui.QPixmap(pic)) # png (bmp)
self.graphicsView.setScene(self.scene)
####Screen Graphic BitMap
###########################
# ####Screen Graphic SVG
# self.graphicsView = QtWidgets.QGraphicsView()
# pic = PySide2.QtSvg.QGraphicsSvgItem(path + "FreeCAD.svg") # svg
# self.scene = QtWidgets.QGraphicsScene()
# self.scene.addItem(pic)
# self.graphicsView.setScene(self.scene)
# ####Screen Graphic SVG
########################### PySide2.QtCore.
grid.addWidget(self.GBox_07_, 2, 2, 1, 3) #linge, colonne, ligne case, nombre de cases)
grid04 = QtWidgets.QGridLayout(self.GBox_07_)
grid04.addWidget(self.RB_Top_Left, 1, 0)
grid04.addWidget(self.RB_Center_Top, 1, 1)
grid04.addWidget(self.RB_Top_Rigth, 1, 2)
grid04.addWidget(self.RB_Center, 2, 1)
grid04.addWidget(self.RB_Center_Left, 3, 0)
grid04.addWidget(self.graphicsView, 3, 1)
grid04.addWidget(self.RB_Center_Right, 3, 2)
grid04.addWidget(self.RB_Low_Left, 4, 0)
grid04.addWidget(self.RB_Center_Bottom, 4, 1)
grid04.addWidget(self.RB_Low_Rigth, 4, 2)
#### #Graphique
# # tabWidget ####
##
self.GBox_06_ = QtWidgets.QGroupBox()
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setTabPosition(QtWidgets.QTabWidget.North)
self.tabWidget.setTabShape(QtWidgets.QTabWidget.Rounded)
self.TAB_Discretize = QtWidgets.QWidget()
####################
self.DS_Discretize = QtWidgets.QDoubleSpinBox()
#### # Doit demarrer en "Spinbox" !!
# self.DS_Discretize.setMinimum(0.000001) # DoubleSpinBox
# self.DS_Discretize.setMaximum(999999.99999) # DoubleSpinBox
# self.DS_Discretize.setDecimals(3) # DoubleSpinBox
####
self.DS_Discretize.setSuffix(" Sec") # nombre de Sections
self.DS_Discretize.setMinimum(1) # SpinBox
self.DS_Discretize.setMaximum(999999) # SpinBox
self.DS_Discretize.setDecimals(0) # SpinBox
self.discretize = int(self.discretize) # SpinBox
####
self.DS_Discretize.setValue(self.discretize)
self.DS_Discretize.valueChanged.connect(self.on_DS_Discretize) ###
####################
self.CB_Discretize = QtWidgets.QCheckBox()
self.CB_Discretize.clicked.connect(self.on_CB_Discretize_clicked)
self.CB_Reverse = QtWidgets.QCheckBox()
self.CB_Reverse.setEnabled(False)
self.CB_Reverse.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_BrowserReload))) #
self.CB_Reverse.clicked.connect(self.on_CB_Reverse)
self.PB_Del_Points = QtWidgets.QPushButton()
self.PB_Del_Points.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCancelButton))) #
self.PB_Del_Points.clicked.connect(self.on_PB_Del_Points) ###
self.PB_Discretize = QtWidgets.QPushButton()
self.PB_Discretize.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))) #
self.PB_Discretize.clicked.connect(self.on_PB_Discretize) ###
self.tabWidget.addTab(self.TAB_Discretize, "")
##
# # Tab_Face ####
##
self.Tab_Face = QtWidgets.QWidget()
self.PB_Reset_Face = QtWidgets.QPushButton()
self.PB_Reset_Face.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogResetButton))) #
self.PB_Reset_Face.clicked.connect(self.on_PB_Reset_Sweep) ###
self.PB_Visibility = QtWidgets.QPushButton()
self.PB_Visibility.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_FileDialogListView))) #
self.PB_Visibility.clicked.connect(self.on_PB_Visibility) ###
self.PB_Create_Face = QtWidgets.QPushButton()
self.PB_Create_Face.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))) #
self.PB_Create_Face.clicked.connect(self.on_PB_Create_Face) ###
self.tabWidget.addTab(self.Tab_Face, "")
self.tabWidget.addTab(self.Tab_Face, "")
##
# # Tab_Sweep ####
##
self.Tab_Sweep = QtWidgets.QWidget()
self.PB_Reset_Sweep = QtWidgets.QPushButton()
self.PB_Reset_Sweep.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogResetButton))) #
self.PB_Reset_Sweep.clicked.connect(self.on_PB_Reset_Sweep) ###
self.PB_Del_Sweep = QtWidgets.QPushButton()
self.PB_Del_Sweep.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCancelButton))) #
self.PB_Del_Sweep.clicked.connect(self.on_PB_Del_Sweep) ###
self.PB_Sweep = QtWidgets.QPushButton()
self.PB_Sweep.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))) #
self.PB_Sweep.clicked.connect(self.on_PB_Sweep) ###
self.CB_Solid_Sweep = QtWidgets.QCheckBox(self.Tab_Sweep)
#self.CB_Solid_Sweep.clicked.connect(self.on_CB_Solid_Sweep)
self.CB_Frenet_Sweep = QtWidgets.QCheckBox()
#self.CB_Frenet_Sweep.clicked.connect(self.on_CB_Frenet_Sweep)
self.tabWidget.addTab(self.Tab_Sweep, "")
##
# # Tab_Loft ####
##
self.Tab_Loft = QtWidgets.QWidget()
self.PB_Reset_Loft = QtWidgets.QPushButton()
self.PB_Reset_Loft.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogResetButton))) #
self.PB_Reset_Loft.clicked.connect(self.on_PB_Reset_Sweep) ###
self.PB_Del_Loft = QtWidgets.QPushButton()
self.PB_Del_Loft.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCancelButton))) #
self.PB_Del_Loft.clicked.connect(self.on_PB_Del_Sweep) ###
self.PB_Loft = QtWidgets.QPushButton()
self.PB_Loft.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))) #
self.PB_Loft.clicked.connect(self.on_PB_Loft) ###
self.CB_Solid_Loft = QtWidgets.QCheckBox()
#self.CB_Solid_Loft.clicked.connect(self.on_CB_Solid_Loft)
self.CB_Ruled_Loft = QtWidgets.QCheckBox()
#self.CB_Ruled_Loft.clicked.connect(self.on_CB_Ruled_Loft)
self.CB_Closed_Loft = QtWidgets.QCheckBox()
#self.CB_Closed_Loft.clicked.connect(self.on_CB_Closed_Loft)
self.tabWidget.addTab(self.Tab_Loft, "")
grid.addWidget(self.GBox_06_, 4, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
gridBox = QtWidgets.QGridLayout(self.GBox_06_)
gridBox.addWidget(self.tabWidget, 4, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid05 = QtWidgets.QGridLayout(self.TAB_Discretize)
grid05.addWidget(self.DS_Discretize, 0, 0)
grid05.addWidget(self.CB_Discretize, 0, 1)
grid05.addWidget(self.CB_Reverse, 0, 2)
grid05.addWidget(self.PB_Del_Points, 1, 0)
grid05.addWidget(self.PB_Discretize, 1, 1)
gridBox.addWidget(self.tabWidget, 4, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid06 = QtWidgets.QGridLayout(self.Tab_Face)
grid06.addWidget(self.PB_Reset_Face, 0, 0)
grid06.addWidget(self.PB_Visibility, 0, 1)
grid06.addWidget(self.PB_Create_Face, 0, 2)
gridBox.addWidget(self.tabWidget, 4, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid07 = QtWidgets.QGridLayout(self.Tab_Sweep)
grid07.addWidget(self.PB_Reset_Sweep, 0, 0)
grid07.addWidget(self.PB_Del_Sweep, 0, 1)
grid07.addWidget(self.PB_Sweep, 0, 2)
grid07.addWidget(self.CB_Solid_Sweep, 1, 0)
grid07.addWidget(self.CB_Frenet_Sweep, 1, 1)
gridBox.addWidget(self.tabWidget, 4, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid08 = QtWidgets.QGridLayout(self.Tab_Loft)
grid08.addWidget(self.PB_Reset_Loft, 0, 0)
grid08.addWidget(self.PB_Del_Loft, 0, 1)
grid08.addWidget(self.PB_Loft, 0, 2)
grid08.addWidget(self.CB_Solid_Loft, 1, 0)
grid08.addWidget(self.CB_Ruled_Loft, 1, 1)
grid08.addWidget(self.CB_Closed_Loft, 1, 2)
#### #Tab
####
# # Sortie ####
####
#### #Sortie
self.GBox_05_ = QtWidgets.QGroupBox()
self.PB_Del_Last_Line = QtWidgets.QPushButton()
self.PB_Del_Last_Line.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCancelButton))) #
self.PB_Del_Last_Line.clicked.connect(self.on_PB_Del_Last_Line) ###
self.PB_Quit = QtWidgets.QPushButton()
##https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
##https://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum
self.PB_Quit.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCloseButton))) #PySide2 Qt5
self.PB_Quit.clicked.connect(self.on_PB_Quit) ###
self.PB_Create = QtWidgets.QPushButton()
self.PB_Create.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))) #
self.PB_Create.clicked.connect(self.on_PB_Create) ###
grid.addWidget(self.GBox_05_, 5, 0, 1, 2) #linge, colonne, ligne case, nombre de cases)
grid09 = QtWidgets.QGridLayout(self.GBox_05_)
grid09.addWidget(self.PB_Quit, 0, 0)
grid09.addWidget(self.PB_Del_Last_Line, 0, 1)
grid09.addWidget(self.PB_Create, 0, 2)
#### #Sortie
#### #Info
self.frame = QtWidgets.QFrame()
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
grid.addWidget(self.frame, 6, 0, 1, 3) #ligne, colonne) frame in centralwidget
frame01 = QtWidgets.QGridLayout(self.frame)
frame01.addWidget(self.label_Info, 0, 0)
#### #Info
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_fromUtf8("Connect and Sweep (" + __version__ + ") rmu")) #" " + __date__ +
MainWindow.setWindowIcon(QtGui.QIcon(_fromUtf8(self.path+'Macro_Connect_And_Sweep.png'))) # change l'icone de la fenetre principale
MainWindow.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # PySide2 cette fonction met la fenetre en avant
self.label.setText(_translate("MainWindow", "Connect And Sweep"))
# self.PB_Help.setText(_fromUtf8("Help"))
self.GBox_00.setTitle(_translate("MainWindow", "Mode"))
self.RB_01_BBox_Oject.setText(_translate("MainWindow", "1 : Object + Object"))
self.RB_01_BBox_Oject.setToolTip(_fromUtf8("Create the connection to BoundBox center"+"\n"
"Center first object selected to center second Object selected"+"\n\n"
"If one error of selection is detected the mode change to the mode 3"+"\n"
"and the radio button mode 3 is colored in orange to warn you"+"\n"))
self.RB_02_BBox_Subo.setText(_translate("MainWindow", "2 : Object + S_Object"))
self.RB_02_BBox_Subo.setToolTip(_fromUtf8("Create the connection to BoundBox center"+"\n"
"the first selection = Object (BoundBox center)"+"\n"
"the second selection = SubObject (BoundBox center of the SubObject)"+"\n\n"
"Example: if one line is selected center BoundingBox of the line is the center of line"+"\n"
"if one circle is selected center BoundingBox of the circle is the center of circle"+"\n\n"
"If one error of selection is detected the mode change to the mode 3"+"\n"
"and the radio button mode 3 is colored in orange to warn you"+"\n"))
self.RB_03_Subo_Subo.setText(_translate("MainWindow", "3 : S_Object + S_Object"))
self.RB_03_Subo_Subo.setToolTip(_fromUtf8("Create the connection to BoundBox center"+"\n"
"the first selection = SubObject (BoundBox center of the first SubObject)"+"\n"
"the second selection = SubObject (BoundBox center of the second SubObject)"+"\n"
"the SubObject can be: "+"\n"
"Line, wire, edge, face "+"\n\n"
"PS: If only one line is selected the object created follow the DIRECTION of the line or curve"+"\n"
"If one circle is selected, one line of length 0 is created"+"\n"
"(the points are in point 0 and point 360 and are in the same place.)"))
self.label_Info.setText(_translate("MainWindow", __version__ + " " + __date__ + " rmu"))
self.label_Info.setToolTip(_fromUtf8("Information of the wire selected :" + "\n"
"Number of points created : Length of the wire"))
self.GBox_02_.setTitle(_translate("MainWindow", "Sweep Forme"))
self.SB_Polyline_Number_Faces.setSuffix(_translate("MainWindow", " num"))
self.SB_Polyline_Number_Faces.setToolTip(_fromUtf8("Enter number faces"))
self.DS_Polyline_CirCon.setSuffix(_translate("MainWindow", " Cir mm"))
self.DS_Polyline_CirCon.setToolTip(_fromUtf8("Radius polygon"))
self.RB_Polyline.setText(_translate("MainWindow", "Polygone"))
self.CB_Insc_Circon.setText(_translate("MainWindow", "Polygon Circumscribed"))
self.CB_Insc_Circon.setToolTip(_fromUtf8("Circumscribed by default, if checked then Inscribed"))
self.DS_Rectangle_Y.setSuffix(_translate("MainWindow", " H mm"))
self.DS_Rectangle_Y.setToolTip(_fromUtf8("Rectangle Height"))
self.DS_Rectangle_X.setSuffix(_translate("MainWindow", " L mm"))
self.DS_Rectangle_X.setToolTip(_fromUtf8("Rectangle Length"))
self.RB_Rectangle.setText(_translate("MainWindow", "Rectangle"))
self.RB_Ellipse.setText(_translate("MainWindow", "Ellipse"))
self.DS_Circle_Diameter.setSuffix(_translate("MainWindow", " d mm"))
self.DS_Circle_Diameter.setToolTip(_fromUtf8("Diameter of circle"))
self.DS_Circle_Radius.setSuffix(_translate("MainWindow", " r mm"))
self.DS_Circle_Radius.setToolTip(_fromUtf8("Radius of circle"))
self.RB_Circle.setText(_translate("MainWindow", "Circle"))
self.RB_Line.setText(_translate("MainWindow", "Line"))
self.CB_Solid.setText(_translate("MainWindow", "Solid"))
self.CB_Solid.setToolTip(_fromUtf8("Create solid checked by default"+"\n"
"If is not checked then is pipe empty (Shell)"+"\n"
"If thickness is not 0 the Solid checkBox is checked automatically"))
self.label_Pipe.setText(_translate("MainWindow", "Pipe"))
self.DS_Pipe.setToolTip(_translate("MainWindow", "thickness of pipe"))
self.DS_Pipe.setSuffix(_translate("MainWindow", " Thickness"))
self.DS_Pipe.setToolTip(_fromUtf8("Thickness of pipe"+"\n"
"If thickness = 0 the object is solid and not pipe"+"\n"
"If thickness is larger than a dimension of the object,"+"\n"
"thickness is ignored"+"\n"
"If this function is used with a Line the LineWidth is affected."))
self.GBox_07_.setTitle(_translate("MainWindow", "Corner point position (on X Y Axis)"))
self.RB_Top_Left.setText(_translate("MainWindow", "Top Left"))
self.RB_Top_Left.setToolTip(_fromUtf8("The selected point is in the upper left corner"+"\n"
"The selection order can reverse the form"+"\n"
"Select the objects from the smallest to the largest coordinated"))
self.RB_Center_Top.setText(_translate("MainWindow", "Center Top"))
self.RB_Center_Top.setToolTip(_fromUtf8("The selected point is the center face Top of the beam"))
self.RB_Top_Rigth.setText(_translate("MainWindow", "Top Rigth"))
self.RB_Top_Rigth.setToolTip(_fromUtf8("The selected point is in the upper rigth corner"+"\n"
"The selection order can reverse the form"+"\n"
"Select the objects from the smallest to the largest coordinated"))
self.RB_Center_Left.setText(_translate("MainWindow", "Center Left"))
self.RB_Center_Left.setToolTip(_fromUtf8("The selected point is the center face Left of the beam"))
self.RB_Center_Right.setText(_translate("MainWindow", "Center Right"))
self.RB_Center_Right.setToolTip(_fromUtf8("The selected point is the center face Right of the beam"))
self.RB_Low_Left.setText(_translate("MainWindow", "Low Left"))
self.RB_Low_Left.setToolTip(_fromUtf8("The selected point is in the low left corner"+"\n"
"The selection order can reverse the form"+"\n"
"Select the objects from the smallest to the largest coordinated"))
self.RB_Center_Bottom.setText(_translate("MainWindow", "Center Bottom"))
self.RB_Center_Bottom.setToolTip(_fromUtf8("The selected point is the center face Bottom of the beam"))
self.RB_Low_Rigth.setText(_translate("MainWindow", "Low Rigth"))
self.RB_Low_Rigth.setToolTip(_fromUtf8("The selected point is in the low rigth corner"+"\n"
"The selection order can reverse the form"+"\n"
"Select the objects from the smallest to the largest coordinated"))
self.RB_Center.setText(_translate("MainWindow", "Center"))
self.RB_Center.setToolTip(_fromUtf8("The selected point is in the center of forme"))
self.GBox_06_.setTitle(_translate("MainWindow", "Options"))
self.DS_Discretize.setSuffix(_translate("MainWindow", " sec"))
self.DS_Discretize.setToolTip(_fromUtf8("Enter number cut"))
self.CB_Discretize.setText(_translate("MainWindow", "Sections")) #Dimension
self.CB_Discretize.setToolTip(_fromUtf8("Check this checkBox for choice:" + "\n"
"Section (Sec) : the line is cut in x egual sections" + "\n"
"Dimension (mm) : the line is cut in x parts with the dimension request"))
self.CB_Reverse.setText(_translate("MainWindow", "Reverse"))
self.CB_Reverse.setToolTip(_fromUtf8("Check for reverse the order points created" + "\n"
"only with the Dimension (mm) option"))
self.PB_Del_Points.setText(_translate("MainWindow", "Del last Points"))
self.PB_Del_Points.setToolTip(_fromUtf8("Delete the last package of points created"))
self.PB_Discretize.setText(_translate("MainWindow", "Process Discretize"))
self.PB_Discretize.setToolTip(_fromUtf8("Process the operation creation of points" + "\n"
"after discretize"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.TAB_Discretize), _translate("MainWindow", "Discretize Line"))
self.PB_Reset_Face.setText(_translate("MainWindow", "Reset"))
self.PB_Reset_Face.setToolTip(_fromUtf8("Reset the selection(s) for the Sweep, Loft, Face, Edge or" + "\n"
"Duplicate operation BUT not delette the object created"))
self.PB_Visibility.setText(_translate("MainWindow", "Visibility"))
self.PB_Visibility.setToolTip(_fromUtf8("Restore the visibility" + "\n"
"on the all object selected for create a Duplicate button" + "\n"
"The button is active for the duplicate objects until" + "\n"
"the creation of Sweep (Button)" + "\n"
"If the duplication is not used (empty) this button can be used" + "\n"
"for hide/display the object selected (only the object selcted)"))
self.PB_Create_Face.setText(_translate("MainWindow", "Create Face"))
self.PB_Create_Face.setToolTip(_fromUtf8("Create a Face or Edge on S_obect selected" + "\n"
"The original object used for create a face or duplicate" + "\n"
"is made hidden to access easily on new object created" + "\n"
"This function are used by the Sweep tools button"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Tab_Face), _translate("MainWindow", "Duplicate F/W"))
self.PB_Reset_Sweep.setText(_translate("MainWindow", "Reset"))
self.PB_Reset_Sweep.setToolTip(_fromUtf8("Reset the selection(s) for the Sweep, Loft, Face, Edge or" + "\n"
"Duplicate operation BUT not delette the object created"))
self.PB_Del_Sweep.setText(_translate("MainWindow", "Del last Sweep"))
self.PB_Del_Sweep.setToolTip(_fromUtf8("Delette the last object created" + "\n"
"Sweep, Loft, Edge or Face"))
self.PB_Sweep.setText(_translate("MainWindow", "Create Sweep"))
self.PB_Sweep.setToolTip(_fromUtf8("Create a sweep with the face(s) created and the path selected" + "\n"
"For create the sweep:" + "\n"
"create first the face(s) with the Duplicate button" + "\n"
"Using this button delette the listing of the names memorised" + "\n"
"with the Duplicate button"))
self.CB_Solid_Sweep.setText(_translate("MainWindow", "Solid"))
self.CB_Solid_Sweep.setToolTip(_fromUtf8("Check for create a Solid Sweep"))
self.CB_Frenet_Sweep.setText(_translate("MainWindow", "Frenet"))
self.CB_Frenet_Sweep.setToolTip(_fromUtf8("Check for create a Frenet Sweep"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Tab_Sweep), _translate("MainWindow", "Sweep"))
self.PB_Reset_Loft.setText(_translate("MainWindow", "Reset"))
self.PB_Reset_Loft.setToolTip(_fromUtf8("Reset the selection(s) for the Sweep, Loft, Face, Edge or" + "\n"
"Duplicate operation BUT not delette the object created"))
self.PB_Del_Loft.setText(_translate("MainWindow", "Del last Loft"))
self.PB_Del_Loft.setToolTip(_fromUtf8("Delette the last object created" + "\n"
"Sweep, Loft, Edge or Face"))
self.PB_Loft.setText(_translate("MainWindow", "Create Loft"))
self.PB_Loft.setToolTip(_fromUtf8("Create a loft with the face(s) created" + "\n"
"For create the loft:" + "\n"
"create first the face(s) with the Duplicate button" + "\n"
"Using this button delette the listing of the names memorised" + "\n"
"with the Duplicate button"))
self.CB_Solid_Loft.setText(_translate("MainWindow", "Solid"))
self.CB_Solid_Loft.setToolTip(_fromUtf8("Check for create a Solid Loft"))
self.CB_Ruled_Loft.setText(_translate("MainWindow", "Ruled"))
self.CB_Ruled_Loft.setToolTip(_fromUtf8("Check for create a Ruled Loft"))
self.CB_Closed_Loft.setText(_translate("MainWindow", "Closed"))
self.CB_Closed_Loft.setToolTip(_fromUtf8("Check for create a Closed Loft"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Tab_Loft), _translate("MainWindow", "Loft"))
self.GBox_05_.setTitle(_translate("MainWindow", "Command"))
self.PB_Create.setText(_translate("MainWindow", "Create Solid"))
self.PB_Create.setToolTip(_fromUtf8("Create the sweep or line"))
self.PB_Del_Last_Line.setText(_translate("MainWindow", "Del last Line"))
self.PB_Del_Last_Line.setToolTip(_fromUtf8("If the last form is not in the right direction" + "\n"
"you can delete it easily"))
self.PB_Quit.setText(_translate("MainWindow", "Quit"))
self.PB_Quit.setToolTip(_fromUtf8("Quit Connect And Sweep"))
def on_PB_Help(self): #
WebGui.openBrowser("http://www.freecadweb.org/wiki/index.php?title=Macro_Connect_And_Sweep")
App.Console.PrintMessage("http://www.freecadweb.org/wiki/index.php?title=Macro_Connect_And_Sweep" + "\n")
def colorThickness(self,value): # 0= couleur de Base , 1= couleur rouge
global ui
if (self.Thickness != 0.0):
if value != 0:
############### font and color modified
self.Thickness = 0.0
self.DS_Pipe.setValue(self.Thickness)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.DS_Pipe.setPalette(palette) # DSpinbox
self.DS_Pipe.setFont(font) # DSpinbox
App.Console.PrintWarning("Thickness aborded" + "\n")
self.label_Info.setText(_fromUtf8("Thickness aborded"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
############### font and color modified
else:
############### font and color base
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor("Base"))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
font = QtGui.QFont()
font.setBold(False)
self.DS_Pipe.setPalette(palette) # DSpinbox
self.DS_Pipe.setFont(font) # DSpinbox
###############
def on_RB_00_Mode_clicked(self):
self.RB_01_BBox_Oject.setStyleSheet("background-color: QPalette.Base")# origin system
self.RB_02_BBox_Subo.setStyleSheet("background-color: QPalette.Base") # origin system
self.RB_03_Subo_Subo.setStyleSheet("background-color: QPalette.Base") # origin system
def on_SB_Polyline_Number_Faces(self,value):
self.Polyline_Number_Faces = value
def on_DS_Circle_Radius(self,value):
self.Circle_Radius = value
self.Circle_Diameter = self.Circle_Radius * 2.0
self.DS_Circle_Diameter.setValue(self.Circle_Diameter)
def on_DS_Circle_Diameter(self,value):
self.Circle_Diameter = value
self.Circle_Radius = self.Circle_Diameter / 2.0
self.DS_Circle_Radius.setValue(self.Circle_Radius)
def on_DS_Polyline_CirCon(self,value):
self.Polyline_CirCon = value
def on_DS_Rectangle_X(self,value):
self.Rectangle_X = value
def on_DS_Rectangle_Y(self,value):
if value > self.Rectangle_X:
value = self.Rectangle_X
self.DS_Rectangle_Y.setValue(value)
self.Rectangle_Y = value
def on_DS_Pipe(self,value):
global ui
self.Thickness = value
if self.Thickness != 0.0:
self.CB_Solid.setChecked(True)
self.PB_Create.setText("Create Solid")
self.CB_Solid.setText(_fromUtf8("Solid"))
if self.RB_Polyline.isChecked():
self.PB_Create.setText(_fromUtf8("Create Pipe Polyline"))
elif self.RB_Rectangle.isChecked():
self.PB_Create.setText(_fromUtf8("Create Pipe Rectangle"))
elif self.RB_Ellipse.isChecked():
self.PB_Create.setText(_fromUtf8("Create Pipe Ellipse"))
elif self.RB_Circle.isChecked():
self.PB_Create.setText(_fromUtf8("Create Pipe Circle"))
elif self.RB_Line.isChecked():
self.PB_Create.setText(_fromUtf8("Create Width Line"))
else:
self.CB_Solid.setChecked(True)
if self.RB_Polyline.isChecked():
self.PB_Create.setText(_fromUtf8("Create Solid Polyline"))
elif self.RB_Rectangle.isChecked():
self.PB_Create.setText(_fromUtf8("Create Solid Rectangle"))
elif self.RB_Ellipse.isChecked():
self.PB_Create.setText(_fromUtf8("Create Solid Ellipse"))
elif self.RB_Circle.isChecked():
self.PB_Create.setText(_fromUtf8("Create Solid Circle"))
elif self.RB_Line.isChecked():
self.PB_Create.setText(_fromUtf8("Create Line"))
ff = ui
ff.colorThickness(0)
def on_CB_Insc_Circon_clicked(self):
if self.CB_Insc_Circon.isChecked():
self.DS_Polyline_CirCon.setSuffix(" Ins mm")
self.CB_Insc_Circon.setText(_fromUtf8("Polygon Inscribed"))
else:
self.DS_Polyline_CirCon.setSuffix(" Cir mm")
self.CB_Insc_Circon.setText(_fromUtf8("Polygon Circumscribed"))
def on_CB_Solid_clicked(self):
global ui
if self.CB_Solid.isChecked():
self.PB_Create.setText("Create Solid")
self.CB_Solid.setText(_fromUtf8("Solid"))
else:
self.PB_Create.setText("Create Empty (Shell)")
self.CB_Solid.setText(_fromUtf8("Shell"))
if self.Thickness != 0.0:
self.CB_Solid.setChecked(True)
ui.on_DS_Pipe(self.Thickness)
def on_RB_Polyline_clicked(self):
global ui
self.GBox_07_.setVisible(False)
MainWindow.resize(QtCore.QSize(360, 570))
FreeCADGui.updateGui() # rafraichi l'ecran
MainWindow.resize(QtCore.QSize(360, 570))
if self.RB_Polyline.isChecked():
ui.on_DS_Pipe(self.Thickness)
self.DS_Circle_Radius.setVisible(True)
self.DS_Circle_Diameter.setVisible(True)
self.label_Pipe.setText(_fromUtf8("Pipe"))
def on_RB_Rectangle_clicked(self):
global ui
ui.on_DS_Pipe(self.Thickness)
MainWindow.resize(750, 570)
self.GBox_07_.setVisible(True)
self.grid03.addWidget(self.DS_Rectangle_X, 2, 1)
self.grid03.addWidget(self.DS_Rectangle_Y, 2, 2)
self.DS_Rectangle_X.setSuffix(" L mm")
self.DS_Rectangle_Y.setSuffix(" H mm")
self.DS_Rectangle_X.setToolTip(_fromUtf8("Rectangle Length"))
self.DS_Rectangle_Y.setToolTip(_fromUtf8("Rectangle Height"))
self.label_Pipe.setText(_fromUtf8("Pipe"))
def on_RB_Ellipse_clicked(self):
global ui
ui.on_DS_Pipe(self.Thickness)
MainWindow.resize(750, 570)
self.GBox_07_.setVisible(True)
self.grid03.addWidget(self.DS_Rectangle_X, 3, 1)
self.grid03.addWidget(self.DS_Rectangle_Y, 3, 2)
self.DS_Rectangle_X.setSuffix(" R mm")
self.DS_Rectangle_Y.setSuffix(" r mm")
self.DS_Rectangle_X.setToolTip(_fromUtf8("Ellipse MajorRadius"))
self.DS_Rectangle_Y.setToolTip(_fromUtf8("Ellipse MinorRadius"))
self.label_Pipe.setText(_fromUtf8("Pipe"))
def on_RB_Image_clicked(self):
pic = QtGui.QPixmap()
if self.RB_Top_Left.isChecked():
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_TL))
elif self.RB_Top_Rigth.isChecked():
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_TR))
elif self.RB_Low_Left.isChecked():
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_LL))
elif self.RB_Low_Rigth.isChecked():
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_LR))
elif self.RB_Center.isChecked():
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_CE))
elif self.RB_Center_Top.isChecked(): # center dessus poutrelle
pic.loadFromData(base64.b64decode(CenterTop_b64))
elif self.RB_Center_Right.isChecked(): # Rectangle Center_Right
pic.loadFromData(base64.b64decode(CenterRigth_b64))
elif self.RB_Center_Left.isChecked(): # Rectangle Center Left
pic.loadFromData(base64.b64decode(CenterLeft_b64))
elif self.RB_Center_Bottom.isChecked(): # Rectangle Center Bottom
pic.loadFromData(base64.b64decode(CenterBottom_b64))
else:
pic.loadFromData(base64.b64decode(Macro_Connect_And_Sweep_CE))
self.scene = QtWidgets.QGraphicsScene()
self.scene.addPixmap(QtGui.QPixmap(pic))
self.graphicsView.setScene(self.scene)
def on_RB_Circle_clicked(self):
global ui
self.GBox_07_.setVisible(False)
MainWindow.resize(QtCore.QSize(360, 570))
FreeCADGui.updateGui() # rafraichi l'ecran
MainWindow.resize(QtCore.QSize(360, 570))
if self.RB_Circle.isChecked():
ui.on_DS_Pipe(self.Thickness)
self.label_Pipe.setText(_fromUtf8("Pipe"))
def on_RB_Line_clicked(self):
global ui
self.GBox_07_.setVisible(False)
MainWindow.resize(QtCore.QSize(360, 570))
FreeCADGui.updateGui() # rafraichi l'ecran
MainWindow.resize(QtCore.QSize(360, 570))
if self.RB_Line.isChecked():
ui.on_DS_Pipe(self.Thickness)
self.label_Pipe.setText(_fromUtf8("Line"))
def on_DS_Discretize(self, value):
if self.CB_Discretize.isChecked():
self.discretize = float(value)
else:
self.discretize = int(value)
self.DS_Discretize.setValue(self.discretize)
def on_CB_Discretize_clicked(self):
if self.CB_Discretize.isChecked():
self.DS_Discretize.setMinimum(0.000001)
self.DS_Discretize.setMaximum(999999)
self.DS_Discretize.setDecimals(3)
self.DS_Discretize.setSuffix(" mm")
self.DS_Discretize.setValue(float(self.discretize))
self.CB_Discretize.setText(_fromUtf8("Dimension"))
self.CB_Reverse.setEnabled(True)
else:
self.DS_Discretize.setMinimum(1)
self.DS_Discretize.setMaximum(999999)
self.DS_Discretize.setDecimals(0)
self.DS_Discretize.setSuffix(" Sec")
self.discretize = int(self.discretize)
self.CB_Discretize.setText(_fromUtf8("Sections"))
self.CB_Reverse.setEnabled(False)
self.CB_Reverse.setChecked(False)
self.DS_Discretize.setValue(self.discretize)
def on_CB_Reverse(self):
None
def on_PB_Del_Points(self):
try:
FreeCAD.ActiveDocument.getObject(self.CASweep.Name).removeObjectsFromDocument()
FreeCAD.ActiveDocument.removeObject(self.CASweep.Name)
#01 for de in self.nameL:
#01 FreeCAD.ActiveDocument.removeObject(de)
#01 del self.nameL[:]
except Exception:
None
def on_PB_Discretize(self):
try:
selD = FreeCADGui.Selection.getSelectionEx()
longueur = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0].Length
subElementName = Gui.Selection.getSelectionEx()[0].SubElementNames[0]
self.CASweep = App.activeDocument().addObject("App::DocumentObjectGroup","CASweep_" + subElementName)
#01 self.nameL = []
#01 del self.nameL[:]
if self.CB_Discretize.isChecked():
if self.CB_Reverse.isChecked(): #reverse
debutLine = selD[0].SubObjects[0].Edges[0].Vertexes[0].Point
finLine = selD[0].SubObjects[0].Edges[0].Vertexes[1].Point
lineReverse = Part.LineSegment(finLine, debutLine).toShape()
Part.show(lineReverse)
lineReverse = Part.LineSegment(finLine, debutLine).toShape()
pointsDirection = lineReverse.discretize(Distance = self.discretize) # distance en mm reverse
FreeCAD.ActiveDocument.removeObject(App.ActiveDocument.ActiveObject.Name)
else: #Forward
pointsDirection = selD[0].SubObjects[0].discretize(Distance = self.discretize) # distance en mm nomal
else:
pointsDirection = selD[0].SubObjects[0].discretize(self.discretize + 1) # nombre de coupes
for i in pointsDirection:
point = Draft.makePoint(i)
FreeCADGui.ActiveDocument.getObject(point.Name).PointColor = (1.0,0.0,0.0)
self.CASweep.addObject(point) # conteneur dossier points
#01 self.nameL.append(point.Name)
FreeCAD.ActiveDocument.recompute()
#01 self.label_Info.setText(_fromUtf8("Number points : " + str(len(pointsDirection)) + " ; Length wire : " + str(round(longueur,3))))
except Exception:
App.Console.PrintError("Error Discretize !" + "\n")
self.label_Info.setText(_fromUtf8("Error Discretize !"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
FreeCAD.ActiveDocument.recompute()
def on_PB_Create_Face(self):
try:
sel = FreeCADGui.Selection.getSelection()
self.ElementName = FreeCADGui.Selection.getSelection()[0].Name
subElementName = Gui.Selection.getSelectionEx()[0].SubElementNames[0]
try:
Gui.runCommand('Part_ElementCopy',0) #ici pour la FC 0.19 et + use the FC feature
except Exception :
Part.show(FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0].copy()) # create repro shape subObject
try:
if (str(sel[0].InList[0]) == "<body object>") or (str(sel[0].InList[0]) == "<Part object>"):
objectRealPlacement3DX, objectPlacementAngle = objectRealPlacement3D(FreeCAD.ActiveDocument.getObject(self.ElementName))# search the original Placement
a = App.ActiveDocument.ActiveObject #ici avec la FC 0.18
a.Placement = App.Placement(App.Vector(objectRealPlacement3DX), App.Rotation(objectPlacementAngle[0], objectPlacementAngle[1], objectPlacementAngle[2]), App.Vector(0,0,0))
else:
None
except Exception:
None
App.ActiveDocument.ActiveObject.Label = App.ActiveDocument.ActiveObject.Label + "_" + subElementName
FreeCADGui.activeDocument().getObject(self.ElementName).Visibility = False
try:
FreeCADGui.activeDocument().activeObject().LineColor = (1.0,0.0,0.0) # give LineColor
FreeCADGui.activeDocument().activeObject().PointColor = (1.0,0.0,0.0) # give PointColor
FreeCADGui.activeDocument().activeObject().ShapeColor = (1.0,0.0,0.0) # give ShapeColor
except Exception:
None
if self.ElementName in self.selectForDuplicate:
None
else:
self.selectForDuplicate.append(self.ElementName)
FreeCAD.ActiveDocument.recompute()
self.PB_Reset_Sweep.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Loft.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Face.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Visibility.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Sweep.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Loft.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Face.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
except Exception:
None
App.ActiveDocument.recompute()
def on_PB_Visibility(self): # after created face
try:
if len(self.selectForDuplicate) == 0:
self.ElementName = FreeCADGui.Selection.getSelection()[0].Name
if FreeCADGui.activeDocument().getObject(self.ElementName).Visibility == True:
FreeCADGui.activeDocument().getObject(self.ElementName).Visibility = False
else:
FreeCADGui.activeDocument().getObject(self.ElementName).Visibility = True
else:
for visible in self.selectForDuplicate:
if FreeCADGui.activeDocument().getObject(visible).Visibility == True:
FreeCADGui.activeDocument().getObject(visible).Visibility = False
else:
FreeCADGui.activeDocument().getObject(visible).Visibility = True
except Exception:
None
def on_PB_Reset_Sweep(self): # Sweep or Duplicate or Face or Loft (self.selectForDuplicate)
for visible in self.selectForDuplicate: #restore the visible objects
FreeCADGui.activeDocument().getObject(visible).Visibility = True
self.selectForDuplicate = []
self.PB_Reset_Sweep.setText(_fromUtf8("Reset"))
self.PB_Reset_Loft.setText(_fromUtf8("Reset"))
self.PB_Reset_Face.setText(_fromUtf8("Reset"))
self.PB_Visibility.setStyleSheet("Base")
self.PB_Reset_Sweep.setStyleSheet("Base")
self.PB_Reset_Loft.setStyleSheet("Base")
self.PB_Reset_Face.setStyleSheet("Base")
def on_PB_Del_Sweep(self):
try:
FreeCAD.ActiveDocument.removeObject(self.sweepFaceName)
except Exception:
None
def on_PB_Sweep(self): #
try:
selForSweep = FreeCADGui.Selection.getSelection()
subElementSweep = Gui.Selection.getSelectionEx()[len(selForSweep)-1].SubElementNames[0]
#if (selForSweep[0].Shape.ShapeType == "Face"):
#else:
# print("Error selection : ",selForSweep[0].Shape.ShapeType," ",selForSweep[1].Shape.ShapeType)
if len(selForSweep) > 1:
sweepFace = FreeCAD.ActiveDocument.addObject('Part::Sweep','Sweep')
self.sweepFaceName = sweepFace.Name
sweepFace.Sections = [FreeCAD.ActiveDocument.getObject(o.Name) for o in selForSweep[:-1]]
sweepFace.Spine = FreeCAD.ActiveDocument.getObject(selForSweep[-1].Name),[subElementSweep]
if self.CB_Solid_Sweep.isChecked():
sweepFace.Solid = True
else:
sweepFace.Solid = False
if self.CB_Frenet_Sweep.isChecked():
sweepFace.Frenet = True
else:
sweepFace.Frenet = False
sweepFace.Label = selForSweep[0].Label + "_" + selForSweep[-1].Name
for visible in self.selectForDuplicate: #restore the visible objects
FreeCADGui.activeDocument().getObject(visible).Visibility = True
self.selectForDuplicate = []
self.PB_Reset_Sweep.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Loft.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Face.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Visibility.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Sweep.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Loft.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Face.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
except Exception:
try:
FreeCAD.ActiveDocument.removeObject(self.sweepFaceName)
except Exception:
None
App.ActiveDocument.recompute()
def on_PB_Loft(self):
try:
selForLoft = FreeCADGui.Selection.getSelection()
subElementSweep = Gui.Selection.getSelectionEx()[len(selForLoft)-1].SubElementNames[0]
#if (selForLoft[0].Shape.ShapeType == "Face"):
#else:
# print("Error selection : ",selForLoft[0].Shape.ShapeType," ",selForLoft[1].Shape.ShapeType)
if len(selForLoft) > 1:
loftFace = FreeCAD.ActiveDocument.addObject('Part::Loft','Loft')
self.sweepFaceName = loftFace.Name
loftFace.Sections = [FreeCAD.ActiveDocument.getObject(o.Name) for o in selForLoft]
if self.CB_Solid_Loft.isChecked():
loftFace.Solid = True
else:
loftFace.Solid = False
if self.CB_Ruled_Loft.isChecked():
loftFace.Ruled = True
else:
loftFace.Closed = False
if self.CB_Closed_Loft.isChecked():
loftFace.Closed = True
else:
loftFace.Closed = False
loftFace.Label = selForLoft[0].Label + "_" + selForLoft[-1].Name
for visible in self.selectForDuplicate: #restore the visible objects
FreeCADGui.activeDocument().getObject(visible).Visibility = True
self.selectForDuplicate = []
self.PB_Reset_Sweep.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Loft.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Reset_Face.setText(_fromUtf8("Reset " + str(len(self.selectForDuplicate))))
self.PB_Visibility.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Sweep.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Loft.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
self.PB_Reset_Face.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(115, 210, 22);") # bord white and green
except Exception:
try:
FreeCAD.ActiveDocument.removeObject(self.sweepFaceName)
except Exception:
None
App.ActiveDocument.recompute()
def on_PB_Quit(self): # Quit
App.Console.PrintMessage(str("Fin Connect And Sweep ")+"\n")
self.window.hide()
def on_PB_Del_Last_Line(self): # Del Last Line
self.label_Info.setStyleSheet("QPalette.Base") # origin system
self.label_Info.setText(_fromUtf8( __version__ + " " + __date__ + " rmu"))
try:
FreeCAD.ActiveDocument.getObject(self.FcSweep.Name).removeObjectsFromDocument()
FreeCAD.ActiveDocument.removeObject(self.FcSweep.Name)
except Exception:
self.PB_Del_Last_Line.setText(_fromUtf8("?"))
None
def on_PB_Create(self): # Create
try:
if len(Gui.Selection.getSelection()) >= 1:
self.label_Info.setStyleSheet("QPalette.Base") # origin system
self.label_Info.setText(_fromUtf8( __version__ + " " + __date__ + " rmu"))
if self.RB_01_BBox_Oject.isChecked(): # Obj Obj
boundBox_0 = Gui.Selection.getSelection()[0].Shape.BoundBox.Center # Object 1 is Object BBox
boundBox_0 = boundBox_0.add(objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB"))####
try:
boundBox_1 = Gui.Selection.getSelection()[1].Shape.BoundBox.Center # Object 2 is Object BBox
boundBox_1 = boundBox_1.add(objectRealPlacement3D(Gui.Selection.getSelection()[1],0,"BB"))####
except Exception:
self.RB_03_Subo_Subo.setChecked(True)
self.RB_03_Subo_Subo.setStyleSheet("background-color: #f57900 ")
FreeCAD.Console.PrintError("Bad selection or 1 object selected instead 2 in mode BBox Obj Obj"+"\n"
"mode changed to mode 3 BBox SObj. SObj. "+"\n")
#print("1")
elif self.RB_02_BBox_Subo.isChecked(): # Obj SObj
boundBox_0 = Gui.Selection.getSelection()[0].Shape.BoundBox.Center # Object 2 is Object BBox
boundBox_0 = boundBox_0.add(objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB"))####
try:
boundBox_1 = Gui.Selection.getSelectionEx()[1].SubObjects[0].BoundBox.Center # object 1 is subObject BBCenter
boundBox_1 = boundBox_1.add(objectRealPlacement3D(Gui.Selection.getSelection()[1],0,"BB"))#
except Exception:
self.RB_03_Subo_Subo.setChecked(True)
self.RB_03_Subo_Subo.setStyleSheet("background-color: #f57900 ")
FreeCAD.Console.PrintError("Bad selection or 1 object selected instead 2 in mode BBox Obj SObj"+"\n"
"mode changed to mode 3 BBox SObj. SObj. "+"\n")
#print("2")
if self.RB_03_Subo_Subo.isChecked(): # SObj SObj
boundBox_0 = Gui.Selection.getSelectionEx()[0].SubObjects[0].BoundBox.Center # object 1 is subObject BBCenter
boundBox_0 = boundBox_0.add(objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB"))#
#print("11")
try:
boundBox_1 = Gui.Selection.getSelectionEx()[0].SubObjects[1].BoundBox.Center # object 2 is subObject BBCenter
boundBox_1 = boundBox_1.add(objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB"))#
#print("12")
except Exception:
try:
boundBox_1 = Gui.Selection.getSelectionEx()[1].SubObjects[0].BoundBox.Center # object 2 is subObject BBCenter
boundBox_1 = boundBox_1.add(objectRealPlacement3D(Gui.Selection.getSelection()[1],0,"BB"))#
#print("13")
except Exception:
try:
originalPosition_01 = objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB")
originalPosition_02 = objectRealPlacement3D(Gui.Selection.getSelection()[0],0,"BB")
points = Gui.Selection.getSelectionEx()[0].SubObjects[0].Edges[0].discretize(3) # single object (Line)
boundBox_0 = originalPosition_01.add(points[0])
boundBox_1 = originalPosition_02.add(points[2])
#print("14")
except Exception:
App.Console.PrintMessage("Error selection SObj SObj" + "\n")#
self.label_Info.setText(_fromUtf8("Error selection SObj SObj"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
try:
points=[FreeCAD.Vector(boundBox_0),FreeCAD.Vector(boundBox_1)] # coordinates
self.ligne = Draft.makeWire(points,closed=False,face=False,support=None) # create line directrice
self.ligne.Label = "Line_Master"
App.Console.PrintMessage("Object 0 : " + str(boundBox_0) + "\n") # coordinates displayed
App.Console.PrintMessage("Object 1 : " + str(boundBox_1) + "\n") # coordinates displayed
self.label_Info.setText(_fromUtf8("Object 0 : " + str(boundBox_0) + " Object 1 : " + str(boundBox_1)))
try:
direction = boundBox_1.sub(boundBox_0)
App.Console.PrintMessage("Direction : " + str(direction) + "\n") # direction displayed
except Exception:
None
try:
App.Console.PrintMessage("Distance point to point : " + str(DraftVecUtils.dist(boundBox_0, boundBox_1)) + "\n")# length point to point
self.label_Info.setText(_fromUtf8("Distance point to point : " + str(DraftVecUtils.dist(boundBox_0, boundBox_1))))
except Exeption:
None
App.Console.PrintMessage("_______________________" + "\n")#
##### create Line
#self.PB_Del_Last_Line.setEnabled(True)
if self.RB_Line.isChecked():
if (self.Thickness != 0.0):
FreeCADGui.ActiveDocument.getObject(self.ligne.Name).LineWidth = self.Thickness
self.ligne.Label = "Line_Master_" + str(self.Thickness)
#self.PB_Del_Last_Line.setEnabled(False)
#self.PB_Del_Last_Line.setText(_fromUtf8("!"))
App.ActiveDocument.recompute()
else:
##### section camera view get origin
OriginOrientation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
##### section camera alignement to points
v=boundBox_1.sub(boundBox_0)
r=App.Rotation(App.Vector(0,0,1),v)
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)
##### create Placement
pl = ""
pl = FreeCAD.Placement()
pl.Rotation.Q = (r.Q[0],r.Q[1],r.Q[2],r.Q[3])
pl.Base = FreeCAD.Vector(boundBox_0[0],boundBox_0[1],boundBox_0[2])
##### create Polyline
if self.RB_Polyline.isChecked():
if self.Polyline_CirCon == 0: self.Polyline_CirCon = 1.0
if self.CB_Insc_Circon.isChecked():
self.Forme = Draft.makePolygon(self.Polyline_Number_Faces ,radius=self.Polyline_CirCon,inscribed=True,placement=pl,face=False,support=None) # Draft
else:
self.Forme = Draft.makePolygon(self.Polyline_Number_Faces ,radius=self.Polyline_CirCon,inscribed=False,placement=pl,face=False,support=None) # Draft
self.Forme.Placement = pl
##### tube a soustraire Polyline
if (self.Thickness != 0.0) and (self.Thickness < self.Polyline_CirCon):
if self.CB_Insc_Circon.isChecked():
self.FormeSubtract = Draft.makePolygon(self.Polyline_Number_Faces ,radius=(self.Polyline_CirCon-self.Thickness),inscribed=True,placement=pl,face=False,support=None) # Draft
else:
self.FormeSubtract = Draft.makePolygon(self.Polyline_Number_Faces ,radius=(self.Polyline_CirCon-self.Thickness),inscribed=False,placement=pl,face=False,support=None) # Draft
self.FormeSubtract.Placement = pl
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Polyline
self.PB_Del_Last_Line.setText(_fromUtf8("Del Polygon"))
##### create Rectangle
elif self.RB_Rectangle.isChecked():
XS = self.Rectangle_X-(self.Thickness * 2)
YS = self.Rectangle_Y-(self.Thickness * 2)
if self.RB_Center.isChecked():
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X/2),-(self.Rectangle_Y/2),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment and centrage
##### tube a soustraire Rectangle centre
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-((XS)/2),-((YS)/2),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle centre
elif self.RB_Top_Left.isChecked():
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector((0.0),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Left
##### tube a soustraire Rectangle Top_Left
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector((self.Thickness),-(self.Rectangle_Y-self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Top_Left
elif self.RB_Top_Rigth.isChecked():
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Rigth
##### tube a soustraire Rectangle Top_Rigth
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-(self.Rectangle_X-self.Thickness),-(self.Rectangle_Y-self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Top_Rigth
elif self.RB_Low_Left.isChecked():
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Left
##### tube a soustraire Rectangle Low_Left
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector((self.Thickness),(self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Low_Left
elif self.RB_Low_Rigth.isChecked():
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Rigth
##### tube a soustraire Rectangle Low_Rigth
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
XS = self.Rectangle_X-(self.Thickness * 2)
YS = self.Rectangle_Y-(self.Thickness * 2)
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-(self.Rectangle_X-self.Thickness),(self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Low_Rigth
elif self.RB_Center_Top.isChecked(): # center dessus poutrelle
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X/2.0),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Left
##### tube a soustraire Rectangle center dessus poutrelle
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-(self.Rectangle_X/2.0)+(self.Thickness),-((self.Rectangle_Y)-self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle center dessus poutrelle
elif self.RB_Center_Right.isChecked(): # Rectangle Center_Right
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),-(self.Rectangle_Y/2.0),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Rigth
##### tube a soustraire Rectangle Center_Rigth
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-(self.Rectangle_X-self.Thickness),-((self.Rectangle_Y/2.0)-self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Center_Rigth
elif self.RB_Center_Left.isChecked(): # Rectangle Center Left
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(0.0,-(self.Rectangle_Y/2.0),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Left
##### tube a soustraire Rectangle Center Left
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector((self.Thickness),-(self.Rectangle_Y/2.0)+(self.Thickness),(0.0)), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Center Left
elif self.RB_Center_Bottom.isChecked(): # Rectangle Center Bottom
self.Forme = Draft.makeRectangle(length=self.Rectangle_X,height=self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X/2.0),(0.0),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Rigth
##### tube a soustraire Rectangle Center Bottom
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
XS = self.Rectangle_X-(self.Thickness * 2)
YS = self.Rectangle_Y-(self.Thickness * 2)
self.FormeSubtract = Draft.makeRectangle(length=XS,height=YS,placement=App.Placement(App.Vector(-(self.Rectangle_X/2.0) + self.Thickness,(self.Thickness),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Rectangle Center Bottom
self.PB_Del_Last_Line.setText(_fromUtf8("Del Rectangle"))
##### create Ellipse
elif self.RB_Ellipse.isChecked():
if self.Rectangle_X == 0: self.Rectangle_X = 1.0
if self.Rectangle_Y == 0: self.Rectangle_Y = 1.0
XS = self.Rectangle_X-(self.Thickness )
YS = self.Rectangle_Y-(self.Thickness )
if self.RB_Center.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=pl,face=False,support=None)
self.Forme.Placement = pl # centrage
##### tube a soustraire Ellipse centre
if (self.Thickness != 0.0) and ((self.Thickness) < self.Rectangle_X) and ((self.Thickness) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=pl,face=False,support=None)
self.FormeSubtract.Placement.Rotation = App.Rotation(0.0,0.0,0.0)
self.FormeSubtract.Placement = pl
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse centre
elif self.RB_Top_Left.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector((self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Left
##### tube a soustraire Ellipse Top_Left
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector((self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Top_Left
elif self.RB_Top_Rigth.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Top_Rigth
##### tube a soustraire Ellipse Top_Rigth
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector(-(self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Top_Rigth
elif self.RB_Low_Left.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector((self.Rectangle_X),(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Left
##### tube a soustraire Ellipse Low_Left
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector((self.Rectangle_X),(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Low_Left
elif self.RB_Low_Rigth.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Low_Rigth
##### tube a soustraire Ellipse Low_Rigth
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector(-(self.Rectangle_X),(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Low_Rigth
elif self.RB_Center_Top.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector((self.Rectangle_X),-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(App.Placement(App.Vector(0.0,-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0,0,0))) # centrage Bord superieur
##### tube a soustraire Ellipse Top_Center
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector(0.0,-(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Top_Center
elif self.RB_Center_Bottom.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(App.Placement(App.Vector(0.0,(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0,0,0))) # centrage Bord superieur
##### tube a soustraire Ellipse Bas_Center
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector(0.0,(self.Rectangle_Y),0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Bas_Center
elif self.RB_Center_Left.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector((self.Rectangle_X),0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Left_Center
##### tube a soustraire Ellipse Left_Center
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector((self.Rectangle_X),0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Left_Center
elif self.RB_Center_Right.isChecked():
self.Forme = Draft.makeEllipse(self.Rectangle_X,self.Rectangle_Y,placement=App.Placement(App.Vector(-(self.Rectangle_X),0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.Forme.Placement = pl.multiply(self.Forme.Placement) # increment Rigth_Center
##### tube a soustraire Ellipse Rigth_Center
if (self.Thickness != 0.0) and ((self.Thickness*2) < self.Rectangle_X) and ((self.Thickness*2) < self.Rectangle_Y):
self.FormeSubtract = Draft.makeEllipse(XS,YS,placement=App.Placement(App.Vector(-(self.Rectangle_X),0.0,0.0), App.Rotation(0.0,0.0,0.0), App.Vector(0.0,0.0,0.0)),face=False,support=None)
self.FormeSubtract.Placement = pl.multiply(self.FormeSubtract.Placement)
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Ellipse Rigth_Center
self.PB_Del_Last_Line.setText(_fromUtf8("Del Ellipse"))
##### create Circle
elif self.RB_Circle.isChecked():
if self.Circle_Radius == 0: self.Circle_Radius = 1.0
self.Forme = Draft.makeCircle(radius=self.Circle_Radius,placement=pl,face=False,support=None)
self.Forme.Placement = pl
##### tube a soustraire Circle
if (self.Thickness != 0.0) and (self.Thickness < self.Circle_Radius):
self.Circle_Radius_Sbs = self.Circle_Radius - (self.Thickness)
self.FormeSubtract = Draft.makeCircle(radius=self.Circle_Radius_Sbs,placement=pl,face=False,support=None)
self.FormeSubtract.Placement = pl
else:
ff = ui
ff.colorThickness(1)
##### tube a soustraire Circle
self.PB_Del_Last_Line.setText(_fromUtf8("Del Circle"))
##### create sweep self.Forme externe to line
self.sweepForme = App.ActiveDocument.addObject('Part::Sweep','Sweep_Externe_')
self.sweepForme.Sections=[App.ActiveDocument.getObject(self.Forme.Name), ]
self.sweepForme.Spine=(App.ActiveDocument.getObject(self.ligne.Name))
if (self.CB_Solid.isChecked()) or (self.Thickness != 0.0):
self.sweepForme.Solid=True
else:
self.sweepForme.Solid=False
self.sweepForme.Frenet=True
##### create sweep self.FormeSubtract interne to line
if self.Thickness != 0.0:
self.sweepFormeS = App.ActiveDocument.addObject('Part::Sweep','Sweep_Substract_')
self.sweepFormeS.Sections=[App.ActiveDocument.getObject(self.FormeSubtract.Name), ]
self.sweepFormeS.Spine=(App.ActiveDocument.getObject(self.ligne.Name))
self.sweepFormeS.Solid=True
##### Contener
self.FcSweep = App.ActiveDocument.addObject("App::DocumentObjectGroup","FcSweep")
self.FcSweep.addObject(self.sweepForme)
self.FcSweep.addObject(self.ligne)
self.FcSweep.addObject(self.Forme)
##### tube soustraction
if self.Thickness != 0.0:
### cut object
self.cutFcSweep = App.activeDocument().addObject("Part::Cut","Pipe")
self.cutFcSweep.Base = self.sweepForme
self.cutFcSweep.Tool = self.sweepFormeS
self.cutFcSweep.Label = "Pipe"
self.FcSweep.addObject(self.sweepFormeS) # Contener
self.FcSweep.addObject(self.FormeSubtract)# Contener
self.FcSweep.addObject(self.cutFcSweep) # Contener
App.ActiveDocument.recompute()
##### tube soustraction
##### renamme ObjectGroup
if self.RB_Line.isChecked():
None
else:
if self.RB_Polyline.isChecked():
if self.CB_Insc_Circon.isChecked():
self.FcSweep.Label = "Polyline_r_=_" + str(self.Polyline_CirCon) + "_F_=_" + str(self.Polyline_Number_Faces)+ "_I"
if (self.Thickness != 0.0):
self.FcSweep.Label = "Pipe_Polyline_r_=_" + str(self.Polyline_CirCon) + "_F_=_" + str(self.Polyline_Number_Faces) + "_Th_=_" + str(self.Thickness) + "_I"
else:
self.FcSweep.Label = "Polyline_r_=_" + str(self.Polyline_CirCon) + "_F_=_" + str(self.Polyline_Number_Faces)+ "_C"
if (self.Thickness != 0.0):
self.FcSweep.Label = "Pipe_Polyline_r_=_" + str(self.Polyline_CirCon) + "_F_=_" + str(self.Polyline_Number_Faces) + "_Th_=_" + str(self.Thickness) + "_C"
elif self.RB_Rectangle.isChecked():
self.FcSweep.Label = "Rectangle_X_=_" + str(self.Rectangle_X) + "_Y_=_" + str(self.Rectangle_Y)
if (self.Thickness != 0.0):
self.FcSweep.Label = "Pipe_Rectangle_X_=_" + str(self.Rectangle_X) + "_Y_=_" + str(self.Rectangle_Y) + "_Th_=_" + str(self.Thickness)
None
elif self.RB_Ellipse.isChecked():
self.FcSweep.Label = "Ellipse_X_=_" + str(self.Rectangle_X) + "_Y_=_" + str(self.Rectangle_Y)
if (self.Thickness != 0.0):
self.FcSweep.Label = "Pipe_Ellipse_X_=_" + str(self.Rectangle_X) + "_Y_=_" + str(self.Rectangle_Y) + "_Th_=_" + str(self.Thickness)
None
elif self.RB_Circle.isChecked():
self.FcSweep.Label = "Circle_r_=_" + str(self.Circle_Radius)
if (self.Thickness != 0.0):
self.FcSweep.Label = "Pipe_Circle_r_=_" + str(self.Circle_Radius) + "_Th_=_" + str(self.Thickness)
##### renamme sweep
self.ligne.Label = "Line_Master_" + self.ligne.Name
self.Forme.Label = "Forme_" + self.Forme.Name
FreeCADGui.ActiveDocument.getObject(self.ligne.Name).Visibility = False
FreeCADGui.ActiveDocument.getObject(self.Forme.Name).Visibility = False
if (self.Thickness != 0.0):
self.FormeSubtract.Label = "Subtract_" + self.FormeSubtract.Name
FreeCADGui.ActiveDocument.getObject(self.FormeSubtract.Name).Visibility = False
App.Console.PrintMessage("Thickness : " + str(self.Thickness) + "\n")# Thickness
self.label_Info.setText(_fromUtf8("Thickness : " + str(self.Thickness)))
App.ActiveDocument.recompute()
App.Console.PrintMessage("_______________________" + "\n")#
##### section camera origin view restitute
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation(OriginOrientation)
if self.RB_Polyline.isChecked():
self.PB_Del_Last_Line.setText(_fromUtf8("Delete last Polyline"))
elif self.RB_Rectangle.isChecked():
self.PB_Del_Last_Line.setText(_fromUtf8("Delete last Rectangle"))
elif self.RB_Ellipse.isChecked():
self.PB_Del_Last_Line.setText(_fromUtf8("Delete last Ellipse"))
elif self.RB_Circle.isChecked():
self.PB_Del_Last_Line.setText(_fromUtf8("Delete last Circle"))
elif self.RB_Line.isChecked():
self.PB_Del_Last_Line.setText(_fromUtf8("Delete last Line"))
except Exception:
App.Console.PrintError(" Error Selection !!" + "\n")
self.label_Info.setText(_fromUtf8(" Error Selection !!"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
else:
App.Console.PrintError("Select two objects ("+str(len(Gui.Selection.getSelection()))+" object(s) selected)"+"\n")
App.Console.PrintError("or straight line, edge and mode 3:SObj. + SObj."+"\n")
App.Console.PrintError("_______________________________________________"+"\n")
self.label_Info.setText(_fromUtf8("Select one or two objects ("+str(len(Gui.Selection.getSelection()))+" object(s) selected)"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
except Exception:
App.Console.PrintError(" Error Selection !!!" + "\n")
self.label_Info.setText(_fromUtf8(" Error Selection !!!"))
self.label_Info.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300;}")
#####################################
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("Version",__version__ + " (" + __date__ + ")")#
MainWindow = QtWidgets.QMainWindow()
MainWindow.setObjectName("__title__") # macro internal Name
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
@smjaberl
Copy link

Hey, nice tool, but in Version 0.18 beta it thorws this error: "Select twoo objects (1 object(s) selected)."
I selected two objects like it works in version 0.17 it works.

@mario52a
Copy link
Author

Hi
this version correct the default: getselection() ... changed in new version FC 0.18 and more
see https://forum.freecadweb.org/viewtopic.php?p=299467#p315541
and upgrade now you can select 2 points or only the line, wire, edge

mario

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