401 lines
19 KiB
HTML
401 lines
19 KiB
HTML
<html><head><title>Macro PropertyMemo/fr</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 PropertyMemo/fr</h1></div>
|
|
|
|
<div id="mw-content-text" lang="fr" 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="Macro_PropertyMemo"><a href="https://www.freecadweb.org/wiki/index.php?title=File:PropertyMemo.png" class="image"><img alt="PropertyMemo.png" src="32px-PropertyMemo.png" width="32" height="32" srcset="PropertyMemo.png 1.5x" /></a> Macro_PropertyMemo</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Description
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">Cette petite macro vous permet d'ajouter une Propriété (mémo ou autre texte) à un objet Draft.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Auteur
|
|
</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">Liens
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/fr" title="Macros recipes/fr">Recettes macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/fr" title="How to install macros/fr">Comment installer une macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/fr" title="Customize Toolbars/fr">Comment ajouter une barre d'outils</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">00.02
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Date dernière modification
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2015-10-19
|
|
</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="#Macro_PropertyMemo"><span class="tocnumber">1</span> <span class="toctext">Macro_PropertyMemo</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">2</span> <span class="toctext">Description</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Utilisation"><span class="tocnumber">3</span> <span class="toctext">Utilisation</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="#Liens"><span class="tocnumber">5</span> <span class="toctext">Liens</span></a></li>
|
|
<li class="toclevel-1 tocsection-5"><a href="#Version"><span class="tocnumber">6</span> <span class="toctext">Version</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Description">Description</span></h2>
|
|
<p>Cette petite macro vous permet d'ajouter une Propriété (mémo ou autre texte) à un objet Draft (pour le moment uniquement sur objet Draft)
|
|
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_FCPropertyMemo_00.png" class="image" title="Ajoute une propriété Memo > Name"><img alt="Ajoute une propriété Memo > Name" src="Macro_FCPropertyMemo_00.png" width="258" height="197" /></a>
|
|
</p>
|
|
<h2><span class="mw-headline" id="Utilisation">Utilisation</span></h2>
|
|
<p>Lancez la macro sélectionnez un objet Draft complétez les champs et appliquez la modification. Une nouvelle propriété est créée dans la Vue combinée <b>Vue combinée > Property > Data tab</b>
|
|
</p>
|
|
<ul><li><b>Property title</b> = Titre de la nouvelle propriété (Defaut: Memo)</li>
|
|
<li><b>Property name</b> = nom de la nouvelle propriété</li></ul>
|
|
<div class="floatleft"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_FCPropertyMemo_01.png" class="image" title="Une propriété Memo est créée"><img alt="Une propriété Memo est créée" src="Macro_FCPropertyMemo_01.png" width="373" height="430" /></a></div>
|
|
<ul><li> <b>Memo</b> : Titre de la propriété ici Memo (par défaut)</li>
|
|
<li> <b>Name</b> : Nom de la propriété ici, Name</li>
|
|
<li> Le champ libre nouvellement créé est à compléter manuellement</li></ul>
|
|
<div style="clear:both"></div>
|
|
<p>Le checkBox vous donne le choix entre deux options. Si le checkBox est activé, vous avez la possibilité de créer une liste de mémos que vous pouvez modifier dans une fenêtre si non le mémo sera affiché dans une ligne (option par défaut)
|
|
</p>
|
|
<center>
|
|
<ul class="gallery mw-gallery-traditional">
|
|
<li class="gallerybox" style="width: 435px"><div style="width: 435px">
|
|
<div class="thumb" style="width: 430px;"><div style="margin:15px auto;"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_FCPropertyMemo_02.png" class="image"><img alt="" src="190px-Macro_FCPropertyMemo_02.png" width="190" height="200" srcset="/wiki/images/thumb/5/57/Macro_FCPropertyMemo_02.png/284px-Macro_FCPropertyMemo_02.png 1.5x, /wiki/images/thumb/5/57/Macro_FCPropertyMemo_02.png/379px-Macro_FCPropertyMemo_02.png 2x" /></a></div></div>
|
|
<div class="gallerytext">
|
|
<p>Property Mémo liste.
|
|
</p>
|
|
</div>
|
|
</div></li>
|
|
<li class="gallerybox" style="width: 435px"><div style="width: 435px">
|
|
<div class="thumb" style="width: 430px;"><div style="margin:15px auto;"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_FCPropertyMemo_03.png" class="image"><img alt="" src="204px-Macro_FCPropertyMemo_03.png" width="204" height="200" srcset="/wiki/images/e/eb/Macro_FCPropertyMemo_03.png 1.5x" /></a></div></div>
|
|
<div class="gallerytext">
|
|
<p>La fenêtre Mémo liste.
|
|
</p>
|
|
</div>
|
|
</div></li>
|
|
</ul>
|
|
</center>
|
|
<div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<p><b>Macro_FCPropertyMemo.FCMacro</b>
|
|
</p><p>L'icône disponible pour votre barre d'outils <a href="https://www.freecadweb.org/wiki/index.php?title=File:PropertyMemo.png" class="image"><img alt="PropertyMemo.png" src="PropertyMemo.png" width="48" height="48" /></a>
|
|
</p>
|
|
<pre># -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
"""
|
|
***************************************************************************
|
|
* Copyright (c) 2015 <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_FCMemo 28/09/2015 /19/10/2015
|
|
#
|
|
|
|
#OS: Windows 8
|
|
#Word size of OS: 64-bit
|
|
#Word size of FreeCAD: 64-bit
|
|
#Version: 0.15.4671 (Git)
|
|
#Branch: releases/FreeCAD-0-15
|
|
#Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
|
|
#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_FCPropertyMemo"
|
|
__author__ = "Mario52"
|
|
__url__ = "http://www.freecadweb.org/index-fr.html"
|
|
__version__ = "00.02"
|
|
__date__ = "19/10/2015"
|
|
|
|
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, FreeCAD
|
|
|
|
global path
|
|
#path = FreeCAD.ConfigGet("AppHomePath")
|
|
path = FreeCAD.ConfigGet("UserAppData")
|
|
|
|
global title_01 ; title_01 = "Memo" # title of menu
|
|
global title_02 ; title_02 = "" # title of propriety
|
|
global memo_01  ; memo_01 = "" # memo
|
|
global forString; forString = 0 # memo for String or List
|
|
|
|
try:
|
|
_fromUtf8 = QtCore.QString.fromUtf8
|
|
except AttributeError:
|
|
def _fromUtf8(s):
|
|
return s
|
|
|
|
try:
|
|
_encoding = QtGui.QApplication.UnicodeUTF8
|
|
def _translate(context, text, disambig):
|
|
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
|
except AttributeError:
|
|
def _translate(context, text, disambig):
|
|
return QtGui.QApplication.translate(context, text, disambig)
|
|
|
|
class Ui_MainWindow(object):
|
|
|
|
def setupUi(self, MainWindow):
|
|
self.window = MainWindow
|
|
global path
|
|
global title_01
|
|
global title_02
|
|
global memo_01
|
|
|
|
MainWindow.setObjectName(_fromUtf8("MainWindow"))
|
|
MainWindow.resize(254, 163)
|
|
# MainWindow.resize(241, 211)
|
|
MainWindow.setMinimumSize(QtCore.QSize(254, 163))
|
|
MainWindow.setMaximumSize(QtCore.QSize(254, 163))
|
|
self.centralwidget = QtGui.QWidget(MainWindow)
|
|
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
|
|
|
|
self.PB_Button_01 = QtGui.QPushButton(self.centralwidget)
|
|
self.PB_Button_01.setGeometry(QtCore.QRect(20, 130, 61, 23))
|
|
# self.PB_Button_01.setGeometry(QtCore.QRect(20, 180, 61, 23))
|
|
self.PB_Button_01.setObjectName(_fromUtf8("PB_Button_01"))
|
|
self.PB_Button_01.clicked.connect(self.on_PB_Button_01_clicked) #
|
|
|
|
self.PB_Button_02 = QtGui.QPushButton(self.centralwidget)
|
|
self.PB_Button_02.setGeometry(QtCore.QRect(95, 130, 61, 23))
|
|
# self.PB_Button_02.setGeometry(QtCore.QRect(90, 180, 61, 23))
|
|
self.PB_Button_02.setObjectName(_fromUtf8("PB_Button_02"))
|
|
self.PB_Button_02.clicked.connect(self.on_PB_Button_02_clicked) #
|
|
|
|
self.PB_Button_03 = QtGui.QPushButton(self.centralwidget)
|
|
self.PB_Button_03.setGeometry(QtCore.QRect(170, 130, 61, 23))
|
|
# self.PB_Button_03.setGeometry(QtCore.QRect(160, 180, 61, 23))
|
|
self.PB_Button_03.setObjectName(_fromUtf8("PB_Button_03"))
|
|
self.PB_Button_03.clicked.connect(self.on_PB_Button_03_clicked) #
|
|
|
|
self.LE_Edit_01 = QtGui.QLineEdit(self.centralwidget) # title
|
|
self.LE_Edit_01.setGeometry(QtCore.QRect(20, 50, 211, 20))
|
|
# self.LE_Edit_01.setGeometry(QtCore.QRect(20, 50, 201, 20))
|
|
self.LE_Edit_01.setObjectName(_fromUtf8("LE_Edit_01"))
|
|
self.LE_Edit_01.setText(_fromUtf8(title_01))
|
|
self.LE_Edit_01.setToolTip("Title of menu property")
|
|
self.LE_Edit_01.textChanged.connect(self.on_LE_Edit_01_Pressed) # title property
|
|
|
|
self.LE_Edit_02 = QtGui.QLineEdit(self.centralwidget)
|
|
self.LE_Edit_02.setGeometry(QtCore.QRect(20, 100, 211, 20))
|
|
# self.LE_Edit_02.setGeometry(QtCore.QRect(20, 100, 201, 20))
|
|
self.LE_Edit_02.setObjectName(_fromUtf8("LE_Edit_02"))
|
|
self.LE_Edit_02.setText(_fromUtf8(""))
|
|
self.LE_Edit_02.setToolTip("Title of property")
|
|
self.LE_Edit_02.textChanged.connect(self.on_LE_Edit_02_Pressed) #
|
|
|
|
# self.LE_Edit_03 = QtGui.QLineEdit(self.centralwidget) # memo
|
|
# self.LE_Edit_03.setGeometry(QtCore.QRect(20, 150, 201, 20))
|
|
# self.LE_Edit_03.setObjectName(_fromUtf8("LE_Edit_03"))
|
|
# self.LE_Edit_03.setText(_fromUtf8(""))
|
|
# self.LE_Edit_03.setToolTip("Text memo for property")
|
|
# self.LE_Edit_03.textChanged.connect(self.on_LE_Edit_03_Pressed) #
|
|
|
|
MainWindow.setCentralWidget(self.centralwidget)
|
|
|
|
self.label_00 = QtGui.QLabel(self.centralwidget)
|
|
self.label_00.setGeometry(QtCore.QRect(70, 10, 120, 21))
|
|
font = QtGui.QFont()
|
|
font.setPointSize(10)
|
|
font.setBold(True)
|
|
font.setUnderline(True)
|
|
font.setWeight(75)
|
|
self.label_00.setFont(font)
|
|
self.label_00.setObjectName(_fromUtf8("label_00"))
|
|
|
|
self.label_01 = QtGui.QLabel(self.centralwidget)
|
|
self.label_01.setGeometry(QtCore.QRect(20, 30, 111, 16))
|
|
self.label_01.setObjectName(_fromUtf8("label_01"))
|
|
|
|
self.label_02 = QtGui.QLabel(self.centralwidget)
|
|
self.label_02.setGeometry(QtCore.QRect(20, 80, 111, 16))
|
|
self.label_02.setObjectName(_fromUtf8("label_02"))
|
|
|
|
# self.label_03 = QtGui.QLabel(self.centralwidget)
|
|
# self.label_03.setGeometry(QtCore.QRect(20, 130, 121, 16))
|
|
# self.label_03.setObjectName(_fromUtf8("label_03"))
|
|
|
|
self.CB_String = QtGui.QCheckBox(self.centralwidget) # for String or List
|
|
# self.CB_String.setGeometry(QtCore.QRect(130, 130, 91, 20))
|
|
self.CB_String.setGeometry(QtCore.QRect(120, 80, 120, 20))
|
|
self.CB_String.setObjectName(_fromUtf8("CB_String"))
|
|
self.CB_String.setToolTip("The memo is a string by default"+"\n"+"If the checkBox is checked the memo is a list in one window"+"\n"+"Clic the '...' in ComboView > Data")
|
|
self.CB_String.clicked.connect(self.on_CB_String_clicked) # connect on def "on_checkBox_1_clicked"
|
|
|
|
self.retranslateUi(MainWindow)
|
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
|
|
|
def retranslateUi(self, MainWindow):
|
|
try:
|
|
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant
|
|
except Exception:
|
|
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant
|
|
MainWindow.setWindowTitle("FCPropertyMemo")
|
|
self.PB_Button_01.setText("Reset")
|
|
self.PB_Button_01.setToolTip("Reset the TextEdit")
|
|
self.PB_Button_02.setText("Validate")
|
|
self.PB_Button_02.setToolTip("Validate and apply")
|
|
self.PB_Button_03.setText("Quit")
|
|
|
|
self.PB_Button_03.setToolTip("Quit the FCPropertyMemo")
|
|
self.label_00.setText("FCPropertyMemo")
|
|
self.label_01.setText("Property title")
|
|
self.label_02.setText("Property name")
|
|
# self.label_03.setText("Memo")
|
|
self.CB_String.setText("Chek for List")
|
|
|
|
def on_LE_Edit_01_Pressed(self): # Line edit 01 title
|
|
global title_01
|
|
title_01 = self.LE_Edit_01.text()
|
|
# App.Console.PrintMessage(title_01+"\n")
|
|
|
|
def on_LE_Edit_02_Pressed(self): # Line edit 02 title property
|
|
global title_02
|
|
title_02 = self.LE_Edit_02.text()
|
|
# App.Console.PrintMessage(title_02+"\n")
|
|
|
|
# def on_LE_Edit_03_Pressed(self): # Line edit 03 memo
|
|
# global memo_01
|
|
# memo_01 = self.LE_Edit_03.text()
|
|
# App.Console.PrintMessage(memo_01+"\n")
|
|
|
|
def on_CB_String_clicked(self): # connection on_checkBox_1_clicked
|
|
global forString
|
|
if self.CB_String.isChecked(): # if checkbox_01 is checked then ....
|
|
forString = 1
|
|
self.CB_String.setText("UnCheck for String")
|
|
else :
|
|
forString = 0
|
|
self.CB_String.setText("Check for List")
|
|
# App.Console.PrintMessage("on_CB_String_clicked "+str(forString)+"\n")
|
|
|
|
def on_PB_Button_01_clicked(self): # Button Reset
|
|
global title_01
|
|
global title_02
|
|
global memo_01
|
|
global forString
|
|
self.LE_Edit_01.clear()
|
|
title_01 = "Memo"
|
|
self.LE_Edit_01.setText(_fromUtf8(title_01))
|
|
self.LE_Edit_02.clear()
|
|
title_02 = ""
|
|
# self.LE_Edit_03.clear()
|
|
# memo_01 = ""
|
|
self.CB_String.setChecked(False) # Check by default True or False
|
|
self.CB_String.setText("Check for List")
|
|
forString = 0
|
|
# App.Console.PrintMessage("on_PB_Button_01_clicked\n")
|
|
|
|
def on_PB_Button_02_clicked(self): # Button Validate
|
|
global title_01
|
|
global title_02
|
|
global memo_01
|
|
global forString
|
|
try:
|
|
obj = FreeCADGui.Selection.getSelection()[0]
|
|
obj = App.ActiveDocument.ActiveObject
|
|
op = obj.PropertiesList
|
|
pas = 0
|
|
if (title_02 != ""):
|
|
for p in op:
|
|
if str(p) == title_02:
|
|
App.Console.PrintWarning("This Property is already present"+"\n")
|
|
pas = 0
|
|
break
|
|
else :
|
|
pas = 1
|
|
if pas == 1:
|
|
if forString == 0 :
|
|
a = obj.addProperty("App::PropertyString",title_02,title_01,"_Memo") # create a memo string
|
|
else :
|
|
a = obj.addProperty("App::PropertyStringList",title_02,title_01,"_Memo") # Create a list in window
|
|
Gui.Selection.clearSelection(obj.Name)
|
|
Gui.Selection.addSelection(obj)
|
|
App.activeDocument().recompute()
|
|
ff = ui # Reset
|
|
ff.on_PB_Button_01_clicked() # Reset
|
|
else:
|
|
App.Console.PrintMessage("Field empty"+"\n")
|
|
|
|
except Exception:
|
|
App.Console.PrintWarning("Object not selected or not Draft object"+"\n")
|
|
|
|
# App.Console.PrintMessage("on_PB_Button_02_clicked\n")
|
|
|
|
def on_PB_Button_03_clicked(self): # Button Quit
|
|
App.Console.PrintMessage("End FCPropertyMemo"+"\n\n")
|
|
self.window.hide()
|
|
|
|
MainWindow = QtGui.QMainWindow()
|
|
ui = Ui_MainWindow()
|
|
ui.setupUi(MainWindow)
|
|
MainWindow.show() </pre>
|
|
<h2><span class="mw-headline" id="Liens">Liens</span></h2>
|
|
<p>La discussion sur le forum <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=3&t=12282">Object description field</a>
|
|
</p><p>Mes macros sur <a rel="nofollow" class="external text" href="https://gist.github.com/mario52a">mario52a </a> gists
|
|
</p>
|
|
<h2><span class="mw-headline" id="Version">Version</span></h2>
|
|
<ul><li> ver 00.02 19/10/2015 : ajout d'un checkBox pour mémo String ou mémo Liste</li></ul>
|
|
<p><br />
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_PropertyMemo/fr&oldid=241180">http://www.freecadweb.org/wiki/index.php?title=Macro_PropertyMemo/fr&oldid=241180</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> |