155 lines
7.0 KiB
HTML
155 lines
7.0 KiB
HTML
<html><head><title>Macro CenterFace/de</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/de</h1></div>
|
|
|
|
<div id="mw-content-text" lang="de" 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="Macro_CenterFace"><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> Macro CenterFace</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Beschreibung
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left">This macro red trace (editable) the center face (mass) with 1 point and print the coordinates.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Autor
|
|
</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/de" title="Macros recipes/de">Liste von Macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/de" title="How to install macros/de">How to install macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/de" title="Customize Toolbars/de">How to customize toolbars</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">0.1
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Datum zuletzt geändert
|
|
</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="#Macro_CenterFace"><span class="tocnumber">1</span> <span class="toctext">Macro CenterFace</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">2</span> <span class="toctext">Description</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#Use"><span class="tocnumber">3</span> <span class="toctext">Use</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Icone"><span class="tocnumber">4</span> <span class="toctext">Icone</span></a></li>
|
|
<li class="toclevel-1 tocsection-4"><a href="#Script"><span class="tocnumber">5</span> <span class="toctext">Script</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Description">Description</span></h2>
|
|
<p>This macro red trace (editable) the center face (mass) with 1 point and print the coordinates.
|
|
</p><p><br />
|
|
<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>
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Use">Use</span></h2>
|
|
<p>Select one face and launch the macro. 1 point to face are coloured red (can be changed).
|
|
</p><p>To change the color of the dot change the lines 36, 37, 38
|
|
</p>
|
|
<pre>red = 1.0 # 1 = 255
|
|
green = 0.0 #
|
|
blue = 0.0 # </pre>
|
|
<p>The center of the face (mass) surface and the XYZ coordinates of the face are displayed in the report view.
|
|
</p>
|
|
<h2><span class="mw-headline" id="Icone">Icone</span></h2>
|
|
<p>Download the file image and copy in your macro repertory.
|
|
</p><p>Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ..."
|
|
</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/de&oldid=240939">http://www.freecadweb.org/wiki/index.php?title=Macro_CenterFace/de&oldid=240939</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> |