FCInfo Macro

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Hol1976
Posts: 2
Joined: Tue Mar 04, 2014 5:08 pm

FCInfo Macro

Postby Hol1976 » Tue Mar 04, 2014 5:23 pm

Hello,

As a beginner I have a question about using the Macro from Mario "FCInfo":
I tried the macro for several times, because I want to know some elementary Informations about my parts like volume, area and the Center of gravity - but it doesn´t work.

"Non-ASCII character ´\\xc2´ in file D:/FreeCAD 0.13/FCInfo.FCMacro on line 129, but no Encoding declared"

Perhaps someone knows the solution?

greetings and thanks
from Hol1976
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FCInfo Macro

Postby jmaustpc » Tue Mar 04, 2014 6:35 pm

Did you download it from here

viewtopic.php?f=10&t=3185&p=47748#p47748

and which version English or French?
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FCInfo Macro

Postby jmaustpc » Tue Mar 04, 2014 6:52 pm

I just tried the English version with FreeCAD version below and it only partly worked.

OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3248 (Git)
Branch: master
Hash: e398f3ee7ee0b2f95b79a0b423b4a4352c56721a
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0


It did not produce a window, but it did put some information in my Report view. And an error message

I tested it with a default Part Cylinder

this is the out put from my report view copy and pasted.



Beginning___________________________________________________________________
Document name : Unnamed
Label of the object : Cylinder
Internal name : Cylinder
Element name :
Object type : Solid
Mouse coordinates : X: 0.0, Y: 0.0, Z: 0.0
Length of the object : 0.0, mm
Perimeter of the shape : 35.1327412287, mm

Vertexes and details : (3) (3) (4) (10)
Edge1 = 12.5663706144 mm
X1: 2.0
Y1: -4.89842541529e-16
Z1: 10.0
-
-
-

Edge2 = 10.0 mm
X1: 2.0
Y1: -4.89842541529e-16
Z1: 10.0
X2: 2.0
Y2: -4.89842541529e-16
Z2: 0.0

Edge3 = 12.5663706144 mm
X1: 2.0
Y1: -4.89842541529e-16
Z1: 0.0
-
-
-

Face1 = 125.663706144 mm²
X1: 2.0
Y1: -4.89842541529e-16
Z1: 10.0
X2: 2.0
Y2: -4.89842541529e-16
Z2: 0.0

Face2 = 12.5663706144 mm²
X1: 2.0
Y1: -4.89842541529e-16
Z1: 10.0

Face3 = 12.5663706144 mm²
X1: 2.0
Y1: -4.89842541529e-16
Z1: 0.0

Plan : XY: 0.0° coordinates: [,0.0 , 0.0,] [,0.0 , 0.0,]
Plan : YZ: 0.0° coordinates: [,0.0 , 0.0,] [,0.0 , 0.0,]
Plan : ZX: 0.0° coordinates: [,0.0 , 0.0,] [,0.0 , 0.0,]

The form surface : 150.796447372 mm²
The face surface : 0.0 mm²

Volume of the form : 125.663706144 mm³
Weight : 0.942477796077 g (Density : 7.5)

Center of the shape : X: 0.0 Y: 0.0 Z: 5.0
Center of mass : X: -2.54444374517e-16 Y: 1.9190378453e-17 Z: 5.0
Overall dimensions : [X: 4.0 mm] x [Y: 3.99210691371 mm] x [Z:10.0 mm]

Matrix of inertia : X: 1172.86125734 Y: 2.5559536337e-15 Z: 1.7763568394e-14 : 0.0
: X: 2.5559536337e-15 Y: 1172.86125734 Z: 6.53975343377e-16 : 0.0
: X: 1.7763568394e-14 Y: 6.53975343377e-16 Z: 251.327412287 : 0.0
: X: 0.0 Y: 0.0 Z: 0.0 : 1.0
End_____________________________________________________________
Traceback (most recent call last):
File "/home/user/.FreeCAD/FCInfo_en.py", line 2328, in <module>
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'addDockWidget'



