Macro CenterFace/cs: Difference between revisions
Renatorivo (talk | contribs) (Created page with "Macro CenterFace") |
Renatorivo (talk | contribs) (Created page with "{{Macro/cs|Icon=Text-x-python|Name=Macro CenterFace|Name/cs=Macro CenterFace|Description=This macro red trace (editable) the center face (mass) with 1 point and print the coor...") |
||
Line 1: | Line 1: | ||
{{Macro|Icon=Text-x-python|Name=Macro CenterFace|Description=This macro red trace (editable) the center face (mass) with 1 point and print the coordinates.|Author=Mario52}} |
{{Macro/cs|Icon=Text-x-python|Name=Macro CenterFace|Name/cs=Macro CenterFace|Description=This macro red trace (editable) the center face (mass) with 1 point and print the coordinates.|Author=Mario52}} |
||
==Description== |
==Description== |
Revision as of 19:55, 23 July 2014
File:Text-x-python Macro CenterFace |
Popis |
---|
This macro red trace (editable) the center face (mass) with 1 point and print the coordinates. Autor: Mario52 |
Autor |
Mario52 |
Download |
None |
Odkazy |
Makro recepty| Jak nainstalovat makra Jak přizpůsobit panely nástrojů |
Verze |
1.0 |
Datum poslední úpravy |
None |
Verze FreeCAD |
None |
Výchozí zástupce |
None |
Viz též |
None |
Description
This macro red trace (editable) the center face (mass) with 1 point and print the coordinates.
Use
Select one face and launch the macro. 1 point to face are colored red (can be changed).
To change the color of the dot change the lines 36, 37, 38
red = 1.0 # 1 = 255
green = 0.0 #
blue = 0.0 #
The center of the face (mass) surface and the XYZ coordinates of the face are displayed in the report view.
Macro
Macro_CenterFace.FCMacro
# -*- 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")