Macro Connect And Sweep: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
m (link to Gist cause inappropriate indentation created)
Line 36: Line 36:
==Script== <!--T:5-->
==Script== <!--T:5-->
''' Macro_Connect_And_Sweep.FCMacro'''
''' Macro_Connect_And_Sweep.FCMacro'''
</translate>
<syntaxhighlight>


Download the macro to Gits [https://gist.github.com/mario52a/3ec67a3711202dab69592ce53b938924 ''' Macro_Connect_And_Sweep.FCMacro''']
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2016 <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. *
* *
* 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
# This macro is based to the microelly2 code see "http://forum.freecadweb.org/viewtopic.php?t=7029#p56746"
#
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.16.6700 (Git)
#Build type: Release
#Branch: releases/FreeCAD-0-16
#Hash: 7b925d11aa69ac405b423635adb1e2833f18a817
#Python version: 2.7.8
#Qt version: 4.8.6
#Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17
#
__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.03"
__date__ = "15/09/2016"


__Comment__ = "This macro connect 2 objects (boundingBox center) or one object (boundingBox center) and one point or twoo points selected"
__Help__ = "Start the macro select 2 objects choice the form and validate"

try:
import PyQt4
from PyQt4 import QtGui ,QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import *
except Exception:
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
App = FreeCAD

global ui ; ui = ""
global path
#path = FreeCAD.ConfigGet("AppHomePath")
#path = "YourPath"
path = FreeCAD.ConfigGet("UserAppData")

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)

def errorDialog(msg):
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg )
try:
diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 # cette fonction met la fenetre en avant
except Exception:
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide #cette fonction met la fenetre en avant
# diag.setWindowModality(QtCore.Qt.ApplicationModal) # la fonction a ete desactivee pour favoriser "WindowStaysOnTopHint"
diag.exec_()
class Ui_MainWindow(object):
global path

def __init__(self):
global 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.Thickness = 0.0
self.FcSweep = ""
self.FcSweepS = ""
self.Forme = ""
self.FormeSubtract = ""
self.cutFcSweep = ""

self.ligne = ""
self.sweepForme = ""

def setupUi(self, MainWindow):
self.window = MainWindow
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(332, 312)
MainWindow.setMinimumSize(QtCore.QSize(332, 312))
MainWindow.setMaximumSize(QtCore.QSize(332, 312))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))

self.fontGlobal_08 = QtGui.QFont() # pour compatibilite Windows Linux pour tous les textes
self.fontGlobal_08.setFamily("Arial") # pour compatibilite Windows Linux pour tous les textes
self.fontGlobal_08.setPointSize(8.0) # pour compatibilite Windows Linux pour tous les textes

self.PB_Quit = QtGui.QPushButton(self.centralwidget)
self.PB_Quit.setGeometry(QtCore.QRect(20, 278, 71, 23))
self.PB_Quit.setFont(self.fontGlobal_08) # pour compatibilite W L
self.PB_Quit.setToolTip(_fromUtf8("Quit Connect And Sweep"))
self.PB_Quit.setObjectName(_fromUtf8("PB_Quit"))
self.PB_Quit.clicked.connect(self.on_PB_Quit) ###

self.PB_Del_Last_Line = QtGui.QPushButton(self.centralwidget)
self.PB_Del_Last_Line.setGeometry(QtCore.QRect(100, 278, 71, 23))
self.PB_Del_Last_Line.setFont(self.fontGlobal_08) # pour compatibilite W L
self.PB_Del_Last_Line.setToolTip(_fromUtf8("If the last form is not in the right direction you can delete"))
self.PB_Del_Last_Line.setObjectName(_fromUtf8("PB_Del_Last_Line"))
self.PB_Del_Last_Line.clicked.connect(self.on_PB_Del_Last_Line) ###

self.PB_Create = QtGui.QPushButton(self.centralwidget)
self.PB_Create.setGeometry(QtCore.QRect(180, 278, 71, 23))
self.PB_Create.setFont(self.fontGlobal_08) # pour compatibilite W L
self.PB_Create.setToolTip(_fromUtf8("Create the sweep or line"))
self.PB_Create.setObjectName(_fromUtf8("PB_Create"))
self.PB_Create.clicked.connect(self.on_PB_Create) ###