Jim
Hol1976
Posts: 2
Joined: Tue Mar 04, 2014 5:08 pm

Re: FCInfo Macro

Postby Hol1976 » Wed Mar 05, 2014 11:20 am

Hallo,

I tried both Versions (english and frensh), but nothing works. I created a macro like described in the Manual (FCInfo.FCMacro), but every time I started the marcro, the error message (see below) appears.

Yesterday I copied the updated Version with the ending *.py in the Directory "Mod" but without results after staring. There is no window that appears with Part-Informations or something else, I can see the error message in the additional window of the "Python"-console.

I work with Windows 7 (64bit) and the Python-Version 2.6.
mario52
Posts: 2685
Joined: Wed May 16, 2012 2:13 pm

Re: FCInfo Macro

Postby mario52 » Thu Mar 06, 2014 12:31 pm

Hi
Thank you for the return want try you the older version that is not docked.
For me all versions, works very well (Vista sp2). If older versions work well for you, I'll add the latest changes, correction and put online the docked version and the version not docked.
jmaustpc wrote:Traceback (most recent call last):
File "/home/user/.FreeCAD/FCInfo_en.py", line 2328, in <module>
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'addDockWidget'
I see that the error occurs at the end of the procedure but I do not have the knowledge to correct this error! Sorry on vista the macro works fine and if I did not reproduce the error...
PS: false zip delete ".zip" I leave the old name to find me, you can rename the files.
_______en_FCInfo.py.zip
en_FCInfo.py
(95.43 KiB) Downloaded 167 times
_______AnglaisFCInfo_Test_Ubuntu_02.py.zip
_______AnglaisFCInfo_Test_Ubuntu_02.py
(96.18 KiB) Downloaded 122 times
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FCInfo Macro

Postby jmaustpc » Thu Mar 06, 2014 2:00 pm

Hi Mario
mario52 wrote:PS: false zip delete ".zip" I leave the old name to find me, you can rename the files.

_______en_FCInfo.py.zip
en_FCInfo.py
(95.43 KiB) Downloaded 1 time


_______AnglaisFCInfo_Test_Ubuntu_02.py.zip
_______AnglaisFCInfo_Test_Ubuntu_02.py
(96.18 KiB) Downloaded 1 time
Both of these worked for me. :-)

OS: Kubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3258 (Git)
Branch: master
Hash: 92253429c5cf3ebf8a308d3c563d423b29aacdd3
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0


Jim
mario52
Posts: 2685
Joined: Wed May 16, 2012 2:13 pm

Re: FCInfo Macro

Postby mario52 » Thu Mar 06, 2014 3:17 pm

Hi jmaustpc
I think I'll update and make 2 versions a docked and the other not.
(These two versions have errors carat "cd" must be "ct", calculation of angles XY YZ ZX good for a simple object but could give an error on a compound shape)
thanks
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
mario52
Posts: 2685
Joined: Wed May 16, 2012 2:13 pm

Re: FCInfo Macro

Postby mario52 » Thu Mar 06, 2014 8:50 pm

Hi
I have updated and corrected the error is that they work well ?

(ps: Volant = not docked)
FCInfo_en_Ver_1-11_Volant.py.zip
FCInfo_en_Ver_1-11_Volant.py
(99.24 KiB) Downloaded 223 times
FCInfo_fr_Ver_1-11_Volant.py.zip
FCInfo_fr_Ver_1-11_Volant.py
(100.14 KiB) Downloaded 157 times

(Not yet _______AnglaisFCInfo_Test_Ubuntu_02.py.zip)
thanks
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FCInfo Macro

Postby jmaustpc » Fri Mar 07, 2014 7:01 am

Hi Mario

I tried
FCInfo_en_Ver_1-11_Volant.py.zip,

on a default Part Box, Cylinder and Cone.

I deleted the ".zip" and executed the macro,

On these simple shapes at least, it seems to work perfectly! :)

Then I tried a very much more complicated shape, it still seems to partly work, but then it popped up a error window "Process aborted", although when I clicked "OK" and dismissed the error window and look back at your macro window, it appears to have worked. But this was the shape that had many faults from a recent post on this forum, so it might not mean very much. I will do some more testing.


