179 lines
8.6 KiB
HTML
179 lines
8.6 KiB
HTML
<html><head><title>Macro Apothem Based Prism GUI/fr</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Apothem Based Prism GUI/fr</h1></div>
|
|
|
|
<div id="mw-content-text" lang="fr" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
|
|
<tr>
|
|
<td class="ctTitle">
|
|
<h3><span class="mw-headline" id="Apothem_Based_Prism"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Part_Prism_Apothem.png" class="image"><img alt="Part Prism Apothem.png" src="32px-Part_Prism_Apothem.png" width="32" height="32" srcset="/wiki/images/thumb/0/0f/Part_Prism_Apothem.png/48px-Part_Prism_Apothem.png 1.5x, /wiki/images/0/0f/Part_Prism_Apothem.png 2x" /></a> Apothem Based Prism</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Description
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">A GUI dialog that creates an Apothem, (inradius) Based Prism from user input.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Auteur
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Quick61" title="User:Quick61">Quick61</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Liens
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/fr" title="Macros recipes/fr">Recettes macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/fr" title="How to install macros/fr">Comment installer une macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/fr" title="Customize Toolbars/fr">Comment ajouter une barre d'outils</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">1.0
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Date dernière modification
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2014-12-31
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1"><a href="#Apothem_Based_Prism"><span class="tocnumber">1</span> <span class="toctext">Apothem Based Prism</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Apothem_Based_Prism_2"><span class="tocnumber">2</span> <span class="toctext">Apothem Based Prism</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-2"><a href="#Description"><span class="tocnumber">2.1</span> <span class="toctext">Description</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Utilisation"><span class="tocnumber">3</span> <span class="toctext">Utilisation</span></a></li>
|
|
<li class="toclevel-1 tocsection-4"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
|
|
<li class="toclevel-1 tocsection-5"><a href="#Ajouts"><span class="tocnumber">5</span> <span class="toctext">Ajouts</span></a></li>
|
|
<li class="toclevel-1 tocsection-6"><a href="#Remerciements"><span class="tocnumber">6</span> <span class="toctext">Remerciements</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Apothem_Based_Prism_2"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Part_Prism_Apothem.svg" class="image"><img alt="Part Prism Apothem.svg" src="Part_Prism_Apothem.svg" width="64" height="64" /></a>Apothem Based Prism</span></h2>
|
|
<h3><span class="mw-headline" id="Description">Description</span></h3>
|
|
<p>Cette macro présente à l'utilisateur une fenêtre de dialogue pour fournir la distance entre les centres, le nombre de côtés, et la hauteur permettra de créer un prisme sur la base du apothème ou in radius d'un polygone.
|
|
</p>
|
|
<h2><span class="mw-headline" id="Utilisation">Utilisation</span></h2>
|
|
<p>Copiez la macro dans votre répertoire des macros. lancez la macro ou créez un bouton raccourci dans une barre d'outils.
|
|
</p><p>Lorsqu'elle est exécuté, le Macro présente à l'utilisateur une boîte de dialogue comme illustrée ci-dessous. Entrez d'abord la distance souhaitée entre les alvéoles. Cela peut être un nombre quelconque et peut inclure une valeur décimale, la macro ne reconnait pas les entrées fractionnaires. Ensuite, entrez le nombre de côtés. Ce nombre est un nombre entier et doit être un nombre pair pour des résultats corrects. Enfin entrez la hauteur que vous souhaitez donner au prisme. Encore une fois, cela peut être un nombre quelconque et peut inclure une valeur décimale. Cliquez sur OK et le prisme sera créé dans votre document.
|
|
</p>
|
|
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:ABP_Screenshot.png" class="image"><img alt="ABP Screenshot.png" src="ABP_Screenshot.png" width="364" height="286" /></a></div></div>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<pre># # # # # # # # # # #
|
|
#
|
|
# 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() </pre>
|
|
<h2><span class="mw-headline" id="Ajouts">Ajouts</span></h2>
|
|
<p>Le fichier icône SVG pour utiliser dans votre barre d'outils.
|
|
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Part_Prism_Apothem.svg" class="image"><img alt="Part Prism Apothem.svg" src="Part_Prism_Apothem.svg" width="128" height="128" /></a>
|
|
</p>
|
|
<h2><span class="mw-headline" id="Remerciements">Remerciements</span></h2>
|
|
<p>Remerciement à <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/memberlist.php?mode=viewprofile&u=765">shoogen</a> développeur et à <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/memberlist.php?mode=viewprofile&u=1375">wandererfan</a> pour leur aide précieuse et les conseils dans la mise au point de cette macro.
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Apothem_Based_Prism_GUI/fr&oldid=240727">http://www.freecadweb.org/wiki/index.php?title=Macro_Apothem_Based_Prism_GUI/fr&oldid=240727</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |