Macro PropertyMemo: Difference between revisions
(Marked this version for translation) |
(Marked this version for translation) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
{{Macro |
||
|Name=Macro_PropertyMemo |
|Name=Macro_PropertyMemo |
||
|Icon=PropertyMemo.png |
|Icon=PropertyMemo.png |
||
|Description={{ColoredText|#ff0000|#ffffff|New version GUI modifyed for the HD dpi (QGridLayout) run only FC version 0.19 and more (PySide2 Qt5)}} <br/> <br/> |
|||
|Description=This little macro create one Property additional (memo or other text) for you object (work only with Draft objects).<br/>Launch the macro select one object Draft complete the fields and apply. One new property is created in '''Combo view → Property → Data tab'''. |
|||
For the precedent version see [https://gist.githubusercontent.com/mario52a/eafcf79703fab64b8da5/raw/51702c17fb4b205da52488bf2a239011bbbc9da5/Macro_FCPropertyMemo.FCMacro Macro_FCPropertyMemo.FCMacro] and install it manually.<br/><br/> |
|||
This macro creates an additional Property (memo or other text) for your object (works only with Draft objects). |
|||
<!--T:18--> |
|||
|Author=Mario52 |
|Author=Mario52 |
||
|Version= |
|Version=2020-05-17 |
||
|FCVersion=0.19 |
|||
|Date=2015-10-19 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/f/f2/PropertyMemo.png ToolBar Icon] |
|Download=[https://www.freecadweb.org/wiki/images/f/f2/PropertyMemo.png ToolBar Icon] |
||
}} |
}} |
||
==Description== <!--T:2--> |
==Description== <!--T:2--> |
||
This little macro create one Property additional (memo or other text) for you object (only Draft) |
|||
<!--T:19--> |
|||
This macro creates an additional Property (memo or other text) for your object (works only with Draft objects). |
|||
</translate> |
</translate> |
||
Line 22: | Line 24: | ||
<translate> |
<translate> |
||
<!--T:3--> |
<!--T:3--> |
||
{{Caption| |
{{Caption|Adding one property Memo → Name}} |
||
== |
==Usage== <!--T:4--> |
||
Launch the macro select one object Draft complete the fields and apply. One new property is created in '''Combo view → Property → Data tab''' |
|||
<!--T:20--> |
|||
Launch the macro, select one Draft object, complete the fields and apply. A new property is created in '''Combo view → Property → Data tab'''. |
|||
<!--T:5--> |
<!--T:5--> |
||
*'''Property title''' |
*'''Property title''' : Property title (group name) for the new property (Default: Memo). |
||
*'''Property name''' |
*'''Property name''' : Name for the new property. |
||
*{{CheckBox|TRUE|UnCheck for String}} : Checkbox that determines the memo type. Check the checkbox to change the type to string instead of list. |
|||
<!--T:6--> |
|||
[[File:Macro_FCPropertyMemo_01.png|left|One Property Memo is adding]] |
|||
<!--T: |
<!--T:21--> |
||
[[File:Macro_FCPropertyMemo_01.png|left|Example of a memo property]] |
|||
* '''Memo''' : Property title here Memo |
|||
* '''Name''' : Property name here Name |
|||
* The field is free to manually complete |
|||
</translate> |
</translate> |
||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
<!--T:14--> |
|||
<!--T:7--> |
|||
I the checkBox is checked you ave one memo in list, click to the tree point for open the list window |
|||
* '''Memo''' : Property title: {{Value|Memo}}. |
|||
* '''Name''' : Property name: {{Value|Name}}. |
|||
* The field is empty |
|||
<!--T:15--> |
<!--T:15--> |
||
<center> |
<center> |
||
<gallery widths="400" heights="200"> |
<gallery widths="400" heights="200"> |
||
Image:Macro_FCPropertyMemo_02.png| |
Image:Macro_FCPropertyMemo_02.png|Example of a memo property using a list |
||
Image:Macro_FCPropertyMemo_03.png| |
Image:Macro_FCPropertyMemo_03.png|Editing the list |
||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
Line 54: | Line 59: | ||
==Script== <!--T:8--> |
==Script== <!--T:8--> |
||
<!--T:22--> |
|||
The icon for the ToolBar [[File:PropertyMemo.png]] |
The icon for the ToolBar [[File:PropertyMemo.png]] |
||
</translate> |
</translate> |
||
'''Macro_FCPropertyMemo.FCMacro''' |
'''Macro_FCPropertyMemo.FCMacro''' |
||
{{ |
{{MacroCode|code= |
||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||
Line 65: | Line 73: | ||
""" |
""" |
||
*************************************************************************** |
*************************************************************************** |
||
* Copyright (c) 2015 |
* Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020 <mario52> * |
||
* * |
* * |
||
* This file is a supplement to the FreeCAD CAx development system. * |
* This file is a supplement to the FreeCAD CAx development system. * |
||
Line 74: | Line 82: | ||
* the License, or (at your option) any later version. * |
* the License, or (at your option) any later version. * |
||
* for detail see the LICENCE text file. * |
* for detail see the LICENCE text file. * |
||
* |
** ** |
||
* Use at your own risk. The author assumes no liability for data loss. * |
|||
* It is advised to backup your data frequently. * |
|||
* If you do not trust the software do not use it. * |
|||
** ** |
|||
* This software is distributed in the hope that it will be useful, * |
* This software is distributed in the hope that it will be useful, * |
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
Line 89: | Line 101: | ||
*************************************************************************** |
*************************************************************************** |
||
""" |
""" |
||
# |
#Macro_FCPropertyMemo 28/09/2015, 19/10/2015, 2020/05/17 |
||
# |
# |
||
# |
|||
#OS: Windows |
#OS: Windows 10 (10.0) |
||
#Word size of OS: 64-bit |
#Word size of OS: 64-bit |
||
#Word size of FreeCAD: 64-bit |
#Word size of FreeCAD: 64-bit |
||
#Version: 0. |
#Version: 0.19.20887 (Git) |
||
#Build type: Release |
|||
#Branch: releases/FreeCAD-0-15 |
|||
#Branch: master |
|||
#Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c |
|||
#Hash: 42c56d9fef82b484448e3730eb7da69c48fe1374 |
|||
#Python version: 2.7.8 |
|||
# |
#Python version: 3.6.8 |
||
#Qt version: 5.12.1 |
|||
#Coin version: 4.0.0a |
#Coin version: 4.0.0a |
||
#OCC version: |
#OCC version: 7.3.0 |
||
#Locale: French/Mars (fr_MA) |
|||
# |
# |
||
# |
|||
__title__ = "Macro_FCPropertyMemo" |
|||
__author__ = "Mario52" |
|||
__url__ = "https://wiki.freecadweb.org/Macro_PropertyMemo" |
|||
__urlGist = "https://gist.github.com/mario52a/eafcf79703fab64b8da5" |
|||
__version__ = "00.03" |
|||
__date__ = "2020/05/17" #YYYY/MM/DD |
|||
#### Test FreeCAD.Version simple ############################################################################################################ |
|||
__title__="Macro_FCPropertyMemo" |
|||
if int(FreeCAD.Version()[1]) < 19: # Version de FreeCAD |
|||
__author__ = "Mario52" |
|||
FreeCAD.Console.PrintMessage("This version " + __title__ + " rmu work with the FreeCAD 0.19 or higher." + "\n\n") |
|||
__url__ = "http://www.freecadweb.org/index-fr.html" |
|||
FreeCAD.Console.PrintMessage("For the precedent version see the page " + "\n\n") |
|||
__version__ = "00.02" |
|||
FreeCAD.Console.PrintMessage("https://gist.githubusercontent.com/mario52a/eafcf79703fab64b8da5/raw/51702c17fb4b205da52488bf2a239011bbbc9da5/Macro_FCPropertyMemo.FCMacro" + "\n\n") |
|||
__date__ = "19/10/2015" |
|||
#### Test FreeCAD.Version simple ############################################################################################################ |
|||
try: |
|||
import PyQt4 |
|||
import PySide2 |
|||
from PyQt4 import QtGui ,QtCore |
|||
from PySide2 import (QtWidgets, QtCore, QtGui) |
|||
from PyQt4.QtGui import * |
|||
from PySide2.QtWidgets import (QWidget, QApplication, QSlider, QGraphicsView, QGraphicsScene, QVBoxLayout, QStyle) |
|||
from PyQt4.QtCore import * |
|||
from PySide2.QtGui import (QPainter, QColor, QIcon) |
|||
except Exception: |
|||
from PySide2.QtSvg import * |
|||
from PySide import QtGui ,QtCore |
|||
from PySide.QtGui import * |
|||
from PySide.QtCore import * |
|||
#import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD |
#import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD |
||
Line 129: | Line 147: | ||
global title_02 ; title_02 = "" # title of propriety |
global title_02 ; title_02 = "" # title of propriety |
||
global memo_01 ; memo_01 = "" # memo |
global memo_01 ; memo_01 = "" # memo |
||
global forString; forString = |
global forString; forString = 1 # memo for String or List |
||
global ui ; ui = "" # |
|||
try: |
try: |
||
Line 153: | Line 172: | ||
global title_02 |
global title_02 |
||
global memo_01 |
global memo_01 |
||
##path########################################################################### |
|||
#path = FreeCAD.ConfigGet("AppHomePath") |
|||
#path = FreeCAD.ConfigGet("UserAppData") |
|||
#path = "your path" |
|||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path |
|||
self.path = param.GetString("MacroPath","") + "/" # macro path |
|||
self.path = self.path.replace("\\","/") |
|||
#App.Console.PrintMessage(str("Path for the icons : ") + self.path + "\n" + __title__ + " : " +__version__ + " " + __date__ + "\n") |
|||
# ################################################################################# |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
||
MainWindow.resize( |
# MainWindow.resize(260, 200) |
||
# MainWindow. |
# MainWindow.setMinimumSize(QtCore.QSize(254, 163)) |
||
MainWindow. |
# MainWindow.setMaximumSize(QtCore.QSize(254, 163)) |
||
MainWindow.setMaximumSize(QtCore.QSize(254, 163)) |
|||
###### Read Configuration begin #### |
|||
self.centralwidget = QtGui.QWidget(MainWindow) |
|||
title_01 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("LE_Edit_01") |
|||
title_02 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("LE_Edit_02") |
|||
CBString = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("CB_String") |
|||
###### Read Configuration end #### |
|||
self.centralwidget = QtWidgets.QWidget(MainWindow) |
|||
self.centralwidget.setObjectName(_fromUtf8("centralwidget")) |
self.centralwidget.setObjectName(_fromUtf8("centralwidget")) |
||
self. |
self.groupBox = QtWidgets.QGroupBox() |
||
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. |
self.label_00 = QtWidgets.QLabel() |
||
self. |
self.label_00.setAlignment(QtCore.Qt.AlignCenter) |
||
font = QtGui.QFont() |
|||
# self.PB_Button_02.setGeometry(QtCore.QRect(90, 180, 61, 23)) |
|||
font.setPointSize(10) |
|||
self.PB_Button_02.setObjectName(_fromUtf8("PB_Button_02")) |
|||
font.setBold(True) |
|||
self.PB_Button_02.clicked.connect(self.on_PB_Button_02_clicked) # |
|||
font.setUnderline(True) |
|||
font.setWeight(80) |
|||
self.label_00.setFont(font) |
|||
self. |
self.label_01 = QtWidgets.QLabel() |
||
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 = |
self.LE_Edit_01 = QtWidgets.QLineEdit() # title property |
||
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.setText(_fromUtf8(title_01)) |
||
self.LE_Edit_01. |
self.LE_Edit_01.textChanged.connect(self.on_LE_Edit_01_Pressed) |
||
self.LE_Edit_01.textChanged.connect(self.on_LE_Edit_01_Pressed) # title property |
|||
self. |
self.label_02 = QtWidgets.QLabel() |
||
self.LE_Edit_02.setGeometry(QtCore.QRect(20, 100, 211, 20)) |
|||
self.LE_Edit_02 = QtWidgets.QLineEdit() # title name |
|||
self.LE_Edit_02. |
self.LE_Edit_02.setText(_fromUtf8(title_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_02.textChanged.connect(self.on_LE_Edit_02_Pressed) # |
||
# self. |
# self.label_03 = QtWidgets.QLabel() |
||
# self.LE_Edit_03.setGeometry(QtCore.QRect(20, 150, 201, 20)) |
|||
# self.LE_Edit_03. |
# self.LE_Edit_03 = QtWidgets.QLineEdit() # memo |
||
# 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) # |
# self.LE_Edit_03.textChanged.connect(self.on_LE_Edit_03_Pressed) # |
||
self.CB_String = QtWidgets.QCheckBox() # for String or List |
|||
MainWindow.setCentralWidget(self.centralwidget) |
|||
self.CB_String.setChecked(CBString) |
|||
self.CB_String.clicked.connect(self.on_CB_String_clicked) # connect on def "on_checkBox_1_clicked" |
|||
self. |
self.PB_Help = QtWidgets.QPushButton() |
||
self.PB_Help.setToolTip(_fromUtf8("Help on line " + __version__ + " " + __date__ + " rmu")) |
|||
self.label_00.setGeometry(QtCore.QRect(70, 10, 120, 21)) |
|||
self.PB_Help.setIcon(QtGui.QIcon.fromTheme("help",QtGui.QIcon(":/icons/help-browser.svg"))) |
|||
font = QtGui.QFont() |
|||
self.PB_Help.clicked.connect(self.on_PB_Help) # |
|||
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. |
self.PB_Button_01 = QtWidgets.QPushButton() |
||
self.PB_Button_01.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/view-refresh.svg"))) |
|||
self.label_01.setGeometry(QtCore.QRect(20, 30, 111, 16)) |
|||
self. |
self.PB_Button_01.clicked.connect(self.on_PB_Button_01_clicked) # |
||
self. |
self.PB_Button_02 = QtWidgets.QPushButton() |
||
# self.PB_Button_02.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogOkButton))) # |
|||
self.label_02.setGeometry(QtCore.QRect(20, 80, 111, 16)) |
|||
self.PB_Button_02.setIcon(QtGui.QIcon.fromTheme("execute",QtGui.QIcon(":/icons/button_valid.svg"))) |
|||
self.label_02.setObjectName(_fromUtf8("label_02")) |
|||
self.PB_Button_02.clicked.connect(self.on_PB_Button_02_clicked) # |
|||
self.PB_Button_03 = QtWidgets.QPushButton() |
|||
self.PB_Button_03.setIcon(QtGui.QIcon.fromTheme("close",QtGui.QIcon(":/icons/application-exit.svg"))) |
|||
# self.label_03.setGeometry(QtCore.QRect(20, 130, 121, 16)) |
|||
self.PB_Button_03.clicked.connect(self.on_PB_Button_03_clicked) # |
|||
# self.label_03.setObjectName(_fromUtf8("label_03")) |
|||
#### Layout debut ######################## |
|||
self.CB_String = QtGui.QCheckBox(self.centralwidget) # for String or List |
|||
self.grid0 = QtWidgets.QGridLayout(self.centralwidget) |
|||
self. |
self.grid0.setContentsMargins(10, 10, 10, 10) |
||
self. |
self.grid0.addWidget(self.groupBox, 0, 0, 1, 1) |
||
self.gridLayout = QtWidgets.QGridLayout(self.groupBox) |
|||
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.gridLayout.addWidget(self.label_00, 1, 0, 1, 4) |
|||
self.CB_String.clicked.connect(self.on_CB_String_clicked) # connect on def "on_checkBox_1_clicked" |
|||
self.gridLayout.addWidget(self.label_01, 2, 0, 1, 4) |
|||
self.gridLayout.addWidget(self.LE_Edit_01, 3, 0, 1, 4) |
|||
self.gridLayout.addWidget(self.label_02, 4, 0, 1, 2) |
|||
self.gridLayout.addWidget(self.CB_String, 4, 2, 1, 2) |
|||
self.gridLayout.addWidget(self.LE_Edit_02, 5, 0, 1, 4) |
|||
# self.gridLayout.addWidget(self.label_03, 6, 0, 1, 4) |
|||
# self.gridLayout.addWidget(self.LE_Edit_03, 7, 0, 1, 3) |
|||
self.gridLayout.addWidget(self.PB_Help, 8, 0, 1, 1) |
|||
self.gridLayout.addWidget(self.PB_Button_01, 8, 1, 1, 1) |
|||
self.gridLayout.addWidget(self.PB_Button_02, 8, 2, 1, 1) |
|||
self.gridLayout.addWidget(self.PB_Button_03, 8, 3, 1, 1) |
|||
#### Layout fin ########################### |
|||
MainWindow.setCentralWidget(self.centralwidget) |
|||
self.retranslateUi(MainWindow) |
self.retranslateUi(MainWindow) |
||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
||
def retranslateUi(self, MainWindow): |
def retranslateUi(self, MainWindow): |
||
MainWindow.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # PySide2 cette fonction met la fenetre en avant |
|||
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") |
|||
MainWindow.setWindowIcon(QtGui.QIcon(_fromUtf8(self.path + "PropertyMemo.png"))) # change l'icone de la fenetre principale |
|||
self.PB_Button_03.setToolTip("Quit the FCPropertyMemo") |
|||
_translate = QtCore.QCoreApplication.translate |
|||
self.label_00.setText("FCPropertyMemo") |
|||
MainWindow.setWindowTitle(_translate("MainWindow", "FCPropertyMemo")) |
|||
self.label_01.setText("Property title") |
|||
self.label_02.setText("Property name") |
|||
self.groupBox.setTitle(_translate("MainWindow", "ver : " + __version__ + " : " + __date__ + " (rmu)")) |
|||
# self.label_03.setText("Memo") |
|||
self. |
self.label_00.setText(_translate("MainWindow", "FCProperty Memo")) |
||
self.label_01.setText(_translate("MainWindow", "Property title")) |
|||
self.label_02.setText(_translate("MainWindow", "Property name")) |
|||
self.CB_String.setText(_translate("MainWindow", "UnCheck for String")) |
|||
self.LE_Edit_02.setToolTip("Title of property") |
|||
# self.label_03.setText(_translate("MainWindow", "Memo")) |
|||
# self.LE_Edit_03.setText(_fromUtf8("")) |
|||
# self.LE_Edit_03.setToolTip("Text memo") |
|||
self.PB_Help.setText(_translate("MainWindow", "Wiki")) |
|||
self.PB_Button_01.setText(_translate("MainWindow", "Reset")) |
|||
self.PB_Button_02.setText(_translate("MainWindow", "Validate")) |
|||
self.PB_Button_03.setText(_translate("MainWindow", "Quit")) |
|||
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") |
|||
def on_LE_Edit_01_Pressed(self): # Line edit 01 title |
def on_LE_Edit_01_Pressed(self): # Line edit 01 title |
||
global title_01 |
global title_01 |
||
title_01 = self.LE_Edit_01.text() |
title_01 = self.LE_Edit_01.text() |
||
# App.Console.PrintMessage(title_01+"\n") |
# App.Console.PrintMessage(title_01+"\n") |
||
Line 263: | Line 302: | ||
def on_LE_Edit_02_Pressed(self): # Line edit 02 title property |
def on_LE_Edit_02_Pressed(self): # Line edit 02 title property |
||
global title_02 |
global title_02 |
||
title_02 = self.LE_Edit_02.text() |
title_02 = self.LE_Edit_02.text() |
||
# App.Console.PrintMessage(title_02+"\n") |
# App.Console.PrintMessage(title_02+"\n") |
||
Line 273: | Line 313: | ||
def on_CB_String_clicked(self): # connection on_checkBox_1_clicked |
def on_CB_String_clicked(self): # connection on_checkBox_1_clicked |
||
global forString |
global forString |
||
if self.CB_String.isChecked(): # if checkbox_01 is checked then .... |
if self.CB_String.isChecked(): # if checkbox_01 is checked then .... |
||
forString = 1 |
forString = 1 |
||
Line 286: | Line 327: | ||
global memo_01 |
global memo_01 |
||
global forString |
global forString |
||
self.LE_Edit_01.clear() |
self.LE_Edit_01.clear() |
||
title_01 = "Memo" |
title_01 = "Memo" |
||
Line 293: | Line 335: | ||
# self.LE_Edit_03.clear() |
# self.LE_Edit_03.clear() |
||
# memo_01 = "" |
# memo_01 = "" |
||
self.CB_String.setChecked( |
self.CB_String.setChecked(True) |
||
forString = 1 |
|||
self.CB_String.setText("UnCheck for String") |
|||
forString = 0 |
|||
# App.Console.PrintMessage("on_PB_Button_01_clicked\n") |
# App.Console.PrintMessage("on_PB_Button_01_clicked\n") |
||
def on_PB_Button_02_clicked(self): # Button Validate |
def on_PB_Button_02_clicked(self): # Button Validate |
||
global ui |
|||
global title_01 |
global title_01 |
||
global title_02 |
global title_02 |
||
global memo_01 |
global memo_01 |
||
global forString |
global forString |
||
try: |
|||
# try: |
|||
obj = FreeCADGui.Selection.getSelection()[0] |
|||
obj = "" |
|||
obj = FreeCADGui.Selection.getSelection()[0] |
|||
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 : # title_02 = sous titre, title_01 = titre |
|||
a = obj.addProperty("App::PropertyString",title_02, title_01, "_Memo") # create a memo string |
|||
#FreeCAD.ActiveDocument.getObject(obj.Name) = memo_01 |
|||
else : |
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() |
|||
a = obj.addProperty("App::PropertyString",title_02,title_01,"_Memo") # create a memo string |
|||
#ui.on_PB_Button_01_clicked() # Reset |
|||
else: |
|||
a = obj.addProperty("App::PropertyStringList",title_02,title_01,"_Memo") # Create a list in window |
|||
App.Console.PrintMessage("Field empty"+"\n") |
|||
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: |
# except Exception: |
||
App.Console.PrintWarning("Object not selected or not Draft object"+"\n") |
# 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 |
def on_PB_Button_03_clicked(self): # Button Quit |
||
App.Console.PrintMessage("End FCPropertyMemo"+"\n\n") |
App.Console.PrintMessage("End FCPropertyMemo"+"\n\n") |
||
###### Write Configuration begin #### |
|||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("CB_String", self.CB_String.isChecked())# True or False |
|||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("LE_Edit_01", title_01) # "" |
|||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("LE_Edit_02", "") # title_02 |
|||
###### Write Configuration end #### |
|||
self.window.hide() |
self.window.hide() |
||
def on_PB_Help(self): # Button Help |
|||
MainWindow = QtGui.QMainWindow() |
|||
import WebGui |
|||
WebGui.openBrowser(__url__) |
|||
App.Console.PrintMessage(__url__ + "\n") |
|||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("Version",__version__ + " (" + __date__ + ")")# |
|||
MainWindow = QtWidgets.QMainWindow() |
|||
ui = Ui_MainWindow() |
ui = Ui_MainWindow() |
||
ui.setupUi(MainWindow) |
ui.setupUi(MainWindow) |
||
MainWindow.show() |
MainWindow.show() |
||
}} |
}} |
||
<translate> |
<translate> |
||
==Link== <!--T:11--> |
==Link== <!--T:11--> |
||
Line 352: | Line 410: | ||
<!--T:13--> |
<!--T:13--> |
||
My macros on [https://gist.github.com/mario52a mario52a |
My macros on Github of [https://gist.github.com/mario52a mario52a]. |
||
==Version== <!--T:16--> |
==Version== <!--T:16--> |
||
<!--T:17--> |
<!--T:17--> |
||
* ver 00. |
* ver 00.03 2020/05/17 : Grid layout for 0.19 |
||
* ver 00.02 19/10/2015 : Add checkBox for choice memo String or memo List |
|||
</translate> |
</translate> |
Latest revision as of 12:45, 5 December 2023
Description |
---|
New version GUI modifyed for the HD dpi (QGridLayout) run only FC version 0.19 and more (PySide2 Qt5) For the precedent version see Macro_FCPropertyMemo.FCMacro and install it manually. |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
2020-05-17 |
Date last modified |
None |
FreeCAD Version(s) |
0.19 |
Default shortcut |
None |
See also |
None |
Description
This macro creates an additional Property (memo or other text) for your object (works only with Draft objects).
Adding one property Memo → Name
Usage
Launch the macro, select one Draft object, complete the fields and apply. A new property is created in Combo view → Property → Data tab.
- Property title : Property title (group name) for the new property (Default: Memo).
- Property name : Name for the new property.
- UnCheck for String : Checkbox that determines the memo type. Check the checkbox to change the type to string instead of list.
- Memo : Property title:
Memo
. - Name : Property name:
Name
. - The field is empty
-
Example of a memo property using a list
-
Editing the list
Script
Macro_FCPropertyMemo.FCMacro
# -*- coding: utf-8 -*- from __future__ import unicode_literals """ *************************************************************************** * Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020 <mario52> * * * * This file is a supplement to the FreeCAD CAx development system. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License (LGPL) * * as published by the Free Software Foundation; either version 2 of * * the License, or (at your option) any later version. * * for detail see the LICENCE text file. * ** ** * Use at your own risk. The author assumes no liability for data loss. * * It is advised to backup your data frequently. * * If you do not trust the software do not use it. * ** ** * This software is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this macro; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * * USA * *************************************************************************** * WARNING! All changes in this file will be lost and * * may cause malfunction of the program * *************************************************************************** """ #Macro_FCPropertyMemo 28/09/2015, 19/10/2015, 2020/05/17 # # #OS: Windows 10 (10.0) #Word size of OS: 64-bit #Word size of FreeCAD: 64-bit #Version: 0.19.20887 (Git) #Build type: Release #Branch: master #Hash: 42c56d9fef82b484448e3730eb7da69c48fe1374 #Python version: 3.6.8 #Qt version: 5.12.1 #Coin version: 4.0.0a #OCC version: 7.3.0 #Locale: French/Mars (fr_MA) # # __title__ = "Macro_FCPropertyMemo" __author__ = "Mario52" __url__ = "https://wiki.freecadweb.org/Macro_PropertyMemo" __urlGist = "https://gist.github.com/mario52a/eafcf79703fab64b8da5" __version__ = "00.03" __date__ = "2020/05/17" #YYYY/MM/DD #### Test FreeCAD.Version simple ############################################################################################################ if int(FreeCAD.Version()[1]) < 19: # Version de FreeCAD FreeCAD.Console.PrintMessage("This version " + __title__ + " rmu work with the FreeCAD 0.19 or higher." + "\n\n") FreeCAD.Console.PrintMessage("For the precedent version see the page " + "\n\n") FreeCAD.Console.PrintMessage("https://gist.githubusercontent.com/mario52a/eafcf79703fab64b8da5/raw/51702c17fb4b205da52488bf2a239011bbbc9da5/Macro_FCPropertyMemo.FCMacro" + "\n\n") #### Test FreeCAD.Version simple ############################################################################################################ import PySide2 from PySide2 import (QtWidgets, QtCore, QtGui) from PySide2.QtWidgets import (QWidget, QApplication, QSlider, QGraphicsView, QGraphicsScene, QVBoxLayout, QStyle) from PySide2.QtGui import (QPainter, QColor, QIcon) from PySide2.QtSvg import * #import 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 = 1 # memo for String or List global ui ; ui = "" # 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 ##path########################################################################### #path = FreeCAD.ConfigGet("AppHomePath") #path = FreeCAD.ConfigGet("UserAppData") #path = "your path" param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path self.path = param.GetString("MacroPath","") + "/" # macro path self.path = self.path.replace("\\","/") #App.Console.PrintMessage(str("Path for the icons : ") + self.path + "\n" + __title__ + " : " +__version__ + " " + __date__ + "\n") # ################################################################################# MainWindow.setObjectName(_fromUtf8("MainWindow")) # MainWindow.resize(260, 200) # MainWindow.setMinimumSize(QtCore.QSize(254, 163)) # MainWindow.setMaximumSize(QtCore.QSize(254, 163)) ###### Read Configuration begin #### title_01 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("LE_Edit_01") title_02 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("LE_Edit_02") CBString = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("CB_String") ###### Read Configuration end #### self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.groupBox = QtWidgets.QGroupBox() self.label_00 = QtWidgets.QLabel() self.label_00.setAlignment(QtCore.Qt.AlignCenter) font = QtGui.QFont() font.setPointSize(10) font.setBold(True) font.setUnderline(True) font.setWeight(80) self.label_00.setFont(font) self.label_01 = QtWidgets.QLabel() self.LE_Edit_01 = QtWidgets.QLineEdit() # title property self.LE_Edit_01.setText(_fromUtf8(title_01)) self.LE_Edit_01.textChanged.connect(self.on_LE_Edit_01_Pressed) self.label_02 = QtWidgets.QLabel() self.LE_Edit_02 = QtWidgets.QLineEdit() # title name self.LE_Edit_02.setText(_fromUtf8(title_02)) self.LE_Edit_02.textChanged.connect(self.on_LE_Edit_02_Pressed) # # self.label_03 = QtWidgets.QLabel() # self.LE_Edit_03 = QtWidgets.QLineEdit() # memo # self.LE_Edit_03.textChanged.connect(self.on_LE_Edit_03_Pressed) # self.CB_String = QtWidgets.QCheckBox() # for String or List self.CB_String.setChecked(CBString) self.CB_String.clicked.connect(self.on_CB_String_clicked) # connect on def "on_checkBox_1_clicked" self.PB_Help = QtWidgets.QPushButton() self.PB_Help.setToolTip(_fromUtf8("Help on line " + __version__ + " " + __date__ + " rmu")) self.PB_Help.setIcon(QtGui.QIcon.fromTheme("help",QtGui.QIcon(":/icons/help-browser.svg"))) self.PB_Help.clicked.connect(self.on_PB_Help) # self.PB_Button_01 = QtWidgets.QPushButton() self.PB_Button_01.setIcon(QtGui.QIcon.fromTheme("refresh",QtGui.QIcon(":/icons/view-refresh.svg"))) self.PB_Button_01.clicked.connect(self.on_PB_Button_01_clicked) # self.PB_Button_02 = QtWidgets.QPushButton() # self.PB_Button_02.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogOkButton))) # self.PB_Button_02.setIcon(QtGui.QIcon.fromTheme("execute",QtGui.QIcon(":/icons/button_valid.svg"))) self.PB_Button_02.clicked.connect(self.on_PB_Button_02_clicked) # self.PB_Button_03 = QtWidgets.QPushButton() self.PB_Button_03.setIcon(QtGui.QIcon.fromTheme("close",QtGui.QIcon(":/icons/application-exit.svg"))) self.PB_Button_03.clicked.connect(self.on_PB_Button_03_clicked) # #### Layout debut ######################## self.grid0 = QtWidgets.QGridLayout(self.centralwidget) self.grid0.setContentsMargins(10, 10, 10, 10) self.grid0.addWidget(self.groupBox, 0, 0, 1, 1) self.gridLayout = QtWidgets.QGridLayout(self.groupBox) self.gridLayout.addWidget(self.label_00, 1, 0, 1, 4) self.gridLayout.addWidget(self.label_01, 2, 0, 1, 4) self.gridLayout.addWidget(self.LE_Edit_01, 3, 0, 1, 4) self.gridLayout.addWidget(self.label_02, 4, 0, 1, 2) self.gridLayout.addWidget(self.CB_String, 4, 2, 1, 2) self.gridLayout.addWidget(self.LE_Edit_02, 5, 0, 1, 4) # self.gridLayout.addWidget(self.label_03, 6, 0, 1, 4) # self.gridLayout.addWidget(self.LE_Edit_03, 7, 0, 1, 3) self.gridLayout.addWidget(self.PB_Help, 8, 0, 1, 1) self.gridLayout.addWidget(self.PB_Button_01, 8, 1, 1, 1) self.gridLayout.addWidget(self.PB_Button_02, 8, 2, 1, 1) self.gridLayout.addWidget(self.PB_Button_03, 8, 3, 1, 1) #### Layout fin ########################### MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # PySide2 cette fonction met la fenetre en avant MainWindow.setWindowIcon(QtGui.QIcon(_fromUtf8(self.path + "PropertyMemo.png"))) # change l'icone de la fenetre principale _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "FCPropertyMemo")) self.groupBox.setTitle(_translate("MainWindow", "ver : " + __version__ + " : " + __date__ + " (rmu)")) self.label_00.setText(_translate("MainWindow", "FCProperty Memo")) self.label_01.setText(_translate("MainWindow", "Property title")) self.label_02.setText(_translate("MainWindow", "Property name")) self.CB_String.setText(_translate("MainWindow", "UnCheck for String")) self.LE_Edit_02.setToolTip("Title of property") # self.label_03.setText(_translate("MainWindow", "Memo")) # self.LE_Edit_03.setText(_fromUtf8("")) # self.LE_Edit_03.setToolTip("Text memo") self.PB_Help.setText(_translate("MainWindow", "Wiki")) self.PB_Button_01.setText(_translate("MainWindow", "Reset")) self.PB_Button_02.setText(_translate("MainWindow", "Validate")) self.PB_Button_03.setText(_translate("MainWindow", "Quit")) 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") 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(True) forString = 1 self.CB_String.setText("UnCheck for String") # App.Console.PrintMessage("on_PB_Button_01_clicked\n") def on_PB_Button_02_clicked(self): # Button Validate global ui global title_01 global title_02 global memo_01 global forString # try: obj = "" obj = FreeCADGui.Selection.getSelection()[0] 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 : # title_02 = sous titre, title_01 = titre a = obj.addProperty("App::PropertyString",title_02, title_01, "_Memo") # create a memo string #FreeCAD.ActiveDocument.getObject(obj.Name) = memo_01 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() #ui.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") ###### Write Configuration begin #### FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("CB_String", self.CB_String.isChecked())# True or False FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("LE_Edit_01", title_01) # "" FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("LE_Edit_02", "") # title_02 ###### Write Configuration end #### self.window.hide() def on_PB_Help(self): # Button Help import WebGui WebGui.openBrowser(__url__) App.Console.PrintMessage(__url__ + "\n") FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("Version",__version__ + " (" + __date__ + ")")# MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show()
Link
The discussion on the forum Object description field
My macros on Github of mario52a.
Version
- ver 00.03 2020/05/17 : Grid layout for 0.19
- ver 00.02 19/10/2015 : Add checkBox for choice memo String or memo List