Macro FCInfoGlass: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Fixed icon location for Addon Manager.)
 
(30 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>

<!--T:1-->
<!--T:1-->
{{Macro
{{Macro|Icon=Macro_FCInfoGlass|Name=Macro FCInfoGlass|Description=Gives a series of information on the form display in the 3D view.|Author=Mario52}}
|Name=Macro FCInfoGlass
|Description=Gives a series of information on the form display in the 3D view.
|Author=Mario52
|Download=[https://wiki.freecad.org/images/6/6b/Macro_FCInfoGlass.png ToolBar Icon]
|Version=00.05
|Date=2016-08-28
|SeeAlso=[[Arch_Survey|Arch Survey]]
}}


<!--T:2-->
==Description== <!--T:2-->

<!--T:43-->
Gives a series of informations about the selected shape and can display a directly in the 3D view
Gives a series of informations about the selected shape and can display a directly in the 3D view


</translate>
{{Codeextralink|https://gist.githubusercontent.com/mario52a/553b1fc7a8ca5bfa44c6/raw/fc57ec0869a8f68ce396acbaed5e87f396426186/Macro_FCInfoGlass.FCMacro}}
<translate>


</translate>
[[File:Macro_FCTransparentInfo_00.FCMacro.png|480px]]
<translate>
<!--T:3-->
<!--T:3-->
{{Caption|FCInfoGlass}}
[[File:Macro_FCTransparentInfo_00.FCMacro.png|480px|FCInfoGlass]]

==Utilisation== <!--T:44-->


===Utilisation=== <!--T:4-->
<!--T:4-->
Select an object or launch the application and select an object, and a series of informations appear on the 3D View.
Select an object or launch the application and select an object, and a series of informations appear on the 3D View.


<!--T:5-->
<!--T:5-->
Modify this line to move the data display in the screen (lines 147, 148)
'''Modify this line''' to move the data display in the screen (lines 84, 85)
</translate>
</translate>
{{Code|code=
<syntaxhighlight>
posiX = 300 # position window coordinate X
global posiX ; posiX = 900 # position window coordinate X "defaut = 900"
posiY = 190 # position window coordinate Y
global posiY ; posiY = 190 # position window coordinate Y "defaut = 190"
}}
</syntaxhighlight>
<translate>
<translate>
<!--T:6-->
<!--T:6-->
* 300, 190 = position X, Y upper left corner
* 900, 190 = position X, Y upper left corner

<!--T:22-->
'''Modify this line''' for change color (line 92)
</translate>

{{Code|code=
#######################################################################
# Section color #
global colorize ; colorize ="black" # colorize the text choice "defaut = "black"
# "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan"

}}
<translate>
==Examples:== <!--T:23-->

<!--T:24-->
Availlable : ''' "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan" '''
<center>
<gallery widths="300" heights="300">
Image:Macro FCInfoGlass 01.png|'''colorize ="black"'''
Image:Macro FCInfoGlass 02.png|'''colorize ="white"'''
</gallery>
</center>
{{clear}}
<center>
<gallery widths="300" heights="300">
Image:Macro FCInfoGlass 03.png|'''colorize ="red"'''
Image:Macro FCInfoGlass 04.png|'''colorize ="yellow"'''
</gallery>
</center>
{{clear}}


<!--T:14-->
<!--T:14-->
This section hare switch give value 1 for displayed the info or 0 for not displayed the info
This section hare switch give value '''1''' for displayed the info or '''0''' for not displayed the info


<!--T:15-->
<!--T:15-->
'''EX:'''
'''Example:'''


<!--T:16-->
<!--T:16-->
is displayed
is displayed ( = '''1''' )


</translate>
</translate>
{{Code|code=
<syntaxhighlight>
global LabelObject ;LabelObject = 1 # Label #3
global LabelObject ;LabelObject = 1 # Label #3 Label Object
}}
</syntaxhighlight>
<translate>
<translate>
<!--T:19-->
is not displayed
is not displayed ( = '''0''' )
</translate>
</translate>
{{Code|code=
<syntaxhighlight>
global LabelObject ;LabelObject = 0 # Label #3
global LabelObject ;LabelObject = 0 # Label #3 Label Object
}}
</syntaxhighlight>
<translate>
<translate>
<!--T:20-->
The section lines 84 to 102
The section lines 79 to 171


</translate>
<syntaxhighlight>
{{Code|code=
################################################
#######################################################################
global visualiserWindow ; visualiserWindow = 0 # si visualiserWindow = 1 la fenetre est visible (pour test) "defaut = 0"
# if visualiserWindow = 1 the windows is visible (for test) "default = 0"
###Section Configuration ##############################################
# Placement window hidden #
global posiX ; posiX = 900 # position window coordinate X "defaut = 900"
global posiY ; posiY = 190 # position window coordinate Y "defaut = 190"
#######################################################################
global SizeX ; SizeX = 600 # size window length (do not modify) "defaut = 600"
global SizeY ; SizeY = 600 # size window heigth (do not modify) "defaut = 600"


#######################################################################
# Section color #
global colorize ; colorize ="black" # colorize the text choice "defaut = "black"
# "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan"


#######################################################################
# Section inter #
global mode ; mode = 1 # mode 1=degrees mode 0=radians "defaut = 1"
global arondi ; arondi = 4 # many numbers after the decimal point "defaut = 4"
global chaineRemplacement ; chaineRemplacement = "_" # replacement string (1 character) "defaut = "_"


#######################################################################
# section switch
# section switch
# if switch = 1 then actif (True Displayed) else inactif (False not Displayed)
# if switch = 1 then actif (True Displayed) else inactif (False not Displayed)
global DocumentName ;DocumentName = 1 # Nom du document #1
global PrintReportView ;PrintReportView = 1 # Affichage dans la vue rapport #0 Displayed ReportView
##
global InternalName ;InternalName = 1 # Nom interne de l'objet #2
global LabelObject ;LabelObject = 1 # Label #3
global DocumentName ;DocumentName = 1 # Nom du document #1 Document Name
global ElementName ;ElementName = 1 # Nom de l'element #4
global InternalName ;InternalName = 1 # Nom interne de l'objet #2 Internal Name
global ObjectType ;ObjectType = 1 # Type d'objet #5
global LabelObject ;LabelObject = 1 # Label #3 Label Object
global ObjectLength ;ObjectLength = 1 # longueur Objet #6
global ElementName ;ElementName = 1 # Nom de l'element #4 Element Name
global FaceSurface ;FaceSurface = 1 # Surface de la face #7
global ObjectType ;ObjectType = 1 # Type d'objet #5 Object Type
global FaceCenter ;FaceCenter = 1 # Center Face (mass) #8
global LineSeparateTitle ;LineSeparateTitle = 1 # ligne de separation des titres ____________ #6 Line Separate of Title
global BoundBoxFaceVol ;BoundBoxFaceVol = 1 # BoundBoxFace Volume #9
global BoundBoxFaceCoor;BoundBoxFaceCoor = 1 # BoundBoxFace coordinates #10
global BoundBoxFaceC ;BoundBoxFaceC = 1 # BoundBoxFaceCenter #11
global VolumeObject ;VolumeObject = 1 # volume #12
global BounboxVolume ;BounboxVolume = 1 # rectangle du BoundBox #13
global BounboxCoord ;BounboxCoord = 1 # boundinbox (dimensions hors tout) #14
global BounboxCenter ;BounboxCenter = 1 # centre de la forme #15
global CenterMass ;CenterMass = 1 # centre de la masse #16
global LineInclination ;LineInclination = 1 # search inclination XY YZ ZX uniquement lignes #17
global VertexesObject ;VertexesObject = 1 # Vertexes de l'objet selectionne #18
global VertexesForme ;VertexesForme = 0 # Vertexes complet de la forme #19
# peut prendre du temps, depasser la fenetre et donner des donnees incompletes
# can take time and exceed the window and give data's incompletes
################################################
</syntaxhighlight>


## Object subObject
<!--T:7-->
global ObjectLength ;ObjectLength = 1 # longueur Objet ou perimetre si c est une face #7 Object Length or perimetre if are a face
It is not possible at the moment to leave the function from the macro or scrolling
global ObjectCurveRadius ;ObjectCurveRadius = 1 # rayon du subObject si arc ou cerle #8 radius subObject if arc or cirle
global ObjectCurveCenter ;ObjectCurveCenter = 1 # coordonnees centrale subObject si arc ou cerle #9 coordinates center subObject if arc or cirle


## Draft
<!--T:8-->
global LineDimension ;LineDimension = 1 # Dimensions Line #10 Line Dimension
One mouse click on the object display the information of the object, two mouse click select the object complete and displayed alls informations
global DWireDimension ;DWireDimension = 1 # Dimensions DWire #11 DWire Dimension
global CircleDimension ;CircleDimension = 1 # Dimensions Circle #12 Circle Dimension
global CirclePartDimension ;CirclePartDimension = 1 # Dimensions Circle Part #13 Circle Part Dimension


global ArcDimension ;ArcDimension = 1 # Dimensions Arc #14 Arc Dimension
<!--T:9-->
global EllipseDimension ;EllipseDimension = 1 # Dimensions Ellipse #15 Ellipse Dimension
(it is possible you can not see everything informations in the window for the moment)
global EllipsePartDimension ;EllipsePartDimension = 1 # Dimensions Ellipse Part #16 Ellipse Part Dimension
global PolygonDimension ;PolygonDimension = 1 # Dimensions Polygon #17 Polygon Dimension
global RectangleDimension ;RectangleDimension = 1 # Dimensions Rectangle #18 Rectangle Dimension
global BSplineDimension ;BSplineDimension = 1 # Dimensions BSpline #19 BSpline Dimension
global PointDimension ;PointDimension = 1 # Dimensions Point #20 Point Dimension
global BezCurveDimension ;BezCurveDimension = 1 # Dimensions BezCurve #21 BezCurve Dimension


## Solid
===Script=== <!--T:10-->
global CylinderDimension ;CylinderDimension = 1 # Dimensions du Cylindre Rayon Hauteur Angle #22 Cylinder Dimension
</translate>
global BoxDimension ;BoxDimension = 1 # Dimensions du Box Length Width Height #23 Box Dimension
'''Macro_FCInfoGlass.FCMacro''' [[File:Macro_FCInfoGlass.png|64px|FCInfoGlass]]
global SphereDimension ;SphereDimension = 1 # Dimensions de la Sphere #24 Sphere Dimension
global EllipsoidDimension ;EllipsoidDimension = 1 # Dimensions Ellipsoid #25 Ellipsoid Dimension
global ConeDimension ;ConeDimension = 1 # Dimensions du Cone #26 Cone Dimension
global TorusDimension ;TorusDimension = 1 # Dimensions du Tore #27 Torus Dimension


## Part
<syntaxhighlight>
global PlanePartDimension ;PlanePartDimension = 1 # Dimensions Plan Part #28 Plane Part Dimension
global PrismPartDimension ;PrismPartDimension = 1 # Dimensions Prisme Part #29 Prism Part Dimension
global WedgePartDimension ;WedgePartDimension = 1 # Dimensions Wedge Part #30 Wedge Part Dimension
global HelixPartDimension ;HelixPartDimension = 1 # Dimensions Helix Part #31 Helix Part Dimension
global SpiralPartDimension ;SpiralPartDimension = 1 # Dimensions Spirale Part #32 Spiral Part Dimension
global VertexPartDimensio ;VertexPartDimension = 1 # Dimensions Vertex Part #33 Vertex Part Dimension
global LinePartDimension ;LinePartDimension = 1 # Dimensions Line Part #34 Line Part Dimension
global RegularPolygonPartDimension;RegularPolygonPartDimension = 1 # Dimensions RegularPolygon Part #35 Regular Polygon Part Dimension


## Face
global FaceSurface ;FaceSurface = 1 # Surface de la face #36 Face Surface
global NormalAt ;NormalAt = 1 # Donne la normale (inclinaison) #37 normalAt(0,0) Face and edges normalAt(0)
global FaceCenter ;FaceCenter = 1 # Center Face (mass) #38 Face Center
global BoundBoxFaceVol ;BoundBoxFaceVol = 1 # BoundBoxFace Volume #39 BoundBox Face Volume
global BoundBoxFaceCent ;BoundBoxFaceCent = 1 # BoundBoxFaceCenter #40 BoundBox Face Center
global BoundBoxFaceCoor ;BoundBoxFaceCoor = 1 # BoundBoxFace coordinates #41 BoundBox Face Coordinates


## Volume
# -*- coding: utf-8 -*-
global BounBoxVolumeVol ;BounBoxVolumeVol = 1 # rectangle du BoundBox #42 BounBox Volume Volume
from __future__ import unicode_literals
global BounBoxVolumeCent ;BounBoxVolumeCent = 1 # centre de la forme #43 BounBox Volume Center
"""
global BounBoxVolumeCoor ;BounBoxVolumeCoor = 1 # boundinbox (dimensions hors tout) #44 BounBox Volume Coordinates
***************************************************************************
* Copyright (c) 2015 <mario52> *
global VolumeObject ;VolumeObject = 1 # volume #45 Volume Object
* *
global CenterMass ;CenterMass = 1 # centre de la masse #46 Center Mass object
global PlacementForme ;PlacementForme = 1 # placement de la forme #47 Placement Forme
* This file is a supplement to the FreeCAD CAx development system. *
* *
global LineInclination ;LineInclination = 1 # search inclination XY YZ ZX uniquement lignes #48 Line Inclination
global VertexesObject ;VertexesObject = 1 # Vertexes de l'objet selectionne #49 Vertexes Object
* This program is free software; you can redistribute it and/or modify *
global VertexesForme ;VertexesForme = 0 # Vertexes complet de la forme #50 Vertexes Forme
* it under the terms of the GNU Lesser General Public License (LGPL) *
# peut prendre du temps, depasser la fenetre et donner des donnees incompletes
* as published by the Free Software Foundation; either version 2 of *
# can take time and exceed the window and give data's incompletes
* the License, or (at your option) any later version. *
### End Section Switch #######################################################################################################################
* for detail see the LICENCE text file. *
}}
* *
<translate>
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
#30/07/2015 04/08/2015
#
#OS: Windows 8
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.15.4671 (Git)
#Branch: releases/FreeCAD-0-15
#Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
#Python version: 2.7.8
#Qt version: 4.8.6
#Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17
#
__title__="FCInfoGlass"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02"
__date__ = "04/08/2015"
__Comment__ = "displays various information on the screen"
__Web__ = ""
__Wiki__ = ""
__Icon__ = "/usr/lib/freecad/Mod/plugins/icons/.png"
__IconW__ = "C:/Documents and Settings/YourUserName/Application Data/FreeCAD"
__Help__ = ""
__Status__ = "not finished"
__Requires__ = "FreeCAD 0.14.3706"
__Communication__ = "http://www.freecadweb.org/wiki/index.php?title=User:Mario52"
try:
import PyQt4
from PyQt4 import QtGui ,QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import *
except Exception:
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD
from math import degrees, radians, atan2, sqrt, pi, sin, cos, asin, acos, atan
from FreeCAD import Base
global path
#path = FreeCAD.ConfigGet("AppHomePath")
path = FreeCAD.ConfigGet("UserAppData")


<!--T:7-->
global compteur ; compteur = 0 # compteur objets
After a change save the macro and run
global texteInfo ; texteInfo = ""# texte
global mode ; mode = 1 # mode 1=degres mode 0=radians


<!--T:33-->
################################################
It is not possible at the moment to leave the function from the macro or scrolling
# section switch
# if switch = 1 then actif (True Displayed) else inactif (False not Displayed)
global DocumentName ;DocumentName = 1 # Nom du document #1
global InternalName ;InternalName = 1 # Nom interne de l'objet #2
global LabelObject ;LabelObject = 1 # Label #3
global ElementName ;ElementName = 1 # Nom de l'element #4
global ObjectType ;ObjectType = 1 # Type d'objet #5
global ObjectLength ;ObjectLength = 1 # longueur Objet #6
global FaceSurface ;FaceSurface = 1 # Surface de la face #7
global FaceCenter ;FaceCenter = 1 # Center Face (mass) #8
global BoundBoxFaceVol ;BoundBoxFaceVol = 1 # BoundBoxFace Volume #9
global BoundBoxFaceCoor;BoundBoxFaceCoor = 1 # BoundBoxFace coordinates #10
global BoundBoxFaceC ;BoundBoxFaceC = 1 # BoundBoxFaceCenter #11
global VolumeObject ;VolumeObject = 1 # volume #12
global BounboxVolume ;BounboxVolume = 1 # rectangle du BoundBox #13
global BounboxCoord ;BounboxCoord = 1 # boundinbox (dimensions hors tout) #14
global BounboxCenter ;BounboxCenter = 1 # centre de la forme #15
global CenterMass ;CenterMass = 1 # centre de la masse #16
global LineInclination ;LineInclination = 1 # search inclination XY YZ ZX uniquement lignes #17
global VertexesObject ;VertexesObject = 1 # Vertexes de l'objet selectionne #18
global VertexesForme ;VertexesForme = 0 # Vertexes complet de la forme #19
# peut prendre du temps, depasser la fenetre et donner des donnees incompletes
# can take time and exceed the window and give data's incompletes
################################################


<!--T:8-->
try:
One mouse click on the object display the information of the object, two mouse click select the object complete and displayed alls informations
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
def angle2(vecteur_x1,vecteur_y1,vecteur_x2,vecteur_y2,mode):
# calcul de l'inclinaison d'une ligne a partir de deux Vecteurs
# si "mode" = 1 alors affichage en degres sinon en radian
try:
deltaX = vecteur_x2 - vecteur_x1
deltaY = vecteur_y2 - vecteur_y1
if mode ==1:
angle = degrees(atan2(float(deltaY),float(deltaX))) # degres
else:
angle = atan2(float(deltaY),float(deltaX)) # radian
return round(angle,6)
except Exception:
return 0


<!--T:9-->
'''PS:''' It is also possible that in the Linux environment it is not possible to click or have access to the object within the window displaying the information


<!--T:38-->
class Ui_MainWindow(object):
There are no problems in the Windows environment you can click inside the window and access to the object except the displayed characters
global path
global texteInfo
def setupUi(self, MainWindow):
self.window = MainWindow
global path
global texteInfo


<!--T:39-->
SizeX = 600 # size window length
this window to view and modify the dimensions, change:
SizeY = 600 # size window heigth
posiX = 300 # position window coordinate X
posiY = 190 # position window coordinate Y


<!--T:40-->
MainWindow.setObjectName("MainWindow")
'''visualiserWindow line 81 = 1'''
MainWindow.setWindowTitle("FCInfoGlass ")
MainWindow.resize(SizeX, SizeY) # dimenssions exterieures de la fenetre
MainWindow.setMinimumSize(QtCore.QSize(SizeX, SizeY)) #
MainWindow.setMaximumSize(QtCore.QSize(SizeX, SizeY)) #
MainWindow.setGeometry(posiX, posiY, SizeX, SizeY) # coin superieur X,Y coin inferieur X,Y positionne la fenetre dans l'ecran
# modify this line for posionned the window


<!--T:41-->
MainWindow.setWindowOpacity(1) # rend la fenetre +/- opaque
the '''lines 87 and 88 and SizeX SizeY''' for window dimensions
MainWindow.setWindowFlags(QtCore.Qt.FramelessWindowHint) # rend la fenêtre transparente et cache le cadre
MainWindow.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) # ne pas bouger ,True
MainWindow.setStyleSheet("background:transparent;") # rend le fond transparent
self.istransparent = True
#############################################


==Script== <!--T:45-->
################ test bouton
# self.frame = QtGui.QFrame(MainWindow)
# self.frame.setGeometry(QtCore.QRect(10, 370, 381, 24))
# self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
# self.frame.setFrameShadow(QtGui.QFrame.Raised)
# self.frame.setObjectName(_fromUtf8("frame"))
# self.PBQuit = QtGui.QPushButton(self.frame)
# self.PBQuit.setGeometry(QtCore.QRect(0, 0, 101, 23))
# self.PBQuit.setObjectName(_fromUtf8("PBQuit"))
# self.PBQuit.clicked.connect(self.on_PBQuit) ###
###################


<!--T:10-->
# self.frame.setWindowOpacity(1) # rend la fenetre +/- opaque
The icon '''Macro_FCInfoGlass.FCMacro''' [[File:Macro_FCInfoGlass.png|64px|FCInfoGlass]]
# self.frame.setWindowFlags(QtCore.Qt.FramelessWindowHint) # rend la fenêtre transparente et cache le cadre
# self.frame.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) # ne pas bouger ,True
# self.frame.setStyleSheet("background:transparent;") # rend le fond transparent
# self.istransparent = True
#########################################
# #cree un cadre aux dimensions MainWindow.resize(400, 400) mais cache la fenetre textEdit OK
# self.centralWidget = QtGui.QWidget(MainWindow)
# self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
# self.tableWidget = QtGui.QTableWidget(self.centralWidget)
# self.tableWidget.setGeometry(QtCore.QRect(0, 0, 400, 400))
##########################################
MainWindow.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) # met la fenetre en avant
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.label = QtGui.QLabel(self.centralWidget)
self.label.setGeometry(QtCore.QRect(10, 20, SizeX, SizeY)) # positionne le label (texte) et donne son occupation (surface cadre)abscisse, ordonnee, largeur, hauteur
self.label.setObjectName(_fromUtf8("label"))
MainWindow.setCentralWidget(self.centralWidget)
self.retranslateUi(MainWindow)
# self.PBQuit.setText("Quit")
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle("Dialog")
# self.PBQuit.setText("Quit")
self.label.setText("")
def on_pushButton_Raf_clicked(self): # affiche le texte concatene dans la fenetre
global texteInfo
self.label.setText(texteInfo + "\n")
# def on_PBQuit(self):
# App.Console.PrintMessage(str("Fin FCTransparencyInfo ")+"\n")
# self.window.hide()
class SelObserver:
def addSelection(self,document, object, element, position): # Selection
global texteInfo
global compteur


<!--T:34-->
global DocumentName
Copy the script on Gits [https://gist.github.com/mario52a/553b1fc7a8ca5bfa44c6 '''Macro_FCInfoGlass.FCMacro''']
global InternalName
global LabelObject
global ElementName
global ObjectType
global ObjectLength
global FaceSurface
global FaceCenter
global BoundBoxFaceVol
global BoundBoxFaceCoor
global BoundBoxFaceC
global VolumeObject
global BounboxVolume
global BounboxCoord
global BounboxCenter
global CenterMass
global LineInclination
global VertexesObject
global VertexesForme


<!--T:35-->
texteInfo = ""
and copy the Macro_FCInfoGlass.FCMacro and the icon in your macro directory.
compteur = 0
arondi = 5
def Around(a) :
return round(a,arondi)
sel = FreeCADGui.Selection.getSelection()
try:
Object = Gui.Selection.getSelectionEx()[0].SubObjects[0]
except:
None
# Nom du document #1
if DocumentName == 1:
try:
App.Console.PrintMessage("Document name : "+str(FreeCAD.activeDocument().Name)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Document name")+" : "+str(FreeCAD.activeDocument().Name)+"\n"
except:
None
# Nom interne de l'objet #2
if InternalName == 1:
try:
App.Console.PrintMessage("Object name : "+str(sel[0].Name)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Object name")+"\t : "+str(sel[0].Name)+"\n"
except:
None
# Label #3
if LabelObject == 1:
try:
App.Console.PrintMessage("Label name : "+str(sel[0].Label)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Label name")+"\t : "+str(sel[0].Label)+"\n"
except:
None
# Nom de l'element #4
if ElementName == 1:
try:
SubElement = FreeCADGui.Selection.getSelectionEx()
element_ = SubElement[0].SubElementNames[0]
App.Console.PrintMessage("Element name : "+str(element_)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Element name")+"\t : "+str(element_)+"\n"
except:
None
# Type d'objet #5
if ObjectType == 1:
try:
typeObject = sel[0].Shape.ShapeType
App.Console.PrintMessage("Object type : "+typeObject+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Object type")+"\t : "+typeObject+"\n"
except:
None
# longueur Objet #6
if ObjectLength == 1:
try:
App.Console.PrintMessage("Object lenght : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].Length)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Object lenght")+"\t : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].Length)+"\n"
except:
None
# Surface de la face #7
if FaceSurface == 1:
try:
App.Console.PrintMessage("Face area : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].Area)+"\n")
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Face area")+"\t : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].Area)+"\n"
except:
None


==Links== <!--T:46-->
# Center Face (mass) #8
if FaceCenter == 1:
try:
det = Gui.Selection.getSelectionEx()[0].SubObjects[0].CenterOfMass
App.Console.PrintMessage("Face center : "+str(det[0])+", "+str(det[1])+", "+str(det[2])+"\n") # Vector center mass to face
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Face center")+"\t : "+str(det[0])+", "+str(det[1])+", "+str(det[2])+"\n"
except:
None


<!--T:11-->
# BoudBox Face Volume #9
The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=8&t=6005 FCInfo Macro]
if BoundBoxFaceVol == 1:
try:
det = Gui.Selection.getSelectionEx()[0].SubObjects[0]
App.Console.PrintMessage("Face BoundBox Vol : "+str(det.BoundBox.XLength)+" x "+str(det.BoundBox.YLength)+" x "+str(det.BoundBox.ZLength)+"\n") # BoundBoxFace face volume
compteur += 1
texteInfo += " "+(str(compteur)+" : "+"Face BBox Volume")+" : "+str(det.BoundBox.XLength)+" x "+str(det.BoundBox.YLength)+" x "+str(det.BoundBox.ZLength)+"\n"
except:
None
# BoudBox Face Coordinates #10
if BoundBoxFaceCoor == 1:
try:
det = Gui.Selection.getSelectionEx()[0].SubObjects[0]
App.Console.PrintMessage("Face BoundBox Coor : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].BoundBox)+"\n") # BoundBoxFace face coordinates
compteur += 1
texteInfo += (str(compteur)+" : "+"Face BBox Coor")+" : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].BoundBox)+"\n"
except:
None
# BoudBox Face Center #11
if BoundBoxFaceC == 1:
try:
det = Gui.Selection.getSelectionEx()[0].SubObjects[0]
App.Console.PrintMessage("Face BoundBox Cent : "+str(Gui.Selection.getSelectionEx()[0].SubObjects[0].BoundBox.Center)+"\n") # BoundBoxFace face center
compteur += 1
texteInfo += (str(compteur)+" : "+"Face BBox Center")+" : X: "+str(det.BoundBox.Center[0])+" Y: "+str(det.BoundBox.Center[1])+" Z: "+str(det.BoundBox.Center[2])+"\n"
except:
None
######Cas d'une forme############################################################
# volume #12
if VolumeObject == 1:
try:
App.Console.PrintMessage("Volume : "+str(sel[0].Shape.Volume)+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"Volume")+"\t : "+str(sel[0].Shape.Volume)+"\n"
except:
None
# rectangle du BoundBox #13
if BounboxVolume == 1:
try:
App.Console.PrintMessage("BoundBox Volume : "+str(sel[0].Shape.BoundBox.XLength)+" x "+str(sel[0].Shape.BoundBox.YLength)+" x "+str(sel[0].Shape.BoundBox.ZLength)+"\r\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"BoundBox Volume")+" : "+str(sel[0].Shape.BoundBox.XLength)+" x "+str(sel[0].Shape.BoundBox.YLength)+" x "+str(sel[0].Shape.BoundBox.ZLength)+"\r\n"
except:
None
# boundinbox (dimensions hors tout) #14
if BounboxCoord == 1:
try:
App.Console.PrintMessage("BoundBox Coor : "+str(sel[0].Shape.BoundBox)+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"BoundBox Coor")+" : "+str(sel[0].Shape.BoundBox)+"\n"
except:
None
# centre de la forme #15
if BounboxCenter == 1:
try:
det = sel[0].Shape.BoundBox.Center
App.Console.PrintMessage("BoundBox Cent : "+str(det[0])+", "+str(det[1])+", "+str(det[2])+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"BoundBox Cent")+" : X: "+str(det[0])+" Y: "+str(det[1])+" Z: "+str(det[2])+"\n"
except:
None
# centre de la masse #16
if CenterMass == 1:
try:
det = sel[0].Shape
c = det.Solids[0].CenterOfMass
App.Console.PrintMessage("CenterMass : X: "+str(c.x)+" Y: "+str(c.y)+" Z: "+str(c.z)+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"CenterMass")+"\t : X: "+str(c.x)+" Y: "+str(c.y)+" Z: "+str(c.z)+"\n"
except:
None
# search inclination XY YZ ZX uniquement lignes #17
if LineInclination == 1:
try:
angleX1 = angleY1 = angleZ1 = 0.0
angleX2 = angleY2 = angleZ2 = 0.0
sel = FreeCADGui.Selection.getSelection()
SubElement = FreeCADGui.Selection.getSelectionEx()
element_ = SubElement[0].SubElementNames[0]
if element_[:4] == "Edge":
try:
element_ = element_[4:]
a = sel[0].Shape.Edges[int(element_)-1].Vertexes[0]
angleX1 = a.Point.x
angleY1 = a.Point.y
angleZ1 = a.Point.z
try:
a = sel[0].Shape.Edges[int(element_)-1].Vertexes[1]
angleX2 = a.Point.x
angleY2 = a.Point.y
angleZ2 = a.Point.z
except Exception:
Vertx.append("-")
Vertx.append("-")
Vertx.append("-")
except Exception:
None
try:
Plan_xy = angle2(angleX1,angleY1,angleX2,angleY2,1)
except Exception:
Plan_xy = 0.0
try:
Plan_yz = angle2(angleY1,angleZ1,angleY2,angleZ2,1)
except Exception:
Plan_yz = 0.0
try:
Plan_zx = angle2(angleZ1,angleX1,angleZ2,angleX2,1)
except Exception:
Plan_zx = 0.0
App.Console.PrintMessage("XY: "+str(Plan_xy)+" YZ: "+str(Plan_yz)+" ZX: "+str(Plan_zx)+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"Inclination Obj")+"\t : "+"XY: "+str(Plan_xy)+" YZ: "+str(Plan_yz)+" ZX: "+str(Plan_zx)+"\n"
except Exception:
None
# Vertexes de l'objet selectionne #18
if VertexesObject == 1:
try:
a = Gui.Selection.getSelectionEx()[0].SubObjects[0].Vertexes
aa = 0
for a0 in range(len(a)):
aa += 1
App.Console.PrintMessage("Vertexes Obj : X"+str(aa)+": "+str(a[a0].Point.x)+", Y"+str(aa)+ ": "+str(a[a0].Point.y)+", Z"+str(aa)+ ": "+str(a[a0].Point.z)+"\n")
compteur += 1
texteInfo += (str(compteur)+" : "+"Vertexes Obj")+"\t : X"+str(aa)+": "+str(a[a0].Point.x)+", Y"+str(aa)+ ": "+str(a[a0].Point.y)+", Z"+str(aa)+ ": "+str(a[a0].Point.z)+"\n"
except:
None
# Vertexes complet de la forme #19
if VertexesForme == 1:
try:
compt_E = 0
perimetre = 0.0
for j in enumerate(sel[0].Shape.Edges):
compt_E+=1
# perimetre += (sel[0].Shape.Edges[compt_E-1].Length)
a = sel[0].Shape.Edges[compt_E-1].Vertexes[0]
App.Console.PrintMessage("Vertexes Form : "+"X1: "+str(a.Point.x)+" Y1: "+str(a.Point.y)+" Z1: "+str(a.Point.z)+"\n")
compteur += 1
texteInfo +=(str(compteur)+" : "+ "Vertexes Form")+"\t : "+"X1: "+str(a.Point.x)+" Y1: "+str(a.Point.y)+" Z1: "+str(a.Point.z)+"\n"
a = sel[0].Shape.Edges[compt_E-1].Vertexes[1]
App.Console.PrintMessage(" : "+"X2: "+str(a.Point.x)+" Y2: "+str(a.Point.y)+" Z2: "+str(a.Point.z)+"\n")
texteInfo += ("\t\t ")+" : "+"X2: "+str(a.Point.x)+" Y2: "+str(a.Point.y)+" Z2: "+str(a.Point.z)+"\n"
# App.Console.PrintMessage("Perimeter : "+str(perimetre)+"\n")
# compteur += 1
# texteInfo += (str(compteur)+" : "+"Perimeter")+" : "+str(perimetre)+"\n"
except:
None


<!--T:36-->
ff = ui
My macros on [https://gist.github.com/mario52a mario52a ] gists
ff.on_pushButton_Raf_clicked()
App.Console.PrintMessage("End_____________________________________________________________"+"\n")


==Version== <!--T:12-->
s=SelObserver()

FreeCADGui.Selection.addObserver(s) # installe la fonction en mode résident
<!--T:42-->
'''28/08/2016 Ver 00.05''' : add radius with subObjects and center coordinates
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
</syntaxhighlight>
<translate>
===Links=== <!--T:11-->
</translate>
[http://forum.freecadweb.org/viewtopic.php?f=8&t=6005 FCInfo Macro]
<translate>
===Version=== <!--T:12-->


<!--T:13-->
<!--T:13-->
'''25/11/2015 Ver 0.04''' : add radius with subObjects and normalAT(0,0)
Prototype not finished

<!--T:37-->
'''31/08/2015 Ver 0.03''' : add many informations


<!--T:18-->
<!--T:18-->
Line 607: Line 259:


</translate>
</translate>
<languages/>

Latest revision as of 21:42, 28 December 2023

Other languages:

Macro FCInfoGlass

Description
Gives a series of information on the form display in the 3D view.

Macro version: 00.05
Last modified: 2016-08-28
Download: ToolBar Icon
Author: Mario52
Author
Mario52
Download
ToolBar Icon
Links
Macro Version
00.05
Date last modified
2016-08-28
FreeCAD Version(s)
None
Default shortcut
None
See also
Arch Survey

Description

Gives a series of informations about the selected shape and can display a directly in the 3D view

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://gist.githubusercontent.com/mario52a/553b1fc7a8ca5bfa44c6/raw/fc57ec0869a8f68ce396acbaed5e87f396426186/Macro_FCInfoGlass.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://gist.githubusercontent.com/mario52a/553b1fc7a8ca5bfa44c6/raw/fc57ec0869a8f68ce396acbaed5e87f396426186/Macro_FCInfoGlass.FCMacro")


FCInfoGlass

Utilisation

Select an object or launch the application and select an object, and a series of informations appear on the 3D View.

Modify this line to move the data display in the screen (lines 84, 85)

global posiX                 ; posiX                           = 900  # position window coordinate X                   "defaut  = 900"
global posiY                 ; posiY                           = 190  # position window coordinate Y                   "defaut  = 190"
  • 900, 190 = position X, Y upper left corner

Modify this line for change color (line 92)

#######################################################################
# Section color                                                       #
global colorize              ; colorize                      ="black" # colorize the text choice                       "defaut  = "black"
                                                                      # "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan"

Examples:

Availlable : "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan"

This section hare switch give value 1 for displayed the info or 0 for not displayed the info

Example:

is displayed ( = 1 )

global LabelObject     ;LabelObject      = 1 # Label                                          #3  Label Object

is not displayed ( = 0 )

global LabelObject     ;LabelObject      = 0 # Label                                          #3  Label Object

The section lines 79 to 171

#######################################################################
global visualiserWindow      ; visualiserWindow                = 0    # si visualiserWindow = 1 la fenetre est visible (pour test)  "defaut  = 0"
                                                                      # if visualiserWindow = 1 the windows is visible (for test)   "default = 0"
###Section Configuration ##############################################
# Placement window hidden                                             #
global posiX                 ; posiX                           = 900  # position window coordinate X                   "defaut  = 900"
global posiY                 ; posiY                           = 190  # position window coordinate Y                   "defaut  = 190"
#######################################################################
global SizeX                 ; SizeX                           = 600  # size window length  (do not modify)            "defaut  = 600"
global SizeY                 ; SizeY                           = 600  # size window heigth  (do not modify)            "defaut  = 600"


#######################################################################
# Section color                                                       #
global colorize              ; colorize                      ="black" # colorize the text choice                       "defaut  = "black"
                                                                      # "black" "white" "red" "green" "blue" "yellow" "magenta" "cyan"


#######################################################################
# Section inter                                                       #
global mode                  ; mode                            = 1    # mode 1=degrees mode 0=radians                  "defaut  = 1"
global arondi                ; arondi                          = 4    # many numbers after the decimal point           "defaut  = 4" 
global chaineRemplacement    ; chaineRemplacement              = "_"  # replacement string (1 character)               "defaut  = "_"


#######################################################################
# section switch 
# if switch = 1 then actif (True Displayed) else inactif (False not Displayed)
global PrintReportView       ;PrintReportView                  = 1    # Affichage dans la vue rapport                  #0  Displayed ReportView
## 
global DocumentName          ;DocumentName                     = 1    # Nom du document                                #1  Document Name
global InternalName          ;InternalName                     = 1    # Nom interne de l'objet                         #2  Internal Name
global LabelObject           ;LabelObject                      = 1    # Label                                          #3  Label Object
global ElementName           ;ElementName                      = 1    # Nom de l'element                               #4  Element Name
global ObjectType            ;ObjectType                       = 1    # Type d'objet                                   #5  Object Type
global LineSeparateTitle     ;LineSeparateTitle                = 1    # ligne de separation des titres ____________    #6  Line Separate of Title

## Object subObject 
global ObjectLength          ;ObjectLength                     = 1    # longueur Objet ou perimetre si c est une face  #7  Object Length or perimetre if are a face
global ObjectCurveRadius     ;ObjectCurveRadius                = 1    # rayon du subObject si arc ou cerle             #8  radius subObject if arc or cirle
global ObjectCurveCenter     ;ObjectCurveCenter                = 1    # coordonnees centrale subObject si arc ou cerle #9  coordinates center subObject if arc or cirle

## Draft
global LineDimension         ;LineDimension                    = 1    # Dimensions Line                                #10  Line Dimension
global DWireDimension        ;DWireDimension                   = 1    # Dimensions DWire                               #11  DWire Dimension
global CircleDimension       ;CircleDimension                  = 1    # Dimensions Circle                              #12 Circle Dimension
global CirclePartDimension   ;CirclePartDimension              = 1    # Dimensions Circle Part                         #13 Circle Part Dimension

global ArcDimension          ;ArcDimension                     = 1    # Dimensions Arc                                 #14 Arc Dimension
global EllipseDimension      ;EllipseDimension                 = 1    # Dimensions Ellipse                             #15 Ellipse Dimension
global EllipsePartDimension  ;EllipsePartDimension             = 1    # Dimensions Ellipse Part                        #16 Ellipse Part Dimension
global PolygonDimension      ;PolygonDimension                 = 1    # Dimensions Polygon                             #17 Polygon Dimension
global RectangleDimension    ;RectangleDimension               = 1    # Dimensions Rectangle                           #18 Rectangle Dimension
global BSplineDimension      ;BSplineDimension                 = 1    # Dimensions BSpline                             #19 BSpline Dimension
global PointDimension        ;PointDimension                   = 1    # Dimensions Point                               #20 Point Dimension
global BezCurveDimension     ;BezCurveDimension                = 1    # Dimensions BezCurve                            #21 BezCurve Dimension

## Solid
global CylinderDimension     ;CylinderDimension                = 1    # Dimensions du Cylindre Rayon Hauteur Angle     #22 Cylinder Dimension
global BoxDimension          ;BoxDimension                     = 1    # Dimensions du Box Length Width Height          #23 Box Dimension
global SphereDimension       ;SphereDimension                  = 1    # Dimensions de la Sphere                        #24 Sphere Dimension
global EllipsoidDimension    ;EllipsoidDimension               = 1    # Dimensions Ellipsoid                           #25 Ellipsoid Dimension
global ConeDimension         ;ConeDimension                    = 1    # Dimensions du Cone                             #26 Cone Dimension
global TorusDimension        ;TorusDimension                   = 1    # Dimensions du Tore                             #27 Torus Dimension

## Part
global PlanePartDimension    ;PlanePartDimension               = 1    # Dimensions Plan Part                           #28 Plane Part Dimension
global PrismPartDimension    ;PrismPartDimension               = 1    # Dimensions Prisme Part                         #29 Prism Part Dimension   
global WedgePartDimension    ;WedgePartDimension               = 1    # Dimensions Wedge Part                          #30 Wedge Part Dimension
global HelixPartDimension    ;HelixPartDimension               = 1    # Dimensions Helix Part                          #31 Helix Part Dimension
global SpiralPartDimension   ;SpiralPartDimension              = 1    # Dimensions Spirale Part                        #32 Spiral Part Dimension
global VertexPartDimensio    ;VertexPartDimension              = 1    # Dimensions Vertex Part                         #33 Vertex Part Dimension
global LinePartDimension     ;LinePartDimension                = 1    # Dimensions Line Part                           #34 Line Part Dimension
global RegularPolygonPartDimension;RegularPolygonPartDimension = 1    # Dimensions RegularPolygon Part                 #35 Regular Polygon Part Dimension

## Face
global FaceSurface           ;FaceSurface                      = 1    # Surface de la face                             #36 Face Surface
global NormalAt              ;NormalAt                         = 1    # Donne la normale (inclinaison)                 #37 normalAt(0,0) Face and edges normalAt(0)
global FaceCenter            ;FaceCenter                       = 1    # Center Face (mass)                             #38 Face Center
global BoundBoxFaceVol       ;BoundBoxFaceVol                  = 1    # BoundBoxFace Volume                            #39 BoundBox Face Volume
global BoundBoxFaceCent      ;BoundBoxFaceCent                 = 1    # BoundBoxFaceCenter                             #40 BoundBox Face Center
global BoundBoxFaceCoor      ;BoundBoxFaceCoor                 = 1    # BoundBoxFace coordinates                       #41 BoundBox Face Coordinates

## Volume
global BounBoxVolumeVol      ;BounBoxVolumeVol                 = 1    # rectangle du BoundBox                          #42 BounBox Volume Volume
global BounBoxVolumeCent     ;BounBoxVolumeCent                = 1    # centre de la forme                             #43 BounBox Volume Center
global BounBoxVolumeCoor     ;BounBoxVolumeCoor                = 1    # boundinbox (dimensions hors tout)              #44 BounBox Volume Coordinates
global VolumeObject          ;VolumeObject                     = 1    # volume                                         #45 Volume Object
global CenterMass            ;CenterMass                       = 1    # centre de la masse                             #46 Center Mass object
global PlacementForme        ;PlacementForme                   = 1    # placement de la forme                          #47 Placement Forme
global LineInclination       ;LineInclination                  = 1    # search inclination XY YZ ZX uniquement lignes  #48 Line Inclination
global VertexesObject        ;VertexesObject                   = 1    # Vertexes de l'objet selectionne                #49 Vertexes Object
global VertexesForme         ;VertexesForme                    = 0    # Vertexes complet de la forme                   #50 Vertexes Forme
                                                                      # peut prendre du temps, depasser la fenetre et donner des donnees incompletes
                                                                      # can take time and exceed the window and give data's incompletes
### End Section Switch #######################################################################################################################

After a change save the macro and run

It is not possible at the moment to leave the function from the macro or scrolling

One mouse click on the object display the information of the object, two mouse click select the object complete and displayed alls informations

PS: It is also possible that in the Linux environment it is not possible to click or have access to the object within the window displaying the information

There are no problems in the Windows environment you can click inside the window and access to the object except the displayed characters

this window to view and modify the dimensions, change:

visualiserWindow line 81 = 1

the lines 87 and 88 and SizeX SizeY for window dimensions

Script

The icon Macro_FCInfoGlass.FCMacro FCInfoGlass

Copy the script on Gits Macro_FCInfoGlass.FCMacro

and copy the Macro_FCInfoGlass.FCMacro and the icon in your macro directory.

Links

The discussion on the forum FCInfo Macro

My macros on mario52a gists

Version

28/08/2016 Ver 00.05 : add radius with subObjects and center coordinates

25/11/2015 Ver 0.04 : add radius with subObjects and normalAT(0,0)

31/08/2015 Ver 0.03 : add many informations

04/08/2015 Ver 0.02 : add switch and presentation