Add an option to incorporate Macro in the CAD file

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Add an option to incorporate Macro in the CAD file

Post by adrianinsaval »

One could just include these instructions as a comment at the beginning of the text
Roy_043 wrote: Wed Sep 28, 2022 7:49 am This works:

Code: Select all

eval(compile(FreeCAD.activeDocument().getObject("Text_document").Text, "<string>", "exec"))
Last edited by adrianinsaval on Wed Sep 28, 2022 3:48 pm, edited 1 time in total.
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Add an option to incorporate Macro in the CAD file

Post by saso »

Roy_043 wrote: Wed Sep 28, 2022 7:49 am This works:

Code: Select all

eval(compile(FreeCAD.activeDocument().getObject("Text_document").Text, "<string>", "exec"))
Nice!

I had a simple example of such workflows width "scripted modeling" here https://forum.freecadweb.org/viewtopic. ... 96#p476096, check also some of the more advanced examples done in a similar way in catia by mansu kim, following the link to his youtube in that post...
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Add an option to incorporate Macro in the CAD file

Post by onekk »

saso wrote: Wed Sep 28, 2022 1:45 pm ...
I had a simple example of such workflows width "scripted modeling" here https://forum.freecadweb.org/viewtopic. ... 96#p476096...
What example, could you please explain not using a youtube video?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Add an option to incorporate Macro in the CAD file

Post by saso »

onekk wrote: Wed Sep 28, 2022 2:22 pm What example, could you please explain not using a youtube video?
My simple example is in the Scripts_in_Model.FCStd file attached to that post, where a script inside the model is used to "study" the profile sections at different positions... But obviously much much more can be done with this and some of the videos show some more advanced examples... Maybe we could try to recreate some in FC :roll:
Last edited by saso on Wed Sep 28, 2022 4:26 pm, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Add an option to incorporate Macro in the CAD file

Post by onekk »

saso wrote: Wed Sep 28, 2022 2:32 pm Maybe we could try to recreate some in FC :roll:
Maybe!

It is not too difficult, even creating them as a FCStd document, probably some helpers methods should be created, but I've already done something similar for Assembly4, maybe see:

https://forum.freecadweb.org/viewtopic. ... 24#p628824

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply