FreeCAD-Doc/localwiki/Macro_Compound_Plus-it.html
2018-07-19 18:47:02 -05:00

824 lines
43 KiB
HTML

<html><head><title>Macro Compound Plus/it</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Compound Plus/it</h1></div>
<div id="mw-content-text" lang="it" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
<tr>
<td class="ctTitle">
<h3><span class="mw-headline" id="Composto_Plus"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Compound_Plus.png" class="image"><img alt="Macro Compound Plus.png" src="32px-Macro_Compound_Plus.png" width="32" height="32" srcset="/wiki/images/thumb/f/fd/Macro_Compound_Plus.png/48px-Macro_Compound_Plus.png 1.5x, Macro_Compound_Plus.png 2x" /></a> Composto Plus</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Descrizione
</th></tr>
<tr>
<td class="ctEven left">Utilità che combina diversi comandi di Draft.
</td></tr>
<tr>
<th class="ctOdd">Autore
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
</td></tr>
<tr>
<th class="ctOdd">Link
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
</td></tr>
<tr>
<th class="ctOdd">Versione
</th></tr>
<tr>
<td class="ctEven macro-version">00.02
</td></tr>
<tr>
<th class="ctOdd">Data ultima modifica
</th></tr>
<tr>
<td class="ctEven macro-date">2018-01-24
</td></tr>
<tr>
<th class="ctOdd">
</th></tr>
<tr>
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Composto_Plus"><span class="tocnumber">1</span> <span class="toctext">Composto Plus</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Descrizione"><span class="tocnumber">2</span> <span class="toctext">Descrizione</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Uso"><span class="tocnumber">3</span> <span class="toctext">Uso</span></a></li>
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
<li class="toclevel-1 tocsection-4"><a href="#Link"><span class="tocnumber">5</span> <span class="toctext">Link</span></a></li>
<li class="toclevel-1 tocsection-5"><a href="#Versioni"><span class="tocnumber">6</span> <span class="toctext">Versioni</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p>
<h2><span class="mw-headline" id="Descrizione">Descrizione</span></h2>
<p>Macro utility che riunisce numerosi comandi di Draft per lavorare con gli oggetti 2D. Ad esempio, lavorare con gli oggetti dei file DXF.
</p>
<h2><span class="mw-headline" id="Uso">Uso</span></h2>
<p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Compound_Plus_00.png" class="image" title="Macro_Compound_Plus_00"><img alt="Macro_Compound_Plus_00" src="Macro_Compound_Plus_00.png" width="254" height="474" /></a>
</p>
<ul><li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Compound I</span> Type I [1 + 1 = 1]&#160;: Crea un composto unico di tutti gli oggetti selezionati, senza lo storico.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Compound II</span> Type II [1 + 1 = A (1 + 1)]&#160;: Crea un composto di tutti gli oggetti selezionati con lo storico di tutti gli oggetti. Stessa funzione di "<b>Menu &gt; Part &gt; Crea composto</b>".</li>
<li>Opzioni per le linee:
<ul><li> Line colour&#160;: Assegna un colore agli oggetti.</li>
<li> Width line&#160;: Assegna uno spessore di linea.</li></ul></li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;"> Convert (A)</span> = Converte i testi <a href="https://www.freecadweb.org/wiki/index.php?title=File:Draft_Text.png" class="image"><img alt="Draft Text.png" src="Draft_Text.png" width="64" height="64" /></a> in forme <a href="https://www.freecadweb.org/wiki/index.php?title=File:Draft_ShapeString.png" class="image"><img alt="Draft ShapeString.png" src="Draft_ShapeString.png" width="64" height="64" /></a> (Lo spessore del testo convertito è rispettato, ma il risultato visivo può non essere rispettato, vedere le proprietà della Vista Combinata per conferma)</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;"> 8.00 </span>&#160;: Gives a thickness of the character and font Family.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Convert Edge</span>&#160;: Questo comando converte una polilinea in una linea con le coordinate. (Es: un composto declassato non ha le coordinate, questa funzione crea una linea con le coordinate)</li>
<li>Per Compound I e Convert Edge</li></ul>
<p>Questa sezione lavora solo con i menu <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Compound I</span>, <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Convert (A)</span> e <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Convert Edge</span>
</p>
<ul><li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">None</span>&#160;: Tutti gli oggetti originali restano così come sono.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Hidden original line(s)</span>&#160;: Nasconde le linee originali.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Delete original line(s)</span>&#160;: Elimina le linee originali.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Reset</span>&#160;: Reset della macro</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">DownGrade</span>&#160;: Declassa gli oggetti, allo stesso modo di <a href="https://www.freecadweb.org/wiki/index.php?title=File:Draft_Downgrade.png" class="image"><img alt="Draft Downgrade.png" src="Draft_Downgrade.png" width="64" height="64" /></a>.</li>
<li><span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Quit</span>&#160;: Esce dalla macro</li></ul>
<h2><span class="mw-headline" id="Script">Script</span></h2>
<p>L'icona per la barra degli strumenti <a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Compound_Plus.png" class="image"><img alt="Macro Compound Plus.png" src="Macro_Compound_Plus.png" width="64" height="64" /></a> da copiare nella stessa cartella della macro
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Come personalizzare la barra degli strumenti</a>, <a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le macro</a>
</p><p>Lo script in github <a rel="nofollow" class="external text" href="https://gist.github.com/mario52a/7be361a8c489deec918f664fdcfc4394">Macro_Compound_Plus.FCMacro</a>
<br /><br />Macro_Compound_Plus.FCMacro<br />
</p>
<pre># -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2016 2017 2018 &lt;mario52&gt; *
* *
* 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_Compound_Plus 05/08/2016 /_00 24/01/2018
#
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.16.6706 (Git)
#Build type: Release
#Branch: releases/FreeCAD-0-16
#Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
#Python version: 2.7.8
#Qt version: 4.8.7
#Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17
#
__title__ = "Macro_Compound_Plus"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02"
__date__ = "24/01/2018"
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD
from math import sqrt, pi, sin, cos, asin
from FreeCAD import Base
App = FreeCAD
doc = App.activeDocument()
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 )
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_()
import os, sys, platform
global PolicePath
global nomPolice
####### detect platform meme dans reset ###################
if platform.system() == "Windows"&#160;:
PolicePath = "C:/Windows/Fonts/ARIAL.TTF"
elif platform.system() == "Linux"&#160;:
PolicePath = "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-M.ttf"
elif platform.system() == "Darwin":
PolicePath = "/Library/Fonts/Arial.ttf"
else:
PolicePath = "C:/Windows/Fonts/ARIAL.TTF"
nomPolice = os.path.basename(PolicePath).split('.')[0]
class Ui_Compound(object):
def __init__(self):
#self.path = "Your Path"
#self.path = FreeCAD.ConfigGet("AppHomePath")
self.path = FreeCAD.ConfigGet("UserAppData")
self.nameL = []
self.comP = []
del self.nameL[:]
del self.comP[:]
self.red = 255.0
self.green = 0.0
self.blue = 0.0
self.lineWidth = 2.0
self.font = ""
self.TextLabel = ""
self.TextLabelText = ""
self.TextPosition = ""
self.TextFontSize = 8.0
self.TextTextColor = ""
self.FontSize = 8.0
self.fonte = ""
self.fontGlobal_08 = "" # pour compatibilite Windows Linux pour tous les textes
self.manuel = False
global PolicePath
global nomPolice
# self.pathFont = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.FontsLocation) # path font search
# self.fonteComp = self.pathFont + "/" + self.nomPolice + ".TTF"
# self.fonteComp = self.fonteComp.replace("\\","/")
def setupUi(self, MainWindow):
global PolicePath
global nomPolice
self.window = MainWindow
Compound.setObjectName(_fromUtf8("Compound"))
Compound.resize(250, 440)
MainWindow.setMinimumSize(QtCore.QSize(250, 440))
MainWindow.setMaximumSize(QtCore.QSize(250, 440))
self.centralwidget = QtGui.QWidget(Compound)
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_01_Compound_01 = QtGui.QPushButton(self.centralwidget)
self.PB_01_Compound_01.setGeometry(QtCore.QRect(10, 40, 75, 23))
self.PB_01_Compound_01.setFont(self.fontGlobal_08)
self.PB_01_Compound_01.setToolTip("Make a compound Block unique")
self.PB_01_Compound_01.setObjectName(_fromUtf8("PB_01_Compound_01"))
self.PB_01_Compound_01.clicked.connect(self.on_PB_01_Compound_01) #
self.PB_02_Compound_02 = QtGui.QPushButton(self.centralwidget)
self.PB_02_Compound_02.setGeometry(QtCore.QRect(10, 70, 75, 23))
self.PB_02_Compound_02.setFont(self.fontGlobal_08)
self.PB_02_Compound_02.setToolTip("Make a compound same Part, Menu &gt; Part &gt; Make compound")
self.PB_02_Compound_02.setObjectName(_fromUtf8("PB_02_Compound_02"))
self.PB_02_Compound_02.clicked.connect(self.on_PB_02_Compound_02) #
self.groupBox_00 = QtGui.QGroupBox(self.centralwidget)
self.groupBox_00.setGeometry(QtCore.QRect(10, 100, 231, 91))
self.groupBox_00.setAlignment(Qt.AlignLeft) # AlignLeft AlignCenter AlignRight
self.groupBox_00.setFont(self.fontGlobal_08)
self.groupBox_00.setToolTip("If this box is unchecked the colors attributes and width line\n"
"of the original line(s) are not modified\n"
"This chekBox work only with Compound II\n"
"Same attributes Part, Menu &gt; Part &gt; Make compound")
self.groupBox_00.setCheckable(True)
self.groupBox_00.setObjectName(_fromUtf8("groupBox_00"))
self.PB_03_Color = QtGui.QPushButton(self.groupBox_00)
self.PB_03_Color.setGeometry(QtCore.QRect(10, 30, 75, 23))
self.PB_03_Color.setFont(self.fontGlobal_08)
self.PB_03_Color.setToolTip("Change the color of object(s) selected(s) value by defaut rvb 255,0,0")
self.PB_03_Color.setObjectName(_fromUtf8("PB_03_Color"))
self.PB_03_Color.clicked.connect(self.on_PB_03_Color) #
self.PB_03_Color.setStyleSheet("background-color: rgb("+str(self.red)+","+str(self.green)+","+str(self.blue)+"); color: cmj("+str(255)+","+str(255)+","+str(255)+")")
self.DS_01_Width = QtGui.QDoubleSpinBox(self.groupBox_00)
self.DS_01_Width.setGeometry(QtCore.QRect(10, 60, 73, 22))
self.DS_01_Width.setFont(self.fontGlobal_08)
self.DS_01_Width.setToolTip("Give a new width for the line(s) selected(s)")
self.DS_01_Width.setObjectName(_fromUtf8("DS_01_Width"))
self.DS_01_Width.setValue(self.lineWidth)
self.DS_01_Width.valueChanged.connect(self.on_DS_01_Width_valueChanged) #
self.PB_04_Convert = QtGui.QPushButton(self.centralwidget)
self.PB_04_Convert.setGeometry(QtCore.QRect(10, 200, 75, 23))
self.PB_04_Convert.setFont(self.fontGlobal_08)
self.PB_04_Convert.setToolTip("Convert the selected text in ShapeString\n"
"By default Convert (A)utomatic use the font preselected and the size of original text\n"
"If the values or font is modified the button change of Convert (M)anual\n"
"The label of the texte are modified to SString_original text (max 30 characters)")
self.PB_04_Convert.setObjectName(_fromUtf8("PB_04_Convert"))
self.PB_04_Convert.clicked.connect(self.on_PB_04_Convert) # ""
if platform.system() == "Windows"&#160;:
self.fontComboBox = QtGui.QFontComboBox(self.centralwidget)
self.fontComboBox.setGeometry(QtCore.QRect(100, 225, 141, 35))
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
# self.fontComboBox.setFont(self.fontGlobal_08)
self.fontComboBox.setCurrentFont(font)
self.fontComboBox.setToolTip("New font.\nActual&#160;: "+nomPolice)
self.fontComboBox.setObjectName(_fromUtf8("fontComboBox"))
self.fontComboBox.currentFontChanged.connect(self.on_PB_Fonte_Win01) #
self.DS_02_Width_Font = QtGui.QDoubleSpinBox(self.centralwidget)
self.DS_02_Width_Font.setGeometry(QtCore.QRect(10, 230, 73, 22))
self.DS_02_Width_Font.setFont(self.fontGlobal_08)
self.DS_02_Width_Font.setToolTip("Give a new width for the font")
self.DS_02_Width_Font.setObjectName(_fromUtf8("DS_02_Width_Font"))
self.DS_02_Width_Font.setValue(self.FontSize)
self.DS_02_Width_Font.valueChanged.connect(self.on_DS_02_Width_Font_valueChanged) #
else: # Linux +
import os.path
nomPolice = os.path.basename(PolicePath).split('.')[0]
self.PB_Fonte_Linux = QtGui.QPushButton(self.centralwidget)
self.PB_Fonte_Linux.setGeometry(QtCore.QRect(100, 225, 141, 35))
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.PB_Fonte_Linux.setFont(font)
self.PB_Fonte_Linux.setToolTip(_fromUtf8("New font.\nActual&#160;: "+nomPolice))
self.PB_Fonte_Linux.setAccessibleDescription(_fromUtf8(""))
self.PB_Fonte_Linux.setText(_fromUtf8(nomPolice))
self.PB_Fonte_Linux.setObjectName(_fromUtf8("PB_Fonte_Linux"))
self.PB_Fonte_Linux.clicked.connect(self.on_PB_Fonte_Linux)
self.DS_02_Width_Font = QtGui.QDoubleSpinBox(self.centralwidget)
self.DS_02_Width_Font.setGeometry(QtCore.QRect(10, 230, 75, 23))
self.DS_02_Width_Font.setFont(self.fontGlobal_08)
self.DS_02_Width_Font.setToolTip("Give a new width for the font")
self.DS_02_Width_Font.setObjectName(_fromUtf8("DS_02_Width_Font"))
self.DS_02_Width_Font.setValue(self.FontSize)
self.DS_02_Width_Font.valueChanged.connect(self.on_DS_02_Width_Font_valueChanged) #
self.PB_04c_Convert_Edge = QtGui.QPushButton(self.centralwidget)
self.PB_04c_Convert_Edge.setGeometry(QtCore.QRect(10, 260, 75, 23))
self.PB_04c_Convert_Edge.setFont(self.fontGlobal_08)
self.PB_04c_Convert_Edge.setToolTip("Convert the edge to line with coordinates\n"
"Select the edge(s) in the 3D view")
self.PB_04c_Convert_Edge.setObjectName(_fromUtf8("PB_04c_Convert_Edge"))
self.PB_04c_Convert_Edge.clicked.connect(self.on_PB_04c_Convert_Edge) # ""
self.PB_05_Reset = QtGui.QPushButton(self.centralwidget)
self.PB_05_Reset.setGeometry(QtCore.QRect(10, 410, 75, 23))
self.PB_05_Reset.setFont(self.fontGlobal_08)
self.PB_05_Reset.setToolTip("Reset the values")
self.PB_05_Reset.setObjectName(_fromUtf8("PB_05_Reset"))
self.PB_05_Reset.clicked.connect(self.on_PB_05_Reset) #
self.PB_06_Downgrade = QtGui.QPushButton(self.centralwidget)
self.PB_06_Downgrade.setGeometry(QtCore.QRect(90, 410, 75, 23))
self.PB_06_Downgrade.setFont(self.fontGlobal_08)
self.PB_06_Downgrade.setToolTip("Downgrade the selected object Same Draft &gt; Downgrade")
self.PB_06_Downgrade.setObjectName(_fromUtf8("PB_06_Downgrade"))
self.PB_06_Downgrade.clicked.connect(self.on_PB_06_Downgrade) #
self.PB_07_Quit = QtGui.QPushButton(self.centralwidget)
self.PB_07_Quit.setGeometry(QtCore.QRect(170, 410, 75, 23))
self.PB_07_Quit.setFont(self.fontGlobal_08)
self.PB_07_Quit.setToolTip("Quit Compound +")
self.PB_07_Quit.setObjectName(_fromUtf8("PB_06_Quit"))
self.PB_07_Quit.clicked.connect(self.on_PB_07_Quit) #
self.label_01_Titre = QtGui.QLabel(self.centralwidget)
self.label_01_Titre.setGeometry(QtCore.QRect(10, 10, 231, 16))
fontTitle = QtGui.QFont()
fontTitle.setPointSize(12)
self.label_01_Titre.setFont(fontTitle)
self.label_01_Titre.setObjectName(_fromUtf8("label_01_Titre"))
self.label_02_Type_1 = QtGui.QLabel(self.centralwidget)
self.label_02_Type_1.setGeometry(QtCore.QRect(100, 40, 111, 16))
self.label_02_Type_1.setFont(self.fontGlobal_08)
self.label_02_Type_1.setObjectName(_fromUtf8("label_02_Type_1"))
self.label_03_Type_2 = QtGui.QLabel(self.centralwidget)
self.label_03_Type_2.setGeometry(QtCore.QRect(100, 70, 141, 16))
self.label_03_Type_2.setFont(self.fontGlobal_08)
self.label_03_Type_2.setObjectName(_fromUtf8("label_03_Type_2"))
self.label_04_Color = QtGui.QLabel(self.groupBox_00)
self.label_04_Color.setGeometry(QtCore.QRect(100, 30, 121, 16))
self.label_04_Color.setFont(self.fontGlobal_08)
self.label_04_Color.setObjectName(_fromUtf8("label_04_Color"))
self.label_05_DSBox = QtGui.QLabel(self.groupBox_00)
self.label_05_DSBox.setGeometry(QtCore.QRect(100, 60, 121, 16))
self.label_05_DSBox.setFont(self.fontGlobal_08)
self.label_05_DSBox.setObjectName(_fromUtf8("label_05_DSBox"))
self.label_06_Convert = QtGui.QLabel(self.centralwidget)
self.label_06_Convert.setGeometry(QtCore.QRect(100, 200, 141, 16))
self.label_06_Convert.setFont(self.fontGlobal_08)
self.label_06_Convert.setObjectName(_fromUtf8("label_06_Convert"))
self.label_08_Convert_Line = QtGui.QLabel(self.centralwidget)
self.label_08_Convert_Line.setGeometry(QtCore.QRect(100, 260, 141, 16))
self.label_08_Convert_Line.setFont(self.fontGlobal_08)
self.label_08_Convert_Line.setObjectName(_fromUtf8("label_08_Convert_Line"))
self.groupBox_01 = QtGui.QGroupBox(self.centralwidget)
self.groupBox_01.setGeometry(QtCore.QRect(10, 290, 231, 81))
self.groupBox_01.setFont(self.fontGlobal_08)
self.groupBox_01.setObjectName(_fromUtf8("groupBox_01"))
self.RB_01_Default = QtGui.QRadioButton(self.groupBox_01)
self.RB_01_Default.setGeometry(QtCore.QRect(10, 20, 141, 17))
self.RB_01_Default.setFont(self.fontGlobal_08)
self.RB_01_Default.setToolTip("The line stay tel quel\n"
"For Compound I and Convert text to String")
self.RB_01_Default.setChecked(True)
self.RB_01_Default.setObjectName(_fromUtf8("RB_01_Default"))
self.RB_02_Hidden = QtGui.QRadioButton(self.groupBox_01)
self.RB_02_Hidden.setGeometry(QtCore.QRect(10, 40, 141, 17))
self.RB_02_Hidden.setFont(self.fontGlobal_08)
self.RB_02_Hidden.setToolTip("The original line are hidden after transform\n"
"For Compound I and Convert text to String")
self.RB_02_Hidden.setObjectName(_fromUtf8("RB_02_Hidden"))
self.RB_03_Delete = QtGui.QRadioButton(self.groupBox_01)
self.RB_03_Delete.setGeometry(QtCore.QRect(10, 60, 141, 17))
self.RB_03_Delete.setFont(self.fontGlobal_08)
self.RB_03_Delete.setToolTip("The original line are deleted after transform\n"
"For Compound I and Convert text to String")
# self.RB_03_Delete.setChecked(True)
self.RB_03_Delete.setObjectName(_fromUtf8("RB_03_Delete"))
self.progressBar = QtGui.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(10, 380, 231, 20))
self.progressBar.setFont(self.fontGlobal_08)
self.progressBar.setValue(0)
self.progressBar.setAlignment(QtCore.Qt.AlignCenter)
self.progressBar.setObjectName(_fromUtf8("progressBar"))
Compound.setCentralWidget(self.centralwidget)
self.retranslateUi(Compound)
QtCore.QMetaObject.connectSlotsByName(Compound)
def retranslateUi(self, Compound):
Compound.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenetre en avant
Compound.setWindowIcon(QtGui.QIcon(self.path + 'Macro_Compound_Plus.png')) # change l'icone de la fenetre principale
Compound.setWindowTitle("Compound +")
self.PB_01_Compound_01.setText("Compound I")
self.PB_02_Compound_02.setText("Compound II")
self.groupBox_00.setTitle("Options lines")
self.PB_03_Color.setText("Color")
self.PB_04_Convert.setText("Convert (A)")
self.PB_04c_Convert_Edge.setText("Convert Edge")
self.label_01_Titre.setText("Compound +")
self.label_02_Type_1.setText("Type I [ 1 + 1 = 1 ]")
self.label_03_Type_2.setText("Type II [ 1 + 1 = A (1 + 1) ]")
self.label_04_Color.setText("Line color")
self.label_05_DSBox.setText("Width line")
self.label_06_Convert.setText("Convert Text to String")
self.label_08_Convert_Line.setText("Convert Edge to Line")
self.groupBox_01.setTitle("For Compound I and Convert")
self.RB_01_Default.setText("None")
self.RB_02_Hidden.setText("Hidden original line(s) ")
self.RB_03_Delete.setText("Delete original line(s)")
self.PB_05_Reset.setText("Reset")
self.PB_06_Downgrade.setText("DownGrade")
self.PB_07_Quit.setText("Quit")
def on_PB_01_Compound_01(self):
self.selectionObjects = FreeCADGui.Selection.getSelection()
if len(self.selectionObjects) &gt; 0:
try:
self.nameL = []
self.comP = []
del self.nameL[:]
del self.comP[:]
self.progressBar.setMaximum(len(self.selectionObjects))
compteur = 0
for i in self.selectionObjects:
self.nameL.append(i.Name)
self.comP.append(i.Shape)
compteur += 1
self.progressBar.setValue(compteur)
Gui.updateGui()
print "Object&#160;: ",i.Name
comp = Part.makeCompound(self.comP)
Part.show(comp)
if self.groupBox_00.isChecked:
FreeCADGui.ActiveDocument.ActiveObject.LineWidth = self.lineWidth
FreeCADGui.ActiveDocument.ActiveObject.LineColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.ShapeColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.PointColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
App.ActiveDocument.ActiveObject.Label = "reproShape_TI"
if self.RB_01_Default.isChecked():
None
if self.RB_02_Hidden.isChecked():
for i in range(len(self.nameL)):
print "Hidden&#160;: ",self.nameL[i]
FreeCADGui.ActiveDocument.getObject(self.nameL[i]).Visibility = False
if self.RB_03_Delete.isChecked():
for i in range(len(self.nameL)):
print "Delete&#160;: ",self.nameL[i]
doc.removeObject(self.nameL[i])
self.progressBar.setValue(0)
except Exception:
FreeCAD.Console.PrintError("Error objects "+"\n")
else:
FreeCAD.Console.PrintError("Not objects selected "+"\n")
# FreeCAD.Console.PrintMessage(str("on_PB_01_Compound_01 ")+"\n")
def on_PB_02_Compound_02(self):
self.selectionObjects = FreeCADGui.Selection.getSelection()
if len(self.selectionObjects) &gt; 0:
try:
self.nameL = []
self.comP = []
del self.nameL[:]
del self.comP[:]
App.activeDocument().addObject("Part::Compound","Compound")
self.progressBar.setMaximum(len(self.selectionObjects))
compteur = 0
for i in self.selectionObjects:
self.nameL.append(App.ActiveDocument.getObject(i.Name))
compteur += 1
self.progressBar.setValue(compteur)
Gui.updateGui()
print i.Name
self.progressBar.setValue(0)
App.activeDocument().Compound.Links = self.nameL
App.activeDocument().recompute()
if self.groupBox_00.isChecked:
FreeCADGui.ActiveDocument.ActiveObject.LineWidth = self.lineWidth
FreeCADGui.ActiveDocument.ActiveObject.LineColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.ShapeColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.PointColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
App.ActiveDocument.ActiveObject.Label = "reproShape_TII"
except Exception:
FreeCAD.Console.PrintError("Error objects "+"\n")
else:
FreeCAD.Console.PrintError("Not objects selected "+"\n")
# FreeCAD.Console.PrintMessage(str("on_PB_02_Compound_02 ")+"\n")
def on_PB_03_Color(self):
self.PB_03_Color.setStyleSheet("background-color: QPalette.Base") # origin system
self.window.hide() # hide the window open color
couleur = QtGui.QColorDialog.getColor()
if couleur.isValid():
self.red = int(str(couleur.name()[1:3]),16)
self.green = int(str(couleur.name()[3:5]),16)
self.blue = int(str(couleur.name()[5:7]),16)
self.PB_03_Color.setStyleSheet("background-color: rgb("+str(self.red)+","+str(self.green)+","+str(self.blue)+"); color: cmj("+str(255)+","+str(255)+","+str(255)+")")
self.window.show() # show the window and close color
# FreeCAD.Console.PrintMessage(str("PB_03_Color ")+"\n")
def on_PB_04_Convert(self):
global PolicePath
global nomPolice
self.selectionObjects = FreeCADGui.Selection.getSelection()
self.progressBar.setMaximum(len(self.selectionObjects))
compteur = 0
if len(self.selectionObjects) &gt; 0:
objA = self.selectionObjects[0]
for objA in self.selectionObjects:
try:
self.TextLabel = objA.Label
self.TextLabelText = objA.LabelText[0]
self.TextPosition = objA.Position
self.TextFontSize = objA.ViewObject.FontSize
if self.manuel:
self.TextFontSize = self.FontSize
self.TextTextColor = objA.ViewObject.TextColor
texte = unicode(self.TextLabelText)
ss=Draft.makeShapeString(String = texte, FontFile=PolicePath, Size=float(self.TextFontSize), Tracking=0)
plm=FreeCAD.Placement()
plm.Base=self.TextPosition
plm.Rotation.Q=(0.0,-0.0,-0.0,1.0)
ss.Placement=plm
ss.Support=None
ss.Label = "SString_"+texte[:30]
FreeCADGui.ActiveDocument.getObject(ss.Name).ShapeColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.getObject(ss.Name).LineColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.getObject(ss.Name).PointColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
compteur += 1
self.progressBar.setValue(compteur)
if self.RB_01_Default.isChecked():
None
if self.RB_02_Hidden.isChecked():
print "Hidden&#160;: ",objA.Name
FreeCADGui.ActiveDocument.getObject(objA.Name).Visibility = False
if self.RB_03_Delete.isChecked():
print "Delete&#160;: ",objA.Name
doc.removeObject(objA.Name)
Gui.updateGui()
except Exception:
FreeCAD.Console.PrintError("Not object TEXT or error" + "\n")
self.progressBar.setValue(0)
FreeCAD.ActiveDocument.recompute()
else:
FreeCAD.Console.PrintError("Select one or more objects TEXT" + "\n")
# FreeCAD.Console.PrintMessage(str("on_PB_04_Convert ")+"\n")
def on_PB_Fonte_Win01(self): # New Font Windows (menu deroulant) fonctionne ok
global PolicePath
global nomPolice
Compound.hide()
fonte = self.fontComboBox.currentFont()
nomPolice = fonte.rawName()
self.fontComboBox.setToolTip("New font.\nActual&#160;: "+nomPolice)
pathFont = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.FontsLocation) # path font search bon pour Windows
fonteComp = pathFont + "/" + nomPolice + ".TTF"
PolicePath = fonteComp.replace("\\","/")
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.fontComboBox.setFont(font)
self.PB_04_Convert.setText("Convert (M)")
self.manuel = True
Compound.show()
# App.Console.PrintMessage("New Font " + (PolicePath)+"\n")
def on_DS_02_Width_Font_valueChanged(self,value):
self.FontSize = value
self.PB_04_Convert.setText("Convert (M)")
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
if platform.system() == "Windows"&#160;:
self.fontComboBox.setFont(font)
else:
self.PB_Fonte_Linux.setFont(font)
self.PB_Fonte_Linux.setText(_fromUtf8(nomPolice))
self.manuel = True
# App.Console.PrintMessage("New FontSize " + str(self.FontSize)+"\n")
def on_PB_Fonte_Win02(self): # New Font Windows (menu avec fenetres)
global PolicePath
global nomPolice
Compound.hide()
font, ok = QtGui.QFontDialog.getFont(QFont(nomPolice, self.FontSize))
if ok:
fonte = font
nomPolice = fonte.rawName()
self.FontSize = fonte.pointSizeF()
pathFont = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.FontsLocation) # path font search bon pour Windows
fonteComp = pathFont + "/" + nomPolice + ".TTF"
PolicePath = fonteComp.replace("\\","/")
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.label_07_Font.setFont(font)
self.label_07_Font.setText("Actual (" + str(self.FontSize) + ") " + nomPolice)
self.label_07_Font.setToolTip("Actual (" + str(self.FontSize) + ") " + nomPolice)
self.PB_04_Convert.setText("Convert (M)")
self.manuel = True
Compound.show()
def on_PB_Fonte_Linux(self): # New Font Linux
global PolicePath
global nomPolice
Compound.hide()
OpenName = ""
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "New Font", PolicePath, "*.ttf") #PySide
try:
if OpenName&#160;!= "":
PolicePath = str(OpenName)
import os.path
nomPolice = os.path.basename(PolicePath).split('.')[0]
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.PB_Fonte_Linux.setText(nomPolice)
self.PB_Fonte_Linux.setFont(font)
self.PB_Fonte_Linux.setToolTip(_fromUtf8("New font.\nActual&#160;: "+nomPolice))
except Exception:
None
Compound.show()
# App.Console.PrintMessage("New Font " + (PolicePath)+"\n")
def on_PB_04c_Convert_Edge(self): # Convert Edge to line
import Draft
points = []
points[:] = []
selectionObjects = FreeCADGui.Selection.getSelectionEx() # Select an object or sub object getSelectionEx
for selection in selectionObjects:
for selectedEdge in selection.SubObjects:
if (str(selectedEdge.Curve)[1:5]) == "Line"&#160;:
numberCut = 1 # line
else:
numberCut = 20 # not line cut in 20 parts
points = selectedEdge.Edges[0].discretize(int(numberCut + 1)) # Dicretize
for lin in range(len(points)-1):
creaLine = [FreeCAD.Vector(points[lin]),FreeCAD.Vector(points[lin+1])]
wire = Draft.makeLine(FreeCAD.Vector(creaLine[0]),FreeCAD.Vector(creaLine[1]))
if self.groupBox_00.isChecked:
FreeCADGui.ActiveDocument.ActiveObject.LineWidth = self.lineWidth
FreeCADGui.ActiveDocument.ActiveObject.LineColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.ShapeColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
FreeCADGui.ActiveDocument.ActiveObject.PointColor = (float(self.red)/255, float(self.green)/255, float(self.blue)/255)
points[:] = []
FreeCAD.ActiveDocument.recompute()
# FreeCAD.Console.PrintMessage(str("on_PB_04c_Convert_Edge")+"\n")
def on_DS_01_Width_valueChanged(self,LineWidth):
self.lineWidth = LineWidth
# FreeCAD.Console.PrintMessage(str("on_DS_01_Width_valueChanged ")+str(self.lineWidth)+"\n")
def on_PB_05_Reset(self): #
global PolicePath
global nomPolice
self.red = 255.0
self.green = 0.0
self.blue = 0.0
self.PB_03_Color.setStyleSheet("background-color: rgb("+str(self.red)+","+str(self.green)+","+str(self.blue)+"); color: cmj("+str(255)+","+str(255)+","+str(255)+")")
# self.RB_01_Default.setChecked(True)
self.RB_03_Delete.setChecked(True)
self.lineWidth = 2.0
self.DS_01_Width.setValue(self.lineWidth)
self.FontSize = 8.0
if platform.system() == "Windows"&#160;:
PolicePath = "C:/Windows/Fonts/ARIAL.TTF"
nomPolice = os.path.basename(PolicePath).split('.')[0]
self.DS_02_Width_Font.setValue(self.FontSize)
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.fontComboBox.setCurrentFont(font)
else:
if platform.system() == "Linux"&#160;:
PolicePath = "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-M.ttf"
elif platform.system() == "Darwin":
PolicePath = "/Library/Fonts/Arial.ttf"
else:
PolicePath = FreeCAD.ConfigGet("AppHomePath")
self.PB_Fonte_Linux.setText("New Font")
nomPolice = os.path.basename(PolicePath).split('.')[0]
font = QtGui.QFont()
font.setFamily(nomPolice)
font.setPointSize(self.FontSize)
self.PB_Fonte_Linux.setFont(font)
self.PB_Fonte_Linux.setText(nomPolice)
self.PB_Fonte_Linux.setToolTip(_fromUtf8("New font.\nActual&#160;: "+nomPolice))
self.DS_02_Width_Font.setValue(self.FontSize)
self.manuel = False
self.PB_04_Convert.setText("Convert (A)")
self.fonte = PolicePath + "/" + nomPolice + ".TTF"
# FreeCAD.Console.PrintMessage(str("on_PB_05_Reset ")+"\n")
def on_PB_06_Downgrade(self): #
try:
import Draft
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True)
FreeCAD.ActiveDocument.recompute()
print
except Exception:
None
# FreeCAD.Console.PrintMessage(str("on_PB_06_Downgrade ")+"\n")
def on_PB_07_Quit(self): #
FreeCAD.Console.PrintMessage("End Compound +"+"\n")
self.window.hide()
# FreeCAD.Console.PrintMessage(str("on_PB_06_Quit ")+"\n")
Compound = QtGui.QMainWindow()
ui = Ui_Compound()
ui.setupUi(Compound)
Compound.show() </pre>
<h2><span class="mw-headline" id="Link">Link</span></h2>
<p>Le mie macro su <a rel="nofollow" class="external text" href="https://gist.github.com/mario52a">Github</a>
</p>
<h2><span class="mw-headline" id="Versioni">Versioni</span></h2>
<ul><li>24/01/2018 ver 00.02&#160;: sup "import PyQt4"</li>
<li>21/11/2016 ver 00.01&#160;:</li></ul>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Compound_Plus/it&amp;oldid=254308">http://www.freecadweb.org/wiki/index.php?title=Macro_Compound_Plus/it&amp;oldid=254308</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>