Macro FCInfo

Macro FCInfo

Description
Gives information about the selected shape and can display a conversion of length, inclination (degrees, radians, grades, percent), area, volume and weight in different units (metric and imperial). The macro now also works for the elements of a sketch in edit mode.


French Version Version Française

Macro version: 1.30c
Last modified: 2025/01/28
FreeCAD version: All
Download: ToolBar Icon
Author: Mario52

Author
Mario52
Download
ToolBar Icon
Links
Macro Version
1.30c
Date last modified
2025/01/28
FreeCAD Version(s)
All
Default shortcut
None
See also
Arch Survey, Macro SimpleProperties, Macro FCInfoGlass

Description

Gives information about the selected shape and can display a conversion of length, inclination (degrees, radians, grades, percent), area, volume and weight in different units (metric and imperial). The macro now also works for the elements of a sketch in edit mode.

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/8d40ab6c018c2bde678f/raw/2ba412bef3a9a5a0c6da4f3be18513a585f3a301/FCInfo_en_Ver_1-30c-rmu_Docked.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/8d40ab6c018c2bde678f/raw/2ba412bef3a9a5a0c6da4f3be18513a585f3a301/FCInfo_en_Ver_1-30c-rmu_Docked.FCMacro")
<class="rawcodeurl"><a href="https://gist.githubusercontent.com/mario52a/8d40ab6c018c2bde678f/raw/2ba412bef3a9a5a0c6da4f3be18513a585f3a301/FCInfo_en_Ver_1-30c-rmu_Docked.FCMacro">raw code</a>


FCInfo

Usage

Select an object and launch the application, or launch the application first and then select an object. The object is analyzed and a dialog opens showing the gathered information. With each new selection, the length unit is reset to mm and the angle unit to decimal degrees.

window
window


Sector 1: Document

FCInfo Document

(you can checked to false the variable switch_setVisible_GBox_001_Document for hidden the Box)

Sector 2: Coordinates click mouse

FCInfo Coordinate

(you can checked to false the variable switch_setVisible_GBox_002_Coordinate_Mouse for hidden the Box)

Sector 3: Color on point

FCInfo Color_on_point

(you can checked to false the variable switch_setVisible_GBox_003_Color for hidden the Box)

Sector 4: Components Mesh

FCInfo Component Mesh

If the selection is a mesh object one new window "Components" is displayed and gives:

(you can checked to false the variable switch_setVisible_GBox_004_Object_Mesh for hidden the Box)

Sector 5: Units

FCInfo Units

(you can checked to false the variable switch_setVisible_GBox_005_Value_Unit for hidden the Box)

Sector 6: Inclination

FCInfo Inclination

(you can checked to false the variable switch_setVisible_GBox_006_Inclination for hidden the Box)

Sector 7: Surface and Volume

FCInfo Surface and Volume

(you can checked to false the variable switch_setVisible_GBox_007_Surface_and_Volume for hidden the Box)

Sector 8: Cost

FCInfo Cost

0.027 Eu

10,0000 Eu (by Kg)
(you can checked to false the variable switch_setVisible_GBox_008_Cost_And_Price for hidden the Box)

Sector 9: BoundBox

FCInfo BoundBox

(you can checked to false the variable switch_setVisible_GBox_009_BoundBox for hidden the Box)

Sector 10: Center of:

FCInfo Center of...

(you can checked to false the variable switch_setVisible_GBox_010_Center_Mass for hidden the Box)

Sector 11: Inertia

FCInfo Inertia

same for length and weigth

(you can checked to false the variable switch_setVisible_GBox_011_Inertia for hidden the Box)

Sector 12: SpreadSheet

FCInfo Disabled

(you can checked to false the variable switch_setVisible_GBox_012_SpreadSheet for hidden the Box)

Sector 13: SpreadSheet creation

FCInfo SpreedSheet

Option for save or read the spreadsheet with different separator, Tabulation, Comma, Semicolon, Space
The Tabulation are the separator for the FreeCAD [Spreadsheet_Workbench|Spreadsheet workbench]
The number of this four separator are calculate for help if unknown
The COMMA are the old (01.16 and before) separator of the FCInfo macro
Now for compatibility with the FreeCAD spreadsheet and since 01.17 version the TABULATION is the separator by default
If you want to convert your old FCInfo spreadsheet : Open it in FCInfo and save it with the Tabulation option checked
(you can checked to false the variable switch_setVisible_GBox_013_SpreadSheet_Creation for hidden the Box)

Sector 14: Main tools

FCInfo Main

(you can checked to false the variable switch_setVisible_GBox_014_Main_Tools for hidden the Box)

Once launched macro, the macro remains active and the window remains visible. To exit the macro by pressing Exit. If you leave by the cross, the macro remains in memory and the data appears in the "report view" of FreeCAD, you must restart FreeCAD for quit it.

Options

The unit used

Length unit:

km, hm, dam, m, dm, cm, mm, µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.

Angle degrees :

  1. decimal degree, ex: 174.831872611°
  2. degree minute seconde, ex: 174° 49' 54.741401''
  3. radian, ex: 3.05139181449 rad
  4. grade, ex: 194.257636235 gon
  5. percent ex: 30° = 57.74%

Understanding of angles in FCInfo display.