Some little things, :)
1) the 4th button at the bottom "Ref", is not clear what that means or does, I did work it out eventually, it means "refresh". :) I think a new user would find that confusing. I think it would be best to change it to "Refresh, or Reload or something else, if you can not fit he word in then perhaps it could be better to use the FreeCAD "recompute" icon?
2) The window is a floating window that, as far as I can see is not dockable...this is OK, if that is what you want, but did you intend for it to be dockable? Here is a screen shot.
marios_infomacro.png
marios_infomacro.png (415.04 KiB) Viewed 4735 times

3) the two different versions in your last post seem to me to be the same...am I missing something?...what is supposed to be different between these two versions of your macro?
mario52 wrote:PS: false zip delete ".zip" I leave the old name to find me, you can rename the files.

_______en_FCInfo.py.zip
en_FCInfo.py
(95.43 KiB) Downloaded 1 time


_______AnglaisFCInfo_Test_Ubuntu_02.py.zip
_______AnglaisFCInfo_Test_Ubuntu_02.py

4) the "save" does not remember the last used directory, every time I try to save the output file, it tries to save into the FreeCAD build directory, that is, one directory up from the directory in which FreeCAD executable file is located.

This is my version data: -

OS: Kubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3259 (Git)
Branch: master
Hash: 040c19b1c1618043631e45c74ddd30536cf09252
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0

In summary ....Well Done!!! :)
Jim
mario52
Posts: 2685
Joined: Wed May 16, 2012 2:13 pm

Re: FCInfo Macro

Postby mario52 » Fri Mar 07, 2014 1:50 pm

hi jmaustpc
Thanks for this study and I will explain everything ,
jmaustpc wrote:but then it popped up a error window "Process aborted",
This error happens when you click on save and that leave you the window by cancel (without selecting file)
jmaustpc wrote:the 4th button at the bottom "Ref", is not clear
Yes Ref = Refresh You can test it by clearing the report view and after click on Ref. I add a tooltip
jmaustpc wrote:2) The window is a floating window that, as far as I can see is not dockable...this is OK, if that is what you want, but did you intend for it to be dockable? Here is a screen shot.
Not on this macro window is flying to compensate for the error "<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'addDockWidget'' of the model docked
jmaustpc wrote:the two different versions in your last post seem to me to be the same...am I missing something?...what is supposed to be different between these two versions of your macro?
not you have nothing missed it did only a single macro

FCInfo_en.py.zip the latest full and final docked that I would like that it works well (french and english)

FCInfo_en_Ver_1-11_Volant.py.zip which is the same version but not docked (volant flying ) (french and english)

_______AnglaisFCInfo_Test_Ubuntu_02.py.zip (french and english) which is the same version not docked (not yet updated) the difference, different encoding because of the mistakes that I had in Kubuntu (usb key) ex:

FCInfo_en

Code: Select all

global uniteSs       ; uniteSs       = u"mm²"
global uniteVs       ; uniteVs       = u"mm³"
global uniteAs       ; uniteAs       = u"°"
differences
_______AnglaisFCInfo_Test_Ubuntu_02.py.zip (Macro FCInfo Alternate Linux)

Code: Select all

global uniteSs       ; uniteSs       = "mm"+iso8859(unichr(178))
global uniteVs       ; uniteVs       = "mm"+iso8859(unichr(179))
global uniteAs       ; uniteAs       = iso8859(unichr(176))
with the addition of this procedure

Code: Select all

def uniBuntu (coding):
return code [:-1]+unichr(ord(coder[-1]))
and I did have more errors in kubuntu !
and later I went back in kubuntu and... two models worked perfectly ??? like you with FCInfo_en_Ver_1 - 11_Volant.py which is not _______AnglaisFCInfo_Test_Ubuntu_02.py

hi Hol1976
have you tried the other macro FCInfo_en_Ver_1-11_Volant.py.zip

ps:I hope that bing has translated well
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.