Macro FCInfo: Difference between revisions

From FreeCAD Documentation
No edit summary
(Marked this version for translation)
(34 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:1-->
<!--T:1-->
{{Macro
{{Macro|Icon=FCInfo|Name=Macro FCInfo|Description=Gives a series of information on the form.|Author=Mario52|Version=1.20 |Date=29/01/2018 }}
|Name=Macro FCInfo
|Icon=FCInfo.png
|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.
<br />French Version [https://gist.githubusercontent.com/mario52a/6afc64081c4eb8be3b93/raw/d4144fac33c0118dd5f6463258f0625b2555c451/FCInfo_fr_Ver_1-23cb-rmu_Docked.FCMacro Version Française]
|Author=Mario52
|Version=1.23cb
|Date=2021/11/25
|FCVersion=All
|Download=
|SeeAlso=[[File:Arch Survey.svg|Arch Survey|24px]] [[Arch_Survey|Arch Survey]]<br />[[Macro_SimpleProperties|Macro SimpleProperties]]
}}

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


<!--T:2-->
<!--T:2-->
Gives a series of informations about the selected shape and can display a conversion of length, inclination (degrees, radians, grades, pourcent) shape, surface, volume and the weight of the form in the density selected in different units of quantities international and Anglo-Saxon.
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.


</translate>
</translate>
{{Codeextralink|https://gist.githubusercontent.com/mario52a/8d40ab6c018c2bde678f/raw/e16ad9ea7b38c0c47e42aa3019be01dd1267a620/FCInfo_en_Ver_1-20_Docked.FCMacro}}
{{Codeextralink|https://gist.githubusercontent.com/mario52a/8d40ab6c018c2bde678f/raw/a182e733cf0b8ff43307b62515bcad8e8b3152d5/FCInfo_en_Ver_1-23cb-rmu_Docked.FCMacro}}
<translate>
<translate>


<!--T:3-->
<!--T:3-->
[[File:Macro_FCInfo_00_en.png|480px|FCInfo]]
[[File:Macro_FCInfo_00_en.png|480px]]
{{Caption|FCInfo}}

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


===Utilisation=== <!--T:4-->
<!--T:4-->
Select an object or launch the application and select an object, and a series of informations appear.
Select an object or launch the application and select an object, and a series of informations appear. His calculations based on unity of FreeCAD, which is the '''mm''' to each new selection, the length unit always comes back on '''mm''' and angle on '''decimal degrees'''.
His calculations based on unity of FreeCAD, which is the '''mm''' to each new selection, the length unit always comes back on '''mm''' and angle on '''decimal degrees'''.
[[File:Macro FCInfo 06.png|200px|left|upper window]][[File:Macro FCInfo 07.png|200px|lower window]]
[[File:Macro FCInfo 06.png|200px|left|upper window]][[File:Macro FCInfo 07.png|200px|lower window]]


Line 31: Line 47:
'''Sector 2: Coordinates click mouse'''
'''Sector 2: Coordinates click mouse'''
*Coordinates X,Y and Z click to mouse
*Coordinates X,Y and Z click to mouse
*The button create on point, axis, plane, copy vector axis form '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*The button creates point, axis, plane, copy vector axis from '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''


<!--T:21-->
<!--T:21-->
'''Sector 3: Value'''
'''Sector 3: Value'''
*Length of the object if the object is a face perimeter is displayed unit size can be selected :<br />km, hm, dam, m, dm, cm, '''mm''', µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique. If the object is circle one second lineEdit is open ans display the radius of circle.
*If the object is a face perimeter, length of the object is displayed. Unit size can be selected :<br />km, hm, dam, m, dm, cm, '''mm''', µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.
*If the object is a circle, a second line is opened and displays the radius of circle.
*Perimeter of the shape
*Perimeter of the shape.


<!--T:22-->
<!--T:22-->
'''Sector 4: Vertexes and details'''
'''Sector 4: Vertexes and details'''
*CheckBox for for search or not all details of the object if is not checked only the principal value are displayed.
*CheckBox for for search or not all details of the object. If it is not checked, only the principal value is displayed.
*Vertexes and details of the shape (compt_Edge), (compt_Faces), (compt_Vector of the Face) <br />max 200 lines in the table, if there are more than 200 lines it appears (!+ 200) and the number of lines<br />(full details can save be the {{KEY|Save}} button in a file in CSV format and can be viewed the file in spreadsheet with the {{KEY|Read}} or by an external spreadsheet as [https://www.libreoffice.org/ LibreOffice] [http://openoffice.apache.org/downloads.html OpenOffice] or other)
*Vertexes and details of the shape (compt_Edge), (compt_Faces), (compt_Vector of the Face) <br />max 200 lines in the table, if there are more than 200 lines it appears (!+ 200) and the number of lines<br />(full details can save be the {{KEY|Save}} button in a file in CSV format and can be viewed the file in spreadsheet with the {{KEY|Read}} or by an external spreadsheet as [https://www.libreoffice.org/ LibreOffice] [http://openoffice.apache.org/downloads.html OpenOffice] or other)


<!--T:23-->
<!--T:23-->
'''Sector 5: Inclination'''
'''Sector 5: Inclination'''
*Inclinations of the object can be displayed in:
*'''Inclination of the object''' can be displayed in:
*'''decimal degree''', ex: 174.831872611°
**decimal degree, ex: 174.831872611°
*'''degree minute seconde''', ex:<nowiki> 174° 49' 54.741401''</nowiki>
**degree minute seconde, ex:<nowiki> 174° 49' 54.741401''</nowiki>
*'''radian''', ex: 3.05139181449 rad
**radian, ex: 3.05139181449 rad
*'''grade''', ex: 194.257636235 gon
**grade, ex: 194.257636235 gon
*'''pourcent''' ex: 30° = 57.74%
**pourcent, ex: 30° = 57.74%
*Inclinations in planes XY, YZ, ZX and their coordinates
*'''Inclinations in planes XY, YZ, ZX''' and their coordinates
*'''Direction object''', give the direction of object the calculate is : coord_1 - coord_2 = direction (or reverse)
*'''Direction object''', give the direction of object. The calculate is : coord_1 - coord_2 = direction (or reverse)
**{{KEY|Line}} this button create a line in direction of the object
**{{KEY|Line}} this button create a line in direction of the object.
*'''ValueAt''', returns the 3D vector corresponding to a parameter value.
*'''ValueAt''', returns the 3D vector corresponding to a parameter value.


<!--T:24-->
<!--T:24-->
'''Sector 6: Surface and Volume'''
'''Sector 6: Surface and Volume'''
*Surface of the form displayed unit size can be selected
*Surface of the form displayed, unit size can be selected.
*Surface of the face displayed unit size can be selected
*Surface of the face displayed, unit size can be selected.
*Volume of the form displayed unit size can be selected
*Volume of the form displayed, unit size can be selected.
*density of the material in '''kg by dm3'''<br />(the "spinBox" is set to '''7,5''' kg, average density of steel. If you want a different default value, change the value of the density, line 204)
*Density of the material in '''kg by dm3'''<br />(the "spinBox" is set to '''7,5''' kg, average density of steel. If you want a different default value, change the value of the density, line 204).
*The {{KEY|gram}} buttom unit mass can be chosen :<br /> ton,quintal, kg, hg, dag, '''gram''', dg, cg, mg, µg, ng, pg, fg, gr (grain), dr (drachm), oz (once), oz t (once troy),<br />lb t (livre troy), lb (livre av), st (stone), qtr (quarter), cwt (hundredweight), tonneau fr, ct
*The {{KEY|gram}} unit mass can be chosen :<br /> ton,quintal, kg, hg, dag, '''gram''', dg, cg, mg, µg, ng, pg, fg, gr (grain), dr (drachm), oz (once), oz t (once troy),<br />lb t (livre troy), lb (livre av), st (stone), qtr (quarter), cwt (hundredweight), tonneau fr, ct.
*weight of the form displayed unit mass can be selected
*Weight of the form displayed, unit mass can be selected.


<!--T:25-->
<!--T:25-->
'''Sector 7: BoundBox'''
'''Sector 7: BoundBox'''
*BoundBox extreme dimensions of the shape
*BoundBox gives extreme dimensions of the shape.


<!--T:26-->
<!--T:26-->
Line 73: Line 90:
*Center of the shape and these coordinates XYZ
*Center of the shape and these coordinates XYZ
*Center of mass and these coordinates XYZ
*Center of mass and these coordinates XYZ
*The button create on point, axis, plane, copy vector axis form '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*The button creates on point, axis, plane, copy vector axis form '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''


<!--T:27-->
<!--T:27-->
'''Sector 9: Inertia'''
'''Sector 9: Inertia'''
*Moment of inertia and these coordinates length and weigth
*Moment of inertia and these coordinates length and weigth
*The button create on point, axis, plane, copy vector axis form '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*The button creates on point, axis, plane, copy vector axis form '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
**action line 1 : x1, y1, z1
** action line 1 : x1, y1, z1
** action line 2 : x2, y2, z2
** action line 2 : x2, y2, z2
** action line 3 : x3, y3, z3
** action line 3 : x3, y3, z3
** action 4 diagonal : x1, y2, z3
** action 4 diagonal : x1, y2, z3
same for length and weigth
same for length and weigth
*Determinant 1 : computes the determinant of the matrix scientific value
*Determinant 1 : computes the determinant of the matrix, in [https://en.wikipedia.org/wiki/Scientific_notation scientific value]
*Determinant 2 : computes the determinant of the matrix decimal value
*Determinant 2 : computes the determinant of the matrix, in decimal value


<!--T:28-->
<!--T:28-->
Line 97: Line 114:


<!--T:32-->
<!--T:32-->
Option for save or read the spreadSheet with different separator, Tabulation, Comma, Semicolon, Space<br />
Option for save or read the spreadsheet with different separator, Tabulation, Comma, Semicolon, Space<br />
The Tabulation are the separator for the FreeCAD spreadSheet module<br />
The Tabulation are the separator for the FreeCAD [Spreadsheet_Workbench|Spreadsheet workbench]<br />
The number of this four separator are calculate for help if unknown<br />
The number of this four separator are calculate for help if unknown<br />
The COMMA are the old (01.16 and before) separator of the FCInfo macro<br />
The COMMA are the old (01.16 and before) separator of the FCInfo macro<br />
Now for compatibility with the FreeCAD spreadSheet and since 01.17 version the TABULATION is the separator by default<br />
Now for compatibility with the FreeCAD spreadsheet and since 01.17 version the TABULATION is the separator by default<br />
If you want to convert your old FCInfo spreadsheet : Open it in FCInfo and save it with the Tabulation option checked
If you want to convert your old FCInfo spreadsheet : Open it in FCInfo and save it with the Tabulation option checked


<!--T:33-->
<!--T:33-->
'''Section 11: Main'''
'''Section 11: Main'''
*{{KEY|CheckBox Clip Board}} : if checked the coordinates are saved in clipBoard form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Clip Board}} : if checked, the coordinates are saved in clipBoard form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Point}} : if checked one point is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Point}} : if checked, one point is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Axis }} : if checked one axis is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Axis}} : if checked, one axis is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Plane}} : if checked one axis plane is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|CheckBox Plane}} : if checked, one axis plane is created in the coordinate displayed form : '''FreeCAD.Vector(-24.0, 240.0, 7.0)'''
*{{KEY|Ref}} : Refresh the display of data in report view
*{{KEY|Ref}} : refresh the display of data in report view
*{{KEY|Exit}} : Exit the macro (you must restart from the tool bar button or menu "View > Panels > FCInfo"
*{{KEY|Exit}} : exit the macro (you must restart from the tool bar button or menu "View Panels FCInfo"
*{{KEY|CheckBox}} '''1''' : If this CheckBox is checked the informations are displayed in the report view window
*{{KEY|CheckBox}} '''1''' : if this CheckBox is checked, the informations are displayed in the report view window
*{{KEY|CheckBox}} '''2''' : If this CheckBox is not checked the window macro are displayed to right (default). If it is checked the window macro are displayed to left
*{{KEY|CheckBox}} '''2''' : if this CheckBox is not checked, the window macro are displayed to right (default). If it is checked the window macro are displayed to left


<!--T:29-->
<!--T:29-->
Line 121: Line 138:
<center>
<center>
<gallery widths="400" heights="200">
<gallery widths="400" heights="200">
Image:Macro_FCInfo_04.png|Docked to rigth,
Image:Macro_FCInfo_04.png|Docked to right,
Image:Macro FCInfo 05.png|or left with Combo view and reachable by a tab, or not docked to the choice.
Image:Macro FCInfo 05.png|or left with Combo view and reachable by a tab, or not docked, to the choice.
</gallery>
</gallery>
</center>
</center>
{{clear}}
{{clear}}


===Options=== <!--T:6-->
==Options== <!--T:47-->

====The unit used====
=====Length unit:=====
===The unit used=== <!--T:6-->

====Length unit:==== <!--T:48-->

<!--T:49-->
km, hm, dam, m, dm, cm, '''mm''', µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.
km, hm, dam, m, dm, cm, '''mm''', µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.


=====Angle degrees :===== <!--T:12-->
====Angle degrees :==== <!--T:50-->

<!--T:12-->
#'''decimal degree''', ex: 174.831872611°
#'''decimal degree''', ex: 174.831872611°
#degree minute seconde, ex:<nowiki> 174° 49' 54.741401''</nowiki>
#degree minute seconde, ex:<nowiki> 174° 49' 54.741401''</nowiki>
Line 150: Line 173:
{{clear}}
{{clear}}


=====Weight unit :===== <!--T:14-->
====Weight unit :==== <!--T:51-->

<!--T:14-->
ton, quintal, kg, hg, dag, '''gram''', dg, cg, mg, µg, ng, pg, fg, gr (grain), dr (drachm), oz (once), oz t (once troy),<br />
ton, quintal, kg, hg, dag, '''gram''', dg, cg, mg, µg, ng, pg, fg, gr (grain), dr (drachm), oz (once), oz t (once troy),<br />
lb t (livre troy), lb (livre av), st (stone), qtr (quarter), cwt (hundredweight), tonneau fr, ct <br /> <br />
lb t (livre troy), lb (livre av), st (stone), qtr (quarter), cwt (hundredweight), tonneau fr, ct <br /> <br />
the "spinBox" is set to '''7,5''' kg, average density of steel. If you want a different default value, change the value of the density, line 206
the "spinBox" is set to '''7,5''' kg, average density of steel. If you want a different default value, change the value of the density, line 208
</translate>


</translate>
{{Code|code=
{{Code|code=
global densite ; densite = 7.5 # (steel = 7.5 kg par dm3)
global densite ; densite = 7.5 # (steel = 7.5 kg par dm3)
}}
}}

<translate>
<translate>

<!--T:15-->
<!--T:15-->
A file can be created by the button {{KEY|Save}}. The file is written as a file [https://fr.wikipedia.org/wiki/Comma-separated_values csv] in this way, the data can be studied in a spreadsheet in FreeCAD or Openoffice, LibreOffice...
A file can be created by the button {{KEY|Save}}. The file is written as a file [https://fr.wikipedia.org/wiki/Comma-separated_values csv] in this way, the data can be studied in a spreadsheet in FreeCAD or OpenOffice, LibreOffice...

==Script== <!--T:7-->


===Script=== <!--T:7-->
<!--T:52-->
Copy the contents of the macro in a file named "FCInfo.FCMacro"
Copy the contents of the macro in a file named "FCInfo.FCMacro"
*Windows: the form is usually '''" drive:\Users\your_user_name\AppData\Roaming\FreeCAD\ "'''
*Windows: the form is usually '''" drive:\Users\your_user_name\AppData\Roaming\FreeCAD\ "'''
Line 170: Line 197:
Or, directly in the interface of FreeCAD <br />
Or, directly in the interface of FreeCAD <br />
The icon must be in the same directory as the macro.<br />
The icon must be in the same directory as the macro.<br />
Download image positioning on the icon [[File:FCInfo.png|64px]] [[File:FCInfoSpreadsheet.png|64px]] and then drag the mouse right click "save as" (do not change the name)<br />
Download image positioning on the icon [[File:FCInfo.png|64px]] [[File:FCInfoSpreadsheet.png|64px]] and then drag the mouse right click "save as" (do not change the name)<br />
</translate>
</translate>
<translate>
<translate>
<!--T:16-->
<!--T:16-->
'''PS: 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'''<br /><br />
'''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'''<br /><br />


<!--T:18-->
<!--T:18-->
Line 184: Line 211:


<!--T:19-->
<!--T:19-->
There is also a [http://www.freecadweb.org/wiki/index.php?title=Macro_FCInfo_Alternate_Linux Macro_FCInfo_Alternate_Linux] here the code is changed (due to the character display error : '''² ³ ° μ''' ordinal not in range (128)") which posed problems in certain configurations the functions are the same <br />
There is also a [http://www.freecadweb.org/wiki/index.php?title=Macro_FCInfo_Alternate_Linux Macro_FCInfo_Alternate_Linux]. Here the code is changed (due to the character display error : '''² ³ ° μ''' ordinal not in range (128)") which posed problems. In certain configurations the functions are the same <br />
Example :
Example :
{{Code|code=
{{Code|code=
Line 205: Line 232:


<!--T:31-->
<!--T:31-->
Dwnload the macro file on gist '''docked to right'''
Download the macro file on gist '''docked to right'''


<!--T:34-->
<!--T:34-->
{{CodeDownload|https://gist.github.com/mario52a/8d40ab6c018c2bde678f|last version Macro_FCInfo and the icons at the end of the page}}
{{CodeDownload|https://gist.github.com/mario52a/8d40ab6c018c2bde678f|last version Macro_FCInfo (the icons are at the end of the page)}}




<!--T:35-->
<!--T:35-->
(Or '''[http://forum.freecadweb.org/viewtopic.php?f=10&t=3185&p=47748#p47748 On the forum.]''' )<br /><br />
(Or '''[http://forum.freecadweb.org/viewtopic.php?f=10&t=3185&p=47748#p47748 on the forum.]''' )<br /><br />
'''PS:''' this macro uses '''getSelection()''' and the list of object begin to 1 ex: for a box '''Edge1 to Edge12'''
'''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]'''<br />
This is normal, the counting on arrays/lists inside OpenCascade always starts at '''1 and not at 0'''.
and the code in the console start at 0 ex: for a box '''Edge[0] to Edge[11]'''<br />
This is normal the counting on arrays/lists inside OpenCascade always starts at '''1 and not at 0'''
</translate>
</translate>
<translate>
<translate>

===Limitations=== <!--T:8-->
===Limitations=== <!--T:53-->
Always leave the button {{KEY|Exit}}. If one exits the program without going through the button {{KEY|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.<br />

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 {{KEY|Save}}.<br />
<!--T:8-->
Always leave the button {{KEY|Exit}}. If one exits the program without going through the button {{KEY|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.<br />
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 {{KEY|Save}}.<br />


<!--T:37-->
<!--T:37-->
If the window macro is invisible after the run , see the bottom window :
If the window macro is invisible after the run, see the bottom window :


<!--T:38-->
<!--T:38-->
Line 241: Line 270:
<strike>inlay right in the interface of FreeCAD</strike> done<br />
<strike>inlay right in the interface of FreeCAD</strike> done<br />


<!--T:10-->
==Version== <!--T:10-->

currently:<br />
<!--T:42-->
*ver 1.23cb 25/11/2021 delete '''"import Sketcher * "''' create conflict with "'''open(OpenName, "r")'''" ??
Adding
</translate>
{{Code|code=
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)
}}
<translate>
<!--T:55-->
*ver 1.23b, 20/11/2021 little correction, add text info in beginning run macro, and ordinal the text code
*ver 1.23 , 19/11/2021 include icon in macro, number decimal displayed, text height, configure options in the Preference FC, correct info for elements of sketch in edit mode.
*ver 1.22 , 12/11/2020 : now the macro is totally uninstalled i use :
</translate>
{{Code|code=
try:
self.window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # destroy
self.window.deleteLater() # destroy
self.window.destroy() # destroy
except Exception:
None
}}

[https://forum.freecadweb.org/viewtopic.php?f=22&t=48013#p411508 How do i exit from FreeCAD instead of Python?]

instead:
{{Code|code=
self.window.hide()
}}
<translate>
<!--T:43-->
and i adding the possibility display or not the "Error Message" window "False" by default, if you wand activate the warning window go to :
</translate>
{{Code|code=
FreeCAD >Menu >Tools >Edit parameters... >BaseApp/Preferences/Macros/FCMmacros/FCInfo > switchWarning
}}
<translate>
<!--T:44-->
*ver 1.21-3.01 , 07/11/2019 # 07/11/2019 ver "01.21-3-rmu" replace character micro = "U", square = "2", cube = "3", degrees = " deg" see "https://forum.freecadweb.org/viewtopic.php?f=3&t=6005&start=70#p345819"
*ver 1.21-2.01 (1.21-rmu) 11/06/2019 rmu replace all characters over 127 in ex: "°" in chr(176)) #degree
*ver 1.21.01 (1.21-rmu) 30/05/2019 rmu change fixed positions to qt layouts grid.addWidget() by rmu75 see the rmu75 fork "https://gist.github.com/rmu75/b165147bd1c2f2659c014103793ae1d8"
*ver 1.21 , 16/04/2019 optimization for Py 3... Qt 5... FreeCAD 0.15 to 0.19 release
*ver 1.20 , 29/01/2018 optimization
*ver 1.20 , 29/01/2018 optimization
*ver 1.19 , 20/01/2018 create checkBox for use detection all elements of the object if wanted or not , the macro is faster. Optimisation
*ver 1.19 , 20/01/2018 create checkBox for use detection all elements of the object if wanted or not , the macro is faster. Optimisation
Line 269: Line 341:
*ver 1.00 , 6/09/2013<br />
*ver 1.00 , 6/09/2013<br />


===Links=== <!--T:17-->
==Links== <!--T:17-->

<!--T:54-->
See Also: [[File:Arch_Survey.svg|36px|Arch Survey]] [[Arch_Survey|Arch Survey]]

<!--T:41-->
You can share your comments on the forum [http://forum.freecadweb.org/viewtopic.php?f=10&t=3185 Info Workbench - Help with icons please.]<br />
You can share your comments on the forum [http://forum.freecadweb.org/viewtopic.php?f=10&t=3185 Info Workbench - Help with icons please.]<br />
Here another post of [http://forum.freecadweb.org/viewtopic.php?f=8&t=6005 FCInfo Macro]
Here another post of [http://forum.freecadweb.org/viewtopic.php?f=8&t=6005 FCInfo Macro]

Revision as of 17:11, 28 November 2021

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.23cb
Last modified: 2021/11/25
FreeCAD version: All
Author: Mario52

Author
Mario52
Download
Links
Macro Version
1.23cb
Date last modified
2021/11/25
FreeCAD Version(s)
All
Default shortcut
None
See also
Arch Survey Arch Survey
Macro SimpleProperties

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/a182e733cf0b8ff43307b62515bcad8e8b3152d5/FCInfo_en_Ver_1-23cb-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/a182e733cf0b8ff43307b62515bcad8e8b3152d5/FCInfo_en_Ver_1-23cb-rmu_Docked.FCMacro")


FCInfo

Utilisation

Select an object or launch the application and select an object, and a series of informations appear. His calculations based on unity of FreeCAD, which is the mm to each new selection, the length unit always comes back on mm and angle on decimal degrees.

upper window
upper window

lower window

Sector 1: Document

  • Document name
  • Label of the object
  • Internal Name of the object
  • Sub element name of the object
  • Type of the object

Sector 2: Coordinates click mouse

  • Coordinates X,Y and Z click to mouse
  • The button creates point, axis, plane, copy vector axis from FreeCAD.Vector(-24.0, 240.0, 7.0)

Sector 3: Value

  • If the object is a face perimeter, length of the object is displayed. Unit size can be selected :
    km, hm, dam, m, dm, cm, mm, µm, nm, pm, fm, inch, link, foot, yard, perch, chain, furlong, mile, league, nautique.
  • If the object is a circle, a second line is opened and displays the radius of circle.
  • Perimeter of the shape.

Sector 4: Vertexes and details

  • CheckBox for for search or not all details of the object. If it is not checked, only the principal value is displayed.
  • Vertexes and details of the shape (compt_Edge), (compt_Faces), (compt_Vector of the Face)
    max 200 lines in the table, if there are more than 200 lines it appears (!+ 200) and the number of lines
    (full details can save be the Save button in a file in CSV format and can be viewed the file in spreadsheet with the Read or by an external spreadsheet as LibreOffice OpenOffice or other)

Sector 5: Inclination

  • Inclination of the object can be displayed in:
    • decimal degree, ex: 174.831872611°
    • degree minute seconde, ex: 174° 49' 54.741401''
    • radian, ex: 3.05139181449 rad
    • grade, ex: 194.257636235 gon
    • pourcent, ex: 30° = 57.74%
  • Inclinations in planes XY, YZ, ZX and their coordinates
  • Direction object, give the direction of object. The calculate is : coord_1 - coord_2 = direction (or reverse)
    • Line this button create a line in direction of the object.
  • ValueAt, returns the 3D vector corresponding to a parameter value.

Sector 6: Surface and Volume

  • Surface of the form displayed, unit size can be selected.
  • Surface of the face displayed, unit size can be selected.
  • Volume of the form displayed, unit size can be selected.
  • Density of the material in kg by dm3
    (the "spinBox" is set to 7,5 kg, average density of steel. If you want a different default value, change the value of the density, line 204).
  • The gram unit mass can be chosen :
    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.
  • Weight of the form displayed, unit mass can be selected.

Sector 7: BoundBox

  • BoundBox gives extreme dimensions of the shape.

Sector 8: Center of:

  • Center of the shape and these coordinates XYZ
  • Center of mass and these coordinates XYZ
  • The button creates on point, axis, plane, copy vector axis form FreeCAD.Vector(-24.0, 240.0, 7.0)

Sector 9: Inertia

  • Moment of inertia and these coordinates length and weigth
  • The button creates on point, axis, plane, copy vector axis form FreeCAD.Vector(-24.0, 240.0, 7.0)
    • action line 1 : x1, y1, z1
    • action line 2 : x2, y2, z2
    • action line 3 : x3, y3, z3
    • action 4 diagonal : x1, y2, z3

same for length and weigth

  • Determinant 1  : computes the determinant of the matrix, in scientific value
  • Determinant 2  : computes the determinant of the matrix, in decimal value

Section 10: SpreadSheet

  • Read : read the data in a spreadsheet saved .FCInfo or txt, asc, csv
  • Save : save the data in disk in the form selected below .FCInfo or txt, asc, csv
  • Tabulation : the separator is Tabulation
  • Comma : the separator is Comma
  • Semicolon : the separator is Semicolon
  • Space : the separator is Space

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

Section 11: Main

  • CheckBox Clip Board  : if checked, the coordinates are saved in clipBoard form : FreeCAD.Vector(-24.0, 240.0, 7.0)
  • CheckBox Point  : if checked, one point is created in the coordinate displayed form : FreeCAD.Vector(-24.0, 240.0, 7.0)
  • CheckBox Axis  : if checked, one axis is created in the coordinate displayed form : FreeCAD.Vector(-24.0, 240.0, 7.0)
  • CheckBox Plane  : if checked, one axis plane is created in the coordinate displayed form : FreeCAD.Vector(-24.0, 240.0, 7.0)
  • Ref  : refresh the display of data in report view
  • Exit : exit the macro (you must restart from the tool bar button or menu "View → Panels → FCInfo"
  • CheckBox 1  : if this CheckBox is checked, the informations are displayed in the report view window
  • CheckBox 2  : if this CheckBox is not checked, the window macro are displayed to right (default). If it is checked the window macro are displayed to left

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.

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. pourcent 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

the "spinBox" is set to 7,5 kg, average density of steel. If you want a different default value, change the value of the density, line 208

global densite       ; densite       = 7.5  # (steel = 7.5 kg par dm3)

A file can be created by the button Save. The file is written as a file csv in this way, the data can be studied in a spreadsheet in FreeCAD or OpenOffice, LibreOffice...

Script

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

  • Windows: the form is usually " drive:\Users\your_user_name\AppData\Roaming\FreeCAD\ "
  • Ubuntu: the form is usually " /home/your_user_name/.FreeCAD ".

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

There is also FCInfo_Alternate_Linux for only for FreeCAD version 0.13... and PyQt4

There is also a Macro_FCInfo_Alternate_Linux. Here the code is changed (due to the character display error : ² ³ ° μ ordinal not in range (128)") which posed problems. In certain configurations the functions are the same
Example :

global uniteSs       ; uniteSs       = u"mm²"
global uniteVs       ; uniteVs       = u"mm³"
global uniteAs       ; uniteAs       = u"°"

remplacés par

global uniteSs       ; uniteSs       = "mm"+iso8859(unichr(178))
global uniteVs       ; uniteVs       = "mm"+iso8859(unichr(179))
global uniteAs       ; uniteAs       = iso8859(unichr(176))

Files saved with this version is incompatible with the other version (docked or not)


Download the icon file Macro_FCInfo_Icon unzip and copy the icon in the same directory of the macro

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.23cb 25/11/2021 delete "import Sketcher * " create conflict with "open(OpenName, "r")" ??

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)
  • ver 1.23b, 20/11/2021 little correction, add text info in beginning run macro, and ordinal the text code
  • ver 1.23 , 19/11/2021 include icon in macro, number decimal displayed, text height, configure options in the Preference FC, correct info for elements of sketch in edit mode.
  • ver 1.22 , 12/11/2020 : now the macro is totally uninstalled i use :
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
  • ver 1.21-3.01 , 07/11/2019 # 07/11/2019 ver "01.21-3-rmu" replace character micro = "U", square = "2", cube = "3", degrees = " deg" see "https://forum.freecadweb.org/viewtopic.php?f=3&t=6005&start=70#p345819"
  • ver 1.21-2.01 (1.21-rmu) 11/06/2019 rmu replace all characters over 127 in ex: "°" in chr(176)) #degree
  • ver 1.21.01 (1.21-rmu) 30/05/2019 rmu change fixed positions to qt layouts grid.addWidget() by rmu75 see the rmu75 fork "https://gist.github.com/rmu75/b165147bd1c2f2659c014103793ae1d8"
  • ver 1.21 , 16/04/2019 optimization for Py 3... Qt 5... FreeCAD 0.15 to 0.19 release
  • ver 1.20 , 29/01/2018 optimization
  • ver 1.19 , 20/01/2018 create checkBox for use detection all elements of the object if wanted or not , the macro is faster. Optimisation
  • ver 1.18 , 19/12/2017 ...
  • ver 1.17c , 14/12/2017 create plane with coordinate give in one project in other project and replace "FCInfo" by "__title__"
  • ver 1.17b , 13/12/2017 little correction replace FCTreeView to FCInfo
  • ver 1.17 , 12/12/2017 add upgrade Moment of inertia mm and kg by pinq FCMacro and moment of inertia of assembly, and create plane, axis, point, and add options separator for spreadsheet
  • ver 1.16 , 21/06/2017 add control height police (here PointSize 8) and checkbox for position the window to right or left
  • ver 1.15 , 19/12/2015 suppression PyQt4 option see , add checkBox for editing infos in report view
  • ver 1.14 , 04/08/2014 replace PyQt4 and PySide and correct tooltip not displayed cause on PySide and add fg
  • ver 1.13 , 27/07/2014 replace FCInfo_en_Ver_1-12_Docked.FCMacro to FCInfo_en_Ver_1-13_Docked.FCMacro accept PyQt4 and PySide
  • ver 1.12 , 10/03/2014 adding tooltip
  • ver 1.11 , 04/03/2014 adding µm, nm, pm, fm, µg, ng, pg, pourcent, fixed of grandeur carat "cd" in "ct", display of the label and internal name, fixed calculation of angles XY YZ ZX could give an error on a compound shape, window dockable in FreeCAD
  • ver 1.10.b , 19/11/2013 buttons outside the scrollbar and the dimensions of the window blocking

(ver 1.10 , 18/11/2013 create scrollbar)

  • ver 1.08.b , 10/11/2013 translation units in English, error correction to display the area of the faces listed in the table and replacement of the"print" by "App.Console.PrintMessage"

ver 1.09 , 04/11/2013 works perfectly on Windows and Linux (cause of errors on Linux the characters : ² ³ ° "ordinal not in range(128)")
In a Linux distribution and in the case of an error of "ordinal not in range (128)" an alternative version exists on this page Macro_FCInfo_Alternate_Linux

  • ver 1.08 , 24/10/2013 correction of high top "Faces" and "Edges" displaying 100 objects (in the saved file)
  • ver 1.07 , 11/10/2013 matches the "Faces" and their coordinates.
  • ver 1.06 , 22/09/2013 matches the "Edges" and their coordinates, inclination on the element rather than the global object
  • ver 1.05 , 17/09/2013 added an icon for the spreadsheet, conversion barrel fr, affichage des dimensions overall instead of coordinates.
  • ver 1.04 , 11/09/2013: read the file directly in a table.
  • ver 1.03 , 09/09/2013: clearer display in view report and replacement by "typeObject = sel[0].Shape.ShapeType"
  • ver 1.02 , 7/09/2013 : small updates
  • ver 1.00 , 6/09/2013

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