Macro within a Sketch

Need help, or want to share a macro? Post here!
gsandy
Posts: 205
Joined: Sun Jan 27, 2019 7:07 pm
Location: Auckland New Zealand

Macro within a Sketch

Postby gsandy » Thu Jul 22, 2021 12:45 am

I have a parametric model that includes flanges (rectangular and circular). I would like the bolt holes (number, size and spacing) within the flange sketch to be determined by spreadsheet values. Is this possible?

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.25288 (Git)
Build type: Release
Branch: master
Hash: bbb557aab6129efd9486d6df19f06c2976fdb7e5
Python version: 3.8.10
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/New Zealand (en_NZ)
edwilliams16
Posts: 505
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Macro within a Sketch

Postby edwilliams16 » Thu Jul 22, 2021 2:18 am

Size and spacing is easy - no macro required. https://wiki.freecadweb.org/Expressions
OTOH changing the number of holes probably does require a macro. Maybe if you can toggle the extra holes to construction in some way, it might work, but is sounds fragile to me.
gsandy
Posts: 205
Joined: Sun Jan 27, 2019 7:07 pm
Location: Auckland New Zealand

Re: Macro within a Sketch

Postby gsandy » Thu Jul 22, 2021 4:35 am

Thanks Ed I will give that a go. Cheers Sandy
chrisb
Posts: 35961
Joined: Tue Mar 17, 2015 9:14 am

Re: Macro within a Sketch

Postby chrisb » Thu Jul 22, 2021 7:28 am

Holes around a flange are usually of equal distance. Than you should use a polar pattern and there you can adjust the number of holes by macro by changing the number of occurrences.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
gsandy
Posts: 205
Joined: Sun Jan 27, 2019 7:07 pm
Location: Auckland New Zealand

Re: Macro within a Sketch

Postby gsandy » Thu Jul 22, 2021 5:55 pm

My model has not been created within the Part Design WB and therefore the polar patter is not available. When I enter the flange sketch to add the holes the only array available is rectangular (see screenshot), which is good for the rectangular flange holes, but even then there is no option to link an alias in the spreadsheet.
Attachments
Snap 2021-07-23 at 05.51.52.png
Snap 2021-07-23 at 05.51.52.png (1.3 KiB) Viewed 173 times
chrisb
Posts: 35961
Joined: Tue Mar 17, 2015 9:14 am

Re: Macro within a Sketch

Postby chrisb » Thu Jul 22, 2021 10:41 pm

Inside of sketcher you cannot directly use expressions for the number of repititions. If you used Part workbench to build your model, then Draft->Array functions will be your friends.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
gsandy
Posts: 205
Joined: Sun Jan 27, 2019 7:07 pm
Location: Auckland New Zealand

Re: Macro within a Sketch

Postby gsandy » Thu Jul 22, 2021 11:15 pm

Thanks Chris, I will redo the model.