Windows: executing a script that creates a class

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
agerber85
Posts: 1
Joined: Fri Nov 18, 2022 6:37 pm

Windows: executing a script that creates a class

Post by agerber85 »

I have a FCMacro, 'threadclass.FCMacro' I developed a few years ago that defines a class called 'thread'. That was probably FC 0.17 or 0.19 on Windows 7, and now I'm on Windows 10. I'm pretty sure I would launch it from the console using basically exec('path/to/threadclass.FCMacro'), but I probably would have had to deal with the fact that Windows uses backlashes. Now whenever I try it with backslashes in the string, I get
SyntaxError: unexpected character after line continuation character
which makes sense, since my string has'\t' in it. I've tried using the "Macros..." dialog to launch it, but whenever I do that, FC acts like the class 'thread' has not been defined, so I'm not sure it is executing.

What's the most preferable way for me to go about executing this macro? If I think I might commonly use it, how can I have it launch every time Freecad opens, so that the class is always available?
Attachments
threadclass.FCMacro
(19.64 KiB) Downloaded 15 times
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Windows: executing a script that creates a class

Post by heda »

"I've tried using the "Macros..." dialog to launch it, but whenever I do that, FC acts like the class 'thread' has not been defined, so I'm not sure it is executing"

there is a setting for that behaviour
uncheck "Run macros in local environment" in Preferences_Editor#Macro
Post Reply