FreeCAD Logo FreeCAD 1.0
  • English Afrikaans Arabic Belarusian Catalan Czech German Greek Spanish Spanish Basque Finnish Filipino French Galician Croatian Hungarian Indonesian Italian Japanese Kabyle Korean Lithuanian Dutch Norwegian Bokmal Polish Portuguese Portuguese Romanian Russian Slovak Slovenian Serbian Swedish Turkish Ukrainian Valencian Vietnamese Chinese Chinese
  • Features
  • Download
  • Blog
  • Documentation
    Documentation index Getting started Users documentation The FreeCAD manual Workbenches documentation Python coding documentation C++ coding documentation Tutorials Frequently asked questions Privacy policy About FreeCAD
  • Contribute
    How to help Sponsor Report a bug Make a pull request Jobs and funding Contribution guidelines Developers handbook Translations
  • Community
    Code of conduct Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendar
  • ♥ Donate

Donate

$
SEPA Information
Please set up your SEPA bank transfer to:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank agency: BNP Paribas Fortis
Address: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Macro Apothem Based Prism GUI

{{Macro |Name=Apothem Based Prism |Icon=Part Prism Apothem.svg |Description=This macro will present the user with a dialog to provide the distance between centers, the number of sides, and height and will create a prism based on the apothem, or inradius of a polygon. This can be extremely handy when one only knows the distance between flats. An example of this would be hexagonal stock of plastics or metal provided by vendors. Most vendors define such stock by the distance between flats. If one is using such stock in their projects, this Macro can be a real time saver. |Author=Quick61 |Version=1.0 |Date=2014-12-31 |Download=[https://www.freecadweb.org/wiki/https://raw.githubusercontent.com/FreeCAD/FreeCAD-documentation/master/wiki/images/4/4e/Part_Prism_Apothem.svg ToolBar Icon] |FCVersion=All }}

Description

This macro will present the user with a dialog to provide the distance between centers, the number of sides, and height and will create a prism based on the apothem, or inradius of a polygon. This can be extremely handy when one only knows the distance between flats. An example of this would be hexagonal stock of plastics or metal provided by vendors. Most vendors define such stock by the distance between flats. If one is using such stock in their projects, this Macro can be a real time saver.

How To Use

Copy the Macro into your FreeCAD Macro directory. Then either run the macro from the Execute Macro dialog or create a shortcut to use from your custom toolbar.

When run, the Macro wil present the user with a dialog like seen below. First enter the desired distance between flats. This can be any number and can include a decimal value, it will not take fractional input. Next enter the number of sides. This number is a whole number and should be an even number as well for proper results. Lastly enter the height you wish the prism to be. Again, this can be any number and can include a decimal value. Click OK and the prism will be created in your document.

The Macro

ToolBar Icon

Macro_Apothem_Based_Prism_GUI.FCMacro

{{MacroCode|code=

# # # # # # # # #

Apothem Based Prism

This script will take the input of the distance between flats, (apothem, aka inradius),

and the number of sidesfor a regular polygon along with a height and produce a

correctly sized prism derived from the circumradius.

# # # # # # # # #

import FreeCAD, FreeCADGui, Part, PartGui, math from FreeCAD import Base from PySide import QtGui, QtCore from math import cos, radians App = FreeCAD Gui = FreeCADGui

class p():

def priSm(self):

    try:
        dbf = float(self.d1.text())
        nos = int(self.d2.text())
        hth = float(self.d3.text())
        aR = dbf / 2
        op1 = 180/float(nos)
        coS = cos(math.radians(op1))
        cR = aR / coS
        prism=App.ActiveDocument.addObject("Part::Prism","Prism")
        prism.Polygon=nos
        prism.Circumradius=cR
        prism.Height=hth
        prism.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
        prism.Label='Prism'
        App.ActiveDocument.recompute()
        Gui.SendMsgToActiveView("ViewFit")
    except:
        FreeCAD.Console.PrintError("Unable to complete task")

        self.close()

def close(self):
    self.dialog.hide()

Make dialog box and get input for distance between flats, number of sides, and height

def __init__(self):
    self.dialog = None

    self.dialog = QtGui.QDialog()
    self.dialog.resize(280,110)

    self.dialog.setWindowTitle("Apothem Based Prism")
    la = QtGui.QVBoxLayout(self.dialog)

    iN1 = QtGui.QLabel("Distance Between Flats")
    la.addWidget(iN1)
    self.d1 = QtGui.QLineEdit()
    la.addWidget(self.d1)

    iN2 = QtGui.QLabel("Number Of Sides (Best results - use even numbers)")
    la.addWidget(iN2)
    self.d2 = QtGui.QLineEdit()
    la.addWidget(self.d2)

    iN3 = QtGui.QLabel("Prism Height")
    la.addWidget(iN3)
    self.d3 = QtGui.QLineEdit()
    la.addWidget(self.d3)

    okbox = QtGui.QDialogButtonBox(self.dialog)
    okbox.setOrientation(QtCore.Qt.Horizontal)
    okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel{{!}}

QtGui.QDialogButtonBox.Ok)

       la.addWidget(okbox)        QtCore.QObject.connect(okbox, QtCore.SIGNAL("accepted()"), self.priSm)        QtCore.QObject.connect(okbox, QtCore.SIGNAL("rejected()"), self.close)        QtCore.QMetaObject.connectSlotsByName(self.dialog)        self.dialog.show()        self.dialog.exec_()

p() }}

Additions

SVG icon for use in custom toolbar shortcut.

Acknowledgements

A thanks to FreeCAD main developer shoogen and FreeCAD programmer wandererfan for their invaluable help and advice in constructing this Macro.


⏵ documentation index > Macro Apothem Based Prism GUI

This page is retrieved from https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Macro_Apothem_Based_Prism_GUI.md

Get in touch!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© The FreeCAD Team. Homepage image credits (top to bottom): ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

This project is supported by: , KiCad Services Corp. and other sponsors

GitHubImprove this page on GitHub