151 lines
6.9 KiB
HTML
151 lines
6.9 KiB
HTML
<html><head><title>Macro CenterFace/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 CenterFace/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="Centro_faccia"><a href="https://www.freecadweb.org/wiki/index.php?title=File:CenterFace.png" class="image"><img alt="CenterFace.png" src="32px-CenterFace.png" width="32" height="32" srcset="/wiki/images/thumb/1/16/CenterFace.png/48px-CenterFace.png 1.5x, CenterFace.png 2x" /></a> Centro faccia</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Descrizione
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">Questa macro marca con un punto rosso (modificabile) il centro della faccia (massa) e stampa le sue coordinate.
|
|
</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.1
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Data ultima modifica
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-date">2014-04-29
|
|
</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="#Centro_faccia"><span class="tocnumber">1</span> <span class="toctext">Centro faccia</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Uso"><span class="tocnumber">2</span> <span class="toctext">Uso</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Icone"><span class="tocnumber">3</span> <span class="toctext">Icone</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p><p>Questa macro marca con un punto rosso (modificabile) il centro della faccia (massa) e stampa le sue coordinate
|
|
</p><p><br />
|
|
</p>
|
|
<a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_CenterFace_00.png" class="image" title="CenterFace"><img alt="CenterFace" src="480px-Macro_CenterFace_00.png" width="480" height="311" srcset="/wiki/images/thumb/3/37/Macro_CenterFace_00.png/720px-Macro_CenterFace_00.png 1.5x, /wiki/images/3/37/Macro_CenterFace_00.png 2x" /></a> <div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Uso">Uso</span></h2>
|
|
<p>Selezionare una faccia e lanciare la macro. Sulla faccia appare un punto di colore rosso (il colore può essere modificato).
|
|
</p><p>Per cambiare il colore del punto modificare le righe 36, 37, 38
|
|
</p>
|
|
<pre>red = 1.0 # 1 = 255
|
|
green = 0.0 #
|
|
blue = 0.0 # </pre>
|
|
<p>Il centro della superficie della faccia (massa) e le sue coordinate XYZ vengono visualizzati nella vista report.
|
|
</p>
|
|
<h2><span class="mw-headline" id="Icone">Icone</span></h2>
|
|
<p>Scaricare le immagini e copiarle nel repertorio delle macro.
|
|
</p><p>Cliccare sull'immagine con il tasto destro del mouse e salvarla nella nuova posizione selezionando "Salva oggetto con nome ..."
|
|
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:CenterFace.png" class="image" title="Button"><img alt="Button" src="CenterFace.png" width="64" height="64" /></a>
|
|
</p>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<p><b>Macro_CenterFace.FCMacro</b>
|
|
</p>
|
|
<pre># -*- coding: utf-8 -*-
|
|
# 29/04/2014
|
|
# select a face launch and list the center coordinate XYZ of face
|
|
# To change the color of the dot change the lines 36, 37, 38
|
|
# red = 1.0 # 1 = 255
|
|
# green = 0.0 #
|
|
# blue = 0.0 #
|
|
# Macro_CenterFace
|
|
# Mario52
|
|
|
|
#OS: Windows Vista
|
|
#Platform: 32-bit
|
|
#Version: 0.14.3389
|
|
#Python version: 2.6.2
|
|
#Qt version: 4.5.2
|
|
#Coin version: 3.1.0
|
|
#SoQt version: 1.4.1
|
|
#OCC version: 6.5.1
|
|
|
|
import FreeCAD, FreeCADGui, Draft, Part
|
|
|
|
try:
|
|
sel = FreeCADGui.Selection.getSelection() # get the selection
|
|
sh = sel[0].Shape # seletion of the first element
|
|
|
|
App.Console.PrintMessage("Label : "+ str(sel[0].Label)+"\n") # extract the Label
|
|
App.Console.PrintMessage("Name  : "+ str(sel[0].Name) +"\n") # extract the Name
|
|
except:
|
|
App.Console.PrintError( "select a face"+"\n")
|
|
|
|
|
|
try:
|
|
SubElement = FreeCADGui.Selection.getSelectionEx()# "getSelectionEx" Used for selecting subobjects
|
|
element_ = SubElement[0].SubElementNames[0] # seletion of the first element
|
|
|
|
# print element_
|
|
# print sh.Faces
|
|
|
|
# LineColor
|
|
red = 1.0 # 1 = 255
|
|
green = 0.0 #
|
|
blue = 0.0 #
|
|
|
|
for i in range(len(sh.Faces)): # list and extract the data
|
|
App.Console.PrintMessage( "Center Face "+str(i)+" "+str(sh.Faces[i].CenterOfMass)+"\n") # Vector center mass to face
|
|
# print "X : ",sh.Faces[i].CenterOfMass.x # Coord. X center mass to face
|
|
# print "Y : ",sh.Faces[i].CenterOfMass.y # Coord. Y center mass to face
|
|
# print "Z : ",sh.Faces[i].CenterOfMass.z # Coord. Z center mass to face
|
|
Draft.makePoint(sh.Faces[i].CenterOfMass.x,sh.Faces[i].CenterOfMass.y,sh.Faces[i].CenterOfMass.z) # create a point
|
|
FreeCADGui.activeDocument().activeObject().PointColor = (red, green, blue)
|
|
|
|
App.Console.PrintMessage( " Surface  : "+str(sel[0].Shape.Faces[i-1].Area)+"\n")
|
|
fco = 0
|
|
for f0 in sel[0].Shape.Faces[i].Vertexes: # Vertexes faces
|
|
fco += 1
|
|
App.Console.PrintMessage(" Vertexe X"+str(fco)+": "+str(f0.Point.x)+" Y"+str(fco)+": "+str(f0.Point.y)+" Z"+str(fco)+": "+str(f0.Point.z)+"\n")
|
|
|
|
except:
|
|
App.Console.PrintError( "select a face *"+"\n") </pre>
|
|
<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_CenterFace/it&oldid=240933">http://www.freecadweb.org/wiki/index.php?title=Macro_CenterFace/it&oldid=240933</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> |