self.CB_Solid = QtGui.QCheckBox(self.centralwidget)
self.CB_Solid.setGeometry(QtCore.QRect(260, 280, 51, 17))
self.CB_Solid.setFont(self.fontGlobal_08) # pour compatibilite W L
self.CB_Solid.setChecked(True)
self.CB_Solid.setText(_fromUtf8("Solid"))
self.CB_Solid.setToolTip(_fromUtf8("Create solid checked by default"+"\n"+"If is not checked then is tube empty"))
self.CB_Solid.setObjectName(_fromUtf8("CB_Solid"))
self.CB_Solid.clicked.connect(self.on_CB_Solid_clicked)

self.GBox_02_ = QtGui.QGroupBox(self.centralwidget)
self.GBox_02_.setGeometry(QtCore.QRect(20, 40, 291, 231))
self.GBox_02_.setFont(self.fontGlobal_08) # pour compatibilite W L
self.GBox_02_.setObjectName(_fromUtf8("GBox_02_"))

self.SB_Polyline_Number_Faces = QtGui.QSpinBox(self.GBox_02_)
self.SB_Polyline_Number_Faces.setGeometry(QtCore.QRect(190, 31, 91, 22))
self.SB_Polyline_Number_Faces.setFont(self.fontGlobal_08) # pour compatibilite W L
self.SB_Polyline_Number_Faces.setPrefix(_fromUtf8(""))
self.SB_Polyline_Number_Faces.setObjectName(_fromUtf8("SB_Polyline_Number_Faces"))
self.SB_Polyline_Number_Faces.setToolTip(_fromUtf8("Enter number faces"))
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.CB_Insc_Circon = QtGui.QCheckBox(self.GBox_02_)
self.CB_Insc_Circon.setGeometry(QtCore.QRect(90, 10, 131, 21))
self.CB_Insc_Circon.setFont(self.fontGlobal_08) # pour compatibilite W L
self.CB_Insc_Circon.setText(_fromUtf8("Polygon Circumscribed"))
self.CB_Insc_Circon.setToolTip(_fromUtf8("Circumscribed by default, if checked then Inscribed"))
self.CB_Insc_Circon.setObjectName(_fromUtf8("CB_Insc_Circon"))
self.CB_Insc_Circon.clicked.connect(self.on_CB_Insc_Circon_clicked)

self.DS_Polyline_CirCon = QtGui.QDoubleSpinBox(self.GBox_02_)
self.DS_Polyline_CirCon.setGeometry(QtCore.QRect(90, 31, 91, 22))
self.DS_Polyline_CirCon.setFont(self.fontGlobal_08) # pour compatibilite W L
self.DS_Polyline_CirCon.setObjectName(_fromUtf8("DS_Polyline_CirCon"))
self.DS_Polyline_CirCon.setToolTip(_fromUtf8("Radius polygon"))
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.DS_Circle_Radius = QtGui.QDoubleSpinBox(self.GBox_02_)
self.DS_Circle_Radius.setGeometry(QtCore.QRect(90, 121, 91, 22))
self.DS_Circle_Radius.setFont(self.fontGlobal_08) # pour compatibilite W L
self.DS_Circle_Radius.setObjectName(_fromUtf8("DS_Circle_Radius"))
self.DS_Circle_Radius.setToolTip(_fromUtf8("Radius of circle"))
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_Rectangle_X = QtGui.QDoubleSpinBox(self.GBox_02_)
self.DS_Rectangle_X.setGeometry(QtCore.QRect(90, 61, 91, 22))
self.DS_Rectangle_X.setFont(self.fontGlobal_08) # pour compatibilite W L
self.DS_Rectangle_X.setObjectName(_fromUtf8("DS_Rectangle_X"))
self.DS_Rectangle_X.setToolTip(_fromUtf8("Rectangle Length"))
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 = QtGui.QDoubleSpinBox(self.GBox_02_)
self.DS_Rectangle_Y.setGeometry(QtCore.QRect(191, 61, 91, 22))
self.DS_Rectangle_X.setFont(self.fontGlobal_08) # pour compatibilite W L
self.DS_Rectangle_Y.setObjectName(_fromUtf8("DS_Rectangle_Y"))
self.DS_Rectangle_Y.setToolTip(_fromUtf8("Rectangle Height"))
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_Polyline = QtGui.QRadioButton(self.GBox_02_)
self.RB_Polyline.setGeometry(QtCore.QRect(20, 31, 71, 17))
self.RB_Polyline.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Polyline.setChecked(True)
self.RB_Polyline.setObjectName(_fromUtf8("RB_Polyline"))
self.RB_Polyline.clicked.connect(self.on_RB_Polyline_clicked)

