Permanent macro install, the "Resident Macro"

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Permanent macro install, the "Resident Macro"

Post by freedman »

Direct to the point: I wrote a macro that builds a running environment (class Dockwidget) and then initialize with a "Super", I then make signal connections to a Selection Observer, all pretty normal stuff.
The code called by the Selection Observer stores the current selection visibility and then sets the selection visibility to 50%. A half second later a timer runs and sets the visibility back to the stored value.

Once everything is initialized the macro closes but it does not release the Selection Observer signal. Now the macro is running in what I call resident mode, the macro is installed and will continue to run until FreeCAD is restarted.

So if you run the included macro, any object selection will change visibility and then revert back a half second later. The only way to stop this process is to restart FreeCAD.

I wrote this attached macro as an example but the possibilities of using this concept are huge. If macros are loaded at FreeCAD startup then many different resident macros could be installed and would run concurrent to FreeCAD.

This is like doing development work but without compiling. I presume handles and variables might be lost when the macro closes so other means could be used for communication. It would be possible to communicate with resident code thru custom properties, values could be passed back and forth.
Attachments
ResidentM2.FCMacro
(1.83 KiB) Downloaded 29 times
Post Reply