Macro Template Helper Error [SOLVED]
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Macro Template Helper Error [SOLVED]
I have installed the macrow as described her:
https://wiki.freecadweb.org/Macro_TemplateHelper/en
It appears in the Macros Menu but when I execute it nothing appears an I get this error message in the report view which looks very strange:-
17:27:12 Traceback (most recent call last):
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 1331, in <module>
main()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 1201, in main
form = InputWindow()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 101, in __init__
self.initUI()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 122, in initUI
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
<class 'NameError'>: name 'QtCore' is not defined
The path leads to my cloud folder??
Has anyone got any idea what is going on here? all advice appreciated.
EDIT : My Bolts Macro and FC Info Macros are working properly??
https://wiki.freecadweb.org/Macro_TemplateHelper/en
It appears in the Macros Menu but when I execute it nothing appears an I get this error message in the report view which looks very strange:-
17:27:12 Traceback (most recent call last):
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 1331, in <module>
main()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 1201, in main
form = InputWindow()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 101, in __init__
self.initUI()
File "/home/Laurie/MEGA/MEGAsync/Bolts Macro/TemplateHelper.FCMacro", line 122, in initUI
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
<class 'NameError'>: name 'QtCore' is not defined
The path leads to my cloud folder??
Has anyone got any idea what is going on here? all advice appreciated.
EDIT : My Bolts Macro and FC Info Macros are working properly??
- Attachments
-
- Macro preference Page.png (84.95 KiB) Viewed 962 times
Last edited by Laurie Hartley on Sat Jul 23, 2022 1:04 am, edited 1 time in total.
Re: Macro Template Helper Error
apparently, the macro is missing a required import:
Add this near the top (around the existing imports) in your macro.
Code: Select all
from PySide2 import QtCore
Cheers,
Markus
Markus
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Re: Macro Template Helper Error
Thanks for your quick response Markus. Just be sure - am I right in my understanding that what I have to do is choose the edit option on the macro menu screen then add this line of code into it?mfro wrote: ↑Fri Jul 22, 2022 9:05 am apparently, the macro is missing a required import:
Add this near the top (around the existing imports) in your macro.Code: Select all
from PySide2 import QtCore
Re: Macro Template Helper Error
Yes.Laurie Hartley wrote: ↑Fri Jul 22, 2022 10:53 am Thanks for your quick response Markus. Just be sure - am I right in my understanding that what I have to do is choose the edit option on the macro menu screen then add this line of code into it?
Cheers,
Markus
Markus
Re: Macro Template Helper Error
@mfro can you give me a hint, why this error never uccurs when I test this macro? It still runs fine without this line on my Macmfro wrote: ↑Fri Jul 22, 2022 9:05 am apparently, the macro is missing a required import:
Add this near the top (around the existing imports) in your macro.Code: Select all
from PySide2 import QtCore
Code: Select all
OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.21.29485 (Git)
Build type: Release
Branch: master
Hash: a236ca843fdd6674afb6d7ed1454fbd3b547f5ea
Python 3.10.5, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: C/Default (C)
Installed mods:
* Reinforcement
* Render 2022.2.0
* sheetmetal 0.2.50
* Help 1.0.3
* Curves 0.5.2
* Assembly3 0.11.3
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Re: Macro Template Helper Error
Thanks Markus - your solution worked like a charm.mfro wrote: ↑Fri Jul 22, 2022 12:09 pmYes.Laurie Hartley wrote: ↑Fri Jul 22, 2022 10:53 am Thanks for your quick response Markus. Just be sure - am I right in my understanding that what I have to do is choose the edit option on the macro menu screen then add this line of code into it?
I have attached a image showing the whereabouts of the edit which may be of help to others.
- Attachments
-
- Template_helper_macro_edit.png (25.27 KiB) Viewed 783 times
Re: Macro Template Helper Error
Wild guess: probably the module is already imported into the interpreter from elsewhere?
You can inspect which modules are imported like so:
Code: Select all
import sys
def listModules():
for key in sys.modules.keys():
print(key)
print('list of imported modules:')
listModules()
Cheers,
Markus
Markus
Re: Macro Template Helper Error [SOLVED]
I have another suspicion: there is a setting in Preferences/General/Macro "Run macros in local environment" which is set by default.
Do you have that unset, by any chance?
Cheers,
Markus
Markus
Re: Macro Template Helper Error [SOLVED]
No, it is (still) checked. I follow the rule: Don't touch settings that you don't understand (yet).