self.RB_Rectangle = QtGui.QRadioButton(self.GBox_02_)
self.RB_Rectangle.setGeometry(QtCore.QRect(20, 61, 71, 17))
self.RB_Rectangle.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Rectangle.setObjectName(_fromUtf8("RB_Rectangle"))
self.RB_Rectangle.clicked.connect(self.on_RB_Rectangle_clicked)

self.RB_Ellipse = QtGui.QRadioButton(self.GBox_02_)
self.RB_Ellipse.setGeometry(QtCore.QRect(20, 91, 61, 17))
self.RB_Ellipse.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Ellipse.setObjectName(_fromUtf8("RB_Ellipse"))
self.RB_Ellipse.clicked.connect(self.on_RB_Ellipse_clicked)

self.RB_Circle = QtGui.QRadioButton(self.GBox_02_)
self.RB_Circle.setGeometry(QtCore.QRect(20, 121, 61, 17))
self.RB_Circle.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Circle.setObjectName(_fromUtf8("RB_Circle"))
self.RB_Circle.clicked.connect(self.on_RB_Circle_clicked)

self.RB_Line = QtGui.QRadioButton(self.GBox_02_)
self.RB_Line.setGeometry(QtCore.QRect(20, 151, 61, 17))
self.RB_Line.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Line.setObjectName(_fromUtf8("RB_Line"))
self.RB_Line.clicked.connect(self.on_RB_Line_clicked)

self.label_Pipe = QtGui.QLabel(self.GBox_02_)
self.label_Pipe.setGeometry(QtCore.QRect(40, 200, 181, 21))
self.label_Pipe.setFont(self.fontGlobal_08) # pour compatibilite W L
self.label_Pipe.setObjectName(_fromUtf8("label_Pipe"))

self.DS_Pipe = QtGui.QDoubleSpinBox(self.GBox_02_)
self.DS_Pipe.setGeometry(QtCore.QRect(90, 200, 191, 22))
self.DS_Pipe.setFont(self.fontGlobal_08) # pour compatibilite W L
self.DS_Pipe.setObjectName(_fromUtf8("DS_Pipe"))
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.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) ###

