191 lines
9.7 KiB
HTML
191 lines
9.7 KiB
HTML
<html><head><title>Macro Circle/it</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 Circle/it</h1></div>
|
|
|
|
<div id="mw-content-text" lang="it" 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="Cerchio"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Cerchio</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Descrizione
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">Crea un cerchio o un arco basato su parametri.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Autore
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">mario52</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Link
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Versione
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">0.2
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Data ultima modifica
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2018-06-10
|
|
</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="#Cerchio"><span class="tocnumber">1</span> <span class="toctext">Cerchio</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Descrizione"><span class="tocnumber">2</span> <span class="toctext">Descrizione</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Uso"><span class="tocnumber">3</span> <span class="toctext">Uso</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
|
|
<li class="toclevel-1 tocsection-4"><a href="#Promemoria_sulle_circonferenze"><span class="tocnumber">5</span> <span class="toctext">Promemoria sulle circonferenze</span></a></li>
|
|
<li class="toclevel-1 tocsection-5"><a href="#Versione"><span class="tocnumber">6</span> <span class="toctext">Versione</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Descrizione">Descrizione</span></h2>
|
|
<p>Questa piccola macro crea un cerchio o un arco fornendo a scelta raggio, diametro, circonferenza, area, angolo iniziale, angolo finale, lunghezza dell'arco, angolo al centro, corda, freccia, centro, placemObject.
|
|
</p><p>Il cerchio viene posto frontale allo schermo, con getCameraOrientation, oppure secondo il posizionamento dato
|
|
</p>
|
|
<h2><span class="mw-headline" id="Uso">Uso</span></h2>
|
|
<p>Copiare il codice e incollarlo nella console Python di FreeCAD, la funzione sarà disponibile per tutta la sessione (è anche possibile utilizzare questo codice in una macro). Assegnare a scelta i parametri:
|
|
</p>
|
|
<ul><li> <b>x y z</b> : coordinate del cerchio, se non sono attribuite, il cerchio viene creato alle coordinate 0,0,0</li>
|
|
<li><b>radius</b> : raggio del cerchio</li>
|
|
<li><b>diameter</b> : diametro del cerchio</li>
|
|
<li><b>circumference</b> : circonferenza del cerchio</li>
|
|
<li><b>area</b> : area del cerchio</li>
|
|
<li><b>startangle</b> : angolo iniziale di un arco</li>
|
|
<li><b>endangle</b> : angolo finale di un arco</li>
|
|
<li><b>arc</b> e <b>anglecenter</b> : arco in combinazione con anglecenter
|
|
<ul><li> <b>arc</b> = lunghezza di un arco</li>
|
|
<li> <b>anglecenter</b> = angolo al centro di un arco, in gradi</li></ul></li>
|
|
<li><b>cord</b> e <b>arrow</b> : corda in combinazione con la freccia
|
|
<ul><li> <b>cord</b> : lunghezza della corda </li>
|
|
<li> <b>arrow</b> : lunghezza della freccia </li></ul></li>
|
|
<li><b>center</b> : se "center" è diverso da 0 viene creato un punto al centro del cerchio</li>
|
|
<li><b>placemObject</b>
|
|
<ul><li> esempio :</li>
|
|
<li> pl=FreeCAD.Placement()</li>
|
|
<li> pl.Rotation.Q=(0.0,-0.0,-0.0,1.0)</li>
|
|
<li> pl.Base=FreeCAD.Vector(-1.89847898483,-0.490152746439,0.0)</li>
|
|
<li> give <b>placemObject = pl</b></li></ul></li></ul>
|
|
<p>Se non vengono forniti dei parametri, ad esempio "<b>circle()</b>", nella vista Report viene visualizzato l'elenco delle funzioni disponibili.
|
|
<br /><br />
|
|
<b>Esempi di fornitura di parametri:</b>
|
|
</p>
|
|
<pre>circle(arc=50,anglecenter=20,center=1)
|
|
circle(cord = 100,arrow = 20,center=1)
|
|
circle(circumference = 100,center=1) </pre>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<p><b>Macro_circle.FCMacro</b>
|
|
</p>
|
|
<pre># -*- coding: utf-8 -*-
|
|
# creer un cercle ou un arc entierement parametrabel en utilisant :
|
|
# create a circle or arc fully parametrabel using:
|
|
# x x x coordinates
|
|
#with radius
|
|
#with diameter
|
|
#with circumference
|
|
#with area
|
|
#with startangle
|
|
#with endangle
|
|
#with [arc and anglecenter] in combination (angle in degrees)
|
|
#with [cord and arrow] in combination
|
|
#with center (if center as different 0 one point is created on center of circle)
|
|
#give placemObject
|
|
# ex :pl=FreeCAD.Placement()
|
|
# pl.Rotation.Q=(0.0,-0.0,-0.0,1.0)
|
|
# pl.Base=FreeCAD.Vector(-1.89847898483,-0.490152746439,0.0)
|
|
# placemObject = pl
|
|
# s'il n'y a pas de parametre "circle()" une liste des fonctions s'affiche dans la Vue rapport
|
|
# if there is no parameter "circle()" a list of functions is displayed in the report view
|
|
|
|
__title__ = "circle"
|
|
__author__ = "Mario52"
|
|
__date__ = "10/06/2018"
|
|
|
|
import Draft #, Part
|
|
def circle(x=0.0,y=0.0,z=0.0,radius=0.0,diameter=0.0,circumference=0.0,area=0.0,startangle=0.0,endangle=0.0,arc=0.0,anglecenter=0.0,cord=0.0,arrow=0.0,center=0,placemObject=""):
|
|
from math import sqrt, pi
|
|
if placemObject == "":
|
|
pl = FreeCAD.Placement()
|
|
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
|
|
pl.Base = FreeCAD.Vector(x,y,z)
|
|
else:
|
|
pl = placemObject # placement imposted
|
|
|
|
if diameter != 0: # with diameter
|
|
radius = diameter / 2.0
|
|
elif circumference != 0: # with circumference
|
|
radius = (circumference / pi) / 2.0
|
|
elif area != 0: # with area
|
|
radius = sqrt((area / pi))
|
|
elif (cord != 0) and (arrow != 0): # with cord and arrow
|
|
radius = ((arrow**2) + (cord**2) / 4.0) / (arrow*2)
|
|
elif (arc != 0) and (anglecenter != 0): # with arc and anglecenter central in degrees
|
|
radius = ((360/anglecenter)*arc) / pi/2.0
|
|
if endangle != 0:
|
|
startangle = endangle - anglecenter
|
|
endangle = anglecenter + startangle
|
|
startangle = endangle - anglecenter
|
|
|
|
if radius != 0:
|
|
try:
|
|
Draft.makeCircle(radius,placement=pl,face=False,startangle=startangle,endangle=endangle,support=None)
|
|
if center != 0:
|
|
Draft.makePoint(x,y,z)
|
|
except Exception:
|
|
App.Console.PrintError("Unexpected keyword argument" + "\n")
|
|
else:
|
|
App.Console.PrintMessage("Unexpected keyword argument" + "\n")
|
|
App.Console.PrintMessage("circle(x,y,z,radius,diameter,circumference,area,startangle,endangle,[arc,anglecenter],[cord,arrow],center,placemObject)" + "\n")
|
|
|
|
#example
|
|
#circle(arc=50,anglecenter=20,center=1) </pre>
|
|
<h2><span class="mw-headline" id="Promemoria_sulle_circonferenze">Promemoria sulle circonferenze</span></h2>
|
|
<p><b>Esempi di codice</b>
|
|
</p>
|
|
<pre>circle(radius=10) # example 1
|
|
circle(x=15,diameter=20) # example 2
|
|
circle(y=45,circumference=100) # example 3 </pre>
|
|
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Circle_01.png" class="image" title="examples 1, 2, 3"><img alt="examples 1, 2, 3" src="640px-Macro_Circle_01.png" width="640" height="293" srcset="/wiki/images/6/61/Macro_Circle_01.png 1.5x" /></a></div></div>
|
|
<div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<pre>circle(y=-15,area=100) # example 4
|
|
circle(y=-15,x=15,startangle=60,endangle=-20,center=1) # example 5
|
|
circle(y=-15,x=45,cord=9,arrow=3,center=1) # example 6 left
|
|
circle(x=65,y=-15,arc=3.5,anglecenter=40,startangle=20,center=1) # example 6 rigth </pre>
|
|
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Circle_02.png" class="image" title="examples"><img alt="examples" src="640px-Macro_Circle_02.png" width="640" height="293" srcset="/wiki/images/2/23/Macro_Circle_02.png 1.5x" /></a></div></div>
|
|
<div style="clear:both"></div>
|
|
<h2><span class="mw-headline" id="Versione">Versione</span></h2>
|
|
<p>ver 0.3 10/06/2018 : replace /2 to /2.0 (float)
|
|
</p><p>ver 0.2 24/02/2015 : agiunto function "<b>placemObject</b>"
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Circle/it&oldid=288435">http://www.freecadweb.org/wiki/index.php?title=Macro_Circle/it&oldid=288435</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> |