Weight unit :

ton, quintal, kg, hg, dag, gram, dg, cg, mg, µg, ng, pg, fg, gr (grain), dr (drachm), oz (once), oz t (once troy),
lb t (livre troy), lb (livre av), st (stone), qtr (quarter), cwt (hundredweight), tonneau fr, ct

FCInfo Configuration


This switch (section GroupBox) allows you to view only the desired section(s) (just visual) false or true.

All calculations are done without taking account of this option

Script

Copy the contents of the macro in a file named "FCInfo.FCMacro"

Or, directly in the interface of FreeCAD
The icon must be in the same directory as the macro.
Download image positioning on the icon and then drag the mouse right click "save as" (do not change the name)

PS: the code is too long to be contained in the wiki page (for the time being the wiki pages accept only 64 KB) the macro code has been placed in the forum

Download the macro file on gist docked to right


(Or on the forum. )

PS: this macro uses getSelection() and the list of object begin to 1 ex: for a box Edge1 to Edge12 and the code in the console start at 0 ex: for a box Edge[0] to Edge[11]
This is normal, the counting on arrays/lists inside OpenCascade always starts at 1 and not at 0.

Limitations

Always leave the button Exit. If one exits the program without going through the button Exit, the program remains in memory and continues to run and the display will remain in the "view report". You must leave FreeCAD to erase it from memory.
Only the first 200 elements of the object are visible in the table. If there are more than 200 items in the object, a signal will be displayed by (! +200). The complete list of data is visible in the file saved by the button Save.

If the window macro is invisible after the run, see the bottom window :


project:
read the file directly in a table. done
matches the "Edges" and their coordinates done
Association of a substance to its density
inclination on the element rather than the global object done
inlay right in the interface of FreeCAD done

Version

ver "1.30c" 2025/01/28 : replace connect comboBox for Arch Linux

replace:

QtCore.QObject.connect(self.comboBox_Unit, QtCore.SIGNAL(u"currentIndexChanged(QString)"), self.SIGNAL_comboPoids_Changed)

by:

self.comboBox_Unit.currentTextChanged.connect(self.SIGNAL_comboPoids_Changed)

ver "1.30b" 2025/01/20 : replace the slash Windows "\" by the slash Python "/"

ver "1.30" 2025/01/02 : delete all reference to PySide PySide2 and QtWidgets modify the (Qt) Save file

#
import PySide2
from PySide2 import QtGui , QtCore, QtWidgets
from PySide2.QtWidgets import QComboBox
from PySide2.QtWidgets import QMessageBox
from PySide2.QtWidgets import QTableWidget, QApplication
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *

            OpenName, Filter = PySide2.QtWidgets.QFileDialog.getOpenFileName(None, u"Read a txt file", setPathLatestDirectory, "*.FCInfo *.csv *.asc *.txt;;FCInfo (*.FCInfo);;Cvs (*.csv);;Ascii (*.asc);;TXT (*.txt);;(*.*);;(*)")#PySide2

replaced and change command by

#
import PySide
try:
    from PySide import QtWidgets
    from PySide.QtWidgets import *
except Exception:
    None
from PySide import QtGui , QtCore
from PySide.QtGui import *
from PySide.QtCore import *

            OpenName, Filter = QFileDialog.getOpenFileName(None, u"Read a txt file", setPathLatestDirectory, "*.FCInfo *.csv *.asc *.txt;;FCInfo (*.FCInfo);;Cvs (*.csv);;Ascii (*.asc);;TXT (*.txt);;(*.*);;(*)")#PySide

ver "1.29b" 2024/05/10 PySide2 modify Inertia " MatrixX1*uniteM to (MatrixX1*uniteM) " and adding spinBox inertia

ver 1.29 2024/05/06 french version fr PySide6 by sylvainbx https://gist.github.com/sylvainbx/af09a30be3e1427de56305825331fb29 merci sylvainbx

ver 1.28b 1.28c 2023/10/30 orthographe

ver 1.28 01/09/2023 modify variable name, possibility hidden each sector, save data spreadSheet in document, surface radius, add button webWiki and webForum

ver 1.27 2023/06/30 optimize the styleSheet, correct the left/right position and restore view after edition sketcher

self.PB_00_Decrement.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);")      # bord white and red

replaced by

self.PB_00_Decrement.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};")      # bord white and red

Adding

FreeCAD.ActiveDocument.openTransaction(u"FCInfo")    # memorise les actions (avec annuler restore)
FreeCAD.ActiveDocument.commitTransaction()           # restore les actions  (avec annuler restore)
#FreeCAD.ActiveDocument.abortTransaction()            # abandonne les actions(avec annuler restore)
try:
        self.window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)    # destroy
        self.window.deleteLater()                                     # destroy
        self.window.destroy()                                         # destroy
except Exception:
        None

How do i exit from FreeCAD instead of Python?

instead:

self.window.hide()

and i adding the possibility display or not the "Error Message" window "False" by default, if you wand activate the warning window go to :

FreeCAD >Menu >Tools >Edit parameters... >BaseApp/Preferences/Macros/FCMmacros/FCInfo > switchWarning

Links

See Also: Arch Survey Arch Survey

You can share your comments on the forum Info Workbench - Help with icons please.
Here another post of FCInfo Macro