self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(20, 15, 181, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName(_fromUtf8("label"))

self.groupBox = QtGui.QGroupBox(self.GBox_02_)
self.groupBox.setVisible(False)
self.groupBox.setGeometry(QtCore.QRect(90, 116, 191, 76))
self.groupBox.setFont(self.fontGlobal_08) # pour compatibilite W L
self.groupBox.setObjectName(_fromUtf8("groupBox"))

self.graphicsView = QtGui.QGraphicsView(self.groupBox)
self.graphicsView.setGeometry(QtCore.QRect(100, 14, 81, 51))
self.graphicsView.setFont(self.fontGlobal_08) # pour compatibilite W L
self.graphicsView.setObjectName(_fromUtf8("graphicsView"))
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_CE.png")
self.scene = QtGui.QGraphicsScene()
self.scene.addPixmap(QtGui.QPixmap(pic))
self.graphicsView.setScene(ui.scene)

self.RB_Top_Left = QtGui.QRadioButton(self.groupBox)
self.RB_Top_Left.setGeometry(QtCore.QRect(10, 14, 31, 17))
self.RB_Top_Left.setFont(self.fontGlobal_08) # pour compatibilite W L
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_Top_Left.setObjectName(_fromUtf8("RB_Top_Left"))
self.RB_Top_Left.clicked.connect(self.on_RB_Image_clicked)

self.RB_Top_Rigth = QtGui.QRadioButton(self.groupBox)
self.RB_Top_Rigth.setGeometry(QtCore.QRect(50, 14, 31, 17))
self.RB_Top_Rigth.setFont(self.fontGlobal_08) # pour compatibilite W L
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_Top_Rigth.setObjectName(_fromUtf8("RB_Top_Rigth"))
self.RB_Top_Rigth.clicked.connect(self.on_RB_Image_clicked)

self.RB_Low_Left = QtGui.QRadioButton(self.groupBox)
self.RB_Low_Left.setGeometry(QtCore.QRect(10, 53, 41, 17))
self.RB_Low_Left.setFont(self.fontGlobal_08) # pour compatibilite W L
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_Low_Left.setObjectName(_fromUtf8("RB_Low_Left"))
self.RB_Low_Left.clicked.connect(self.on_RB_Image_clicked)

self.RB_Low_Rigth = QtGui.QRadioButton(self.groupBox)
self.RB_Low_Rigth.setGeometry(QtCore.QRect(50, 53, 31, 17))
self.RB_Low_Left.setFont(self.fontGlobal_08) # pour compatibilite W L
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_Low_Rigth.setObjectName(_fromUtf8("RB_Low_Rigth"))
self.RB_Low_Rigth.clicked.connect(self.on_RB_Image_clicked)

self.RB_Center = QtGui.QRadioButton(self.groupBox)
self.RB_Center.setGeometry(QtCore.QRect(30, 34, 61, 17))
self.RB_Center.setFont(self.fontGlobal_08) # pour compatibilite W L
self.RB_Center.setToolTip(_fromUtf8("The selected point is in the center of forme"))
self.RB_Center.setChecked(True)
self.RB_Center.setObjectName(_fromUtf8("RB_Center"))
self.RB_Center.clicked.connect(self.on_RB_Image_clicked)

MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_fromUtf8("Macro Connect And Sweep"))
MainWindow.setWindowIcon(QtGui.QIcon(path+'Macro_Connect_And_Sweep.png')) # change l'icone de la fenetre principale
try:
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenetre en avant
except Exception:
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenetre en avant
self.PB_Quit.setText(_fromUtf8("Quit"))
self.PB_Del_Last_Line.setText(_fromUtf8("Del Last Line"))
self.PB_Create.setText(_fromUtf8("Create Solid"))
self.GBox_02_.setTitle(_fromUtf8("Sweep Forme"))
self.SB_Polyline_Number_Faces.setSuffix(_fromUtf8(" num"))
self.DS_Circle_Radius.setSuffix(_fromUtf8(" r mm"))
self.RB_Circle.setText(_fromUtf8("Circle"))
self.DS_Polyline_CirCon.setSuffix(_fromUtf8(" Cir mm"))
self.RB_Polyline.setText(_fromUtf8("Polygone"))
self.RB_Line.setText(_fromUtf8("Line"))
self.RB_Rectangle.setText(_fromUtf8("Rectangle"))
self.RB_Ellipse.setText(_fromUtf8("Ellipse"))
self.DS_Rectangle_X.setSuffix(_fromUtf8(" L mm"))
self.DS_Rectangle_Y.setSuffix(_fromUtf8(" H mm"))
self.label.setText(_fromUtf8("Connect And Sweep"))
self.label_Pipe.setText(_fromUtf8("Pipe"))
self.DS_Pipe.setSuffix(_fromUtf8(" mm Thickness"))
self.groupBox.setTitle(_fromUtf8("Corner point position"))
self.RB_Top_Left.setText(_fromUtf8("TL"))
self.RB_Top_Rigth.setText(_fromUtf8("TR"))
self.RB_Low_Left.setText(_fromUtf8("LL"))
self.RB_Low_Rigth.setText(_fromUtf8("LR"))
self.RB_Center.setText(_fromUtf8("Center"))

def colorThickness(self,value): # 0= couleur de Base , 1= couleur rouge (ici)
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")
############### 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_SB_Polyline_Number_Faces(self,value):
self.Polyline_Number_Faces = value

def on_DS_Circle_Radius(self,value):
self.Circle_Radius = value

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(_fromUtf8("Create Pipe"))
else:
self.CB_Solid.setChecked(True)
self.PB_Create.setText(_fromUtf8("Create Solid"))
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):
if self.CB_Solid.isChecked():
self.PB_Create.setText("Create Solid")
else:
self.PB_Create.setText("Create Empty")
if self.Thickness != 0.0:
self.CB_Solid.setChecked(True)
self.PB_Create.setText("Create Solid")

def on_RB_Polyline_clicked(self):
if self.RB_Polyline.isChecked():
self.groupBox.setVisible(False)
self.DS_Circle_Radius.setVisible(True)

def on_RB_Rectangle_clicked(self):
self.DS_Rectangle_X.setGeometry(QtCore.QRect(90, 61, 91, 22))
self.DS_Rectangle_Y.setGeometry(QtCore.QRect(191, 61, 91, 22))
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.groupBox.setGeometry(QtCore.QRect(90, 86, 191, 76))
self.groupBox.setVisible(True)
self.DS_Circle_Radius.setVisible(False)

def on_RB_Ellipse_clicked(self):
self.DS_Rectangle_X.setGeometry(QtCore.QRect(90, 91, 91, 22))
self.DS_Rectangle_Y.setGeometry(QtCore.QRect(191, 91, 91, 22))
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.groupBox.setGeometry(QtCore.QRect(90, 116, 191, 76))
self.groupBox.setVisible(True)
self.DS_Circle_Radius.setVisible(False)

def on_RB_Image_clicked(self):
if self.RB_Top_Left.isChecked():
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_TL.png")
elif self.RB_Top_Rigth.isChecked():
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_TR.png")
elif self.RB_Low_Left.isChecked():
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_LL.png")
elif self.RB_Low_Rigth.isChecked():
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_LR.png")
elif self.RB_Center.isChecked():
pic = QtGui.QPixmap(path+"Macro_Connect_And_Sweep_CE.png")
self.scene = QtGui.QGraphicsScene()
self.scene.addPixmap(QtGui.QPixmap(pic))
self.graphicsView.setScene(ui.scene)
def on_RB_Circle_clicked(self):
if self.RB_Circle.isChecked():
self.groupBox.setVisible(False)
self.DS_Circle_Radius.setVisible(True)

def on_RB_Line_clicked(self):
if self.RB_Line.isChecked():
self.groupBox.setVisible(False)
self.DS_Circle_Radius.setVisible(True)

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
try:
FreeCAD.ActiveDocument.getObject(self.FcSweep.Name).removeObjectsFromDocument()
FreeCAD.ActiveDocument.removeObject(self.FcSweep.Name)
except Exception:
None

def on_PB_Create(self): # Create
if len(Gui.Selection.getSelection()) >= 2:
try: # Section Object 1 ###
boundBox_0 = Gui.Selection.getSelectionEx()[0].SubObjects[0].Point # Object 1 is SubObject 1
except Exception:
boundBox_0= Gui.Selection.getSelection()[0].Shape.BoundBox.Center # Object 1 is Object

try: # Section Object 2 ###
boundBox_1 = Gui.Selection.getSelectionEx()[1].SubObjects[0].Point # Object 2 is SubObject other object
except Exception:
try:
boundBox_1 = Gui.Selection.getSelectionEx()[0].SubObjects[1].Point # Object 2 is SubObject 2
except Exception:
boundBox_1= Gui.Selection.getSelection()[1].Shape.BoundBox.Center # Object 2 is Object
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(str(boundBox_0)+" : " + str(boundBox_1) + "\n") # coordinates displayed
App.Console.PrintMessage("Length point to point : " + str(self.ligne.Length) + "\n")# line length

##### create Line
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)
None
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

##### 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

##### 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.multiply(self.FormeSubtract.Placement)
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

##### 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
##### 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

App.ActiveDocument.recompute()

App.Console.PrintMessage("_______________________" + "\n")#
##### section camera origin view restitute
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation(OriginOrientation)

else:
App.Console.PrintError("Select twoo objects ("+str(len(Gui.Selection.getSelection()))+" object(s) selected)"+"\n")
# App.Console.PrintMessage(str("on_PB_Create")+"\n")


MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()


</syntaxhighlight>
<translate>
==Example== <!--T:15-->
==Example== <!--T:15-->
Path and tubing with Macro_Connect_And_Sweep and [http://www.freecadweb.org/wiki/index.php?title=Macro_Repro_Wire Macro_Repro_Wire] [[File:Macro_ReproWire.png|32px]]
Path and tubing with Macro_Connect_And_Sweep and [http://www.freecadweb.org/wiki/index.php?title=Macro_Repro_Wire Macro_Repro_Wire] [[File:Macro_ReproWire.png|32px]]

Revision as of 10:57, 21 September 2016

File:Macro Connect And Sweep Macro Connect And Sweep

Description
This macro easily creates a connection between two objects.

Macro version: 00.03 (15/09/2016)
Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
00.03 (15/09/2016)
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

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

Macro_Connect_And_Sweep
Macro_Connect_And_Sweep

Use

Run the macro select your objects or points choice the form and parameters and click Create.

Macro_Connect_And_Sweep
Macro_Connect_And_Sweep

Images

These files must be copied to your macros directory

(For download : Click Right button op the image and click "Save Image as ...")

Center Top left Top rigth Low left Low rigth

The icon for the toolbar Icon for the button

Script

Macro_Connect_And_Sweep.FCMacro

Download the macro to Gits Macro_Connect_And_Sweep.FCMacro

Example

Path and tubing with Macro_Connect_And_Sweep and Macro_Repro_Wire


Version

00.03 15/09/2016 : add create pipe

00.02 13/06/2016 : add options choice angle path rectangle and ellipse

00.01 07/06/2016 : add option solid or not centring rectangle or not

00.00 05/06/2016 :

Links

The forum discussion Scripting point to point tubing

This macro is based to the microelly2 code see Looking for some helpful GUI-commands

Other languages: