Around this time last year we cre­at­ed a small tuto­r­i­al to make a fes­tive tree dec­o­ra­tion, shame­less­ly using the win­ter hol­i­days to actu­al­ly write a tuto­r­i­al that, whilst pre­tend­ing to be fes­tive, real­ly explained the use of the revolve tool! This year we are aim­ing for sim­i­lar, we are going to cre­ate a star shaped dec­o­ra­tion suit­able for 3D print­ing, but we are going to learn how to use a com­mu­ni­ty cre­at­ed macro.

Macro’s in FreeCAD are essen­tial­ly small scripts that can be played back to repeat a set of com­mands and func­tions. They take the form of small python files and there are thou­sands of them out there in the com­mu­ni­ty to be explored. Of course, you can also dive into cre­at­ing your own macros, but that is anoth­er story.

You could, of course, draw a star in many ways, you could place and edit numer­ous tri­an­gles in sketch­er or you could indeed use the Poly­line tool and lots of posi­tion­al con­straints. How­ev­er, it would be nice to draw a star auto­mat­i­cal­ly. To do this nav­i­gate over to this repo and high­light and copy all the code in the starmacro.py file.

Next open up FreeCAD (we used ver­sion 1.1 rc1) and then left click the “Macro” drop down and left click on “Macros”. In the “Exe­cute Macros” win­dow click the “Cre­ate” but­ton and give this new macro a name such as “Star­Ma­cro”. You should then see a new emp­ty tab appear in the pre­view win­dow. Paste the con­tents of the Macro we copied ear­li­er from the repo into this tab and then click the save but­ton. You can now close that tab.

Next cre­ate a new project from the start page using the “Para­met­ric Body” but­ton in the “New File” win­dow. In this project click to add a sketch and select the XY plane as the work­ing plane. This will launch the sketch­er work­bench. Once in the sketch­er work­bench again left click “Macro – Macros” from the tool bar and then in the “Exe­cute Macros” dia­logue scroll down to find your new star macro in the list. High­light the macro in the list and then click “Exe­cute”.

A small dia­logue will appear that sim­ply asks for you to input the num­ber of points you require your star to have. Type in what you require and then left click in the sketch at the cen­tre point of your star and left click again where you would like the edge of your star and your star will appear. Simple!

Clos­ing the Macro dia­logue we can then either fur­ther con­strain the sketch, or sim­ply close the sketch and then click the “Pad” tool to cre­ate our 3D star. As final touch­es we then left clicked on the sur­face of the star, attached anoth­er sketch and made a small hole to hang our dec­o­ra­tion with. We also then, after sav­ing the file, select­ed a point on the star and used the fil­let tool to add a fil­let and select­ed every tip of the star to make the tips a lit­tle round­ed. Final­ly, you can select the item in the tree view and use the “File — Export” menu to export you item as an stl or obj or oth­er for­mats ready for slic­ing and 3D printing. 

Whilst this isn’t a huge project it’s a nice small intro­duc­tion to using the macro sys­tem and we hope you enjoyed it. Final­ly, we hope wher­ev­er you are and what­ev­er you do or don’t cel­e­brate, that you are hav­ing a peace­ful and rest­ful time!


Discover more from FreeCAD News

Subscribe to get the latest posts sent to your email.