Macro to compute center of mass

Show off your FreeCAD projects here!
schupin
Posts: 304
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Postby schupin » Mon Nov 12, 2018 4:42 pm

Kunda1 wrote:
Mon Nov 12, 2018 3:28 pm
Is it as simple as this?
pip install python-git --upgrade
Yes, I just had to brew upgrade python to get pip.

Then, I see a bigger list of macros, but I have an error message when I clock on it.

Code: Select all

Unable to fetch the code of this macro.Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Mod/AddonManager/AddonManager.py", line 868, in run
    self.macro.fill_details_from_wiki(url)
  File "/Applications/FreeCAD.app/Contents/Mod/AddonManager/AddonManager.py", line 686, in fill_details_from_wiki
    FreeCAD.Console.PrintWarning(translate("AddonsInstaller", "Unable to clean macro code: ") + code + '\n')
TypeError: coercing to Unicode: need string or buffer, list found
I'll post this message in a proper subforum (https://forum.freecadweb.org/viewtopic.php?f=22&t=32192)
schupin
Posts: 304
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Postby schupin » Mon Nov 12, 2018 6:06 pm

By the way, I still don't see my macro in the addon manager list :cry:
galou_breizh
Posts: 259
Joined: Wed Sep 15, 2010 9:38 am

Re: Macro to compute center of mass

Postby galou_breizh » Mon Nov 12, 2018 8:51 pm

schupin wrote:
Mon Nov 12, 2018 4:42 pm
I have an error message when I clock on it.
Can you please post your FreeCAD info?
schupin
Posts: 304
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Postby schupin » Mon Nov 12, 2018 8:53 pm

Marion52 solved this "bug" : https://forum.freecadweb.org/viewtopic.php?f=22&t=32192

My FreeCAD info are :

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.5235 (Git shallow)
Build type: Release
Branch: (HEAD detached at 2a6655e)
Hash: 2a6655e1768d80e0098d410989ae02c622f2e698
Python version: 2.7.15
Qt version: 5.11.1
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: French/France (fr_FR)
galou_breizh
Posts: 259
Joined: Wed Sep 15, 2010 9:38 am

Re: Macro to compute center of mass

Postby galou_breizh » Mon Nov 12, 2018 9:40 pm

Good news! Do you see your macro in the list of installable macros now?
schupin
Posts: 304
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Postby schupin » Mon Nov 12, 2018 10:12 pm

Unfortunalty no :(

I guess it should be around here in the list ?
AddonManagerCapture.png
AddonManagerCapture.png (59.44 KiB) Viewed 1127 times
mario52
Posts: 2681
Joined: Wed May 16, 2012 2:13 pm

Re: Macro to compute center of mass

Postby mario52 » Tue Nov 13, 2018 3:49 pm

hi

done i create the wiki page Macro_CenterOfMass

@schupin
for modify or translate the page in french see here How to get wiki editing permissions good for the nextssss macrossss

PS:choice or create on representative icon for the toolBar

to be visible in Addon manager (tab Macros) the macro must be present on this page Macros_recipes

@galou_breizh
if you create wiki page without code or if you delete the code (screwmaker) present in page for external download, use this template :

{{Codeextralink|and here giving the address of the RAW page of the macro }}

(just under Description)

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
UR_
Posts: 1012
Joined: Tue Jan 03, 2017 8:42 pm

Re: Macro to compute center of mass

Postby UR_ » Fri Nov 16, 2018 7:26 pm

Just installed your macro with addonmanager
immediately got this:
Traceback (most recent call last):
File "C:/Users/aio/AppData/Roaming/FreeCAD/Macro/CenterOfMass.FCMacro", line 41, in <module>
from freecad import app
<type 'exceptions.ImportError'>: cannot import name app
:roll:
schupin
Posts: 304
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Postby schupin » Sat Nov 17, 2018 11:45 am

UR_ wrote:
Fri Nov 16, 2018 7:26 pm
Just installed your macro with addonmanager
immediately got this:
Traceback (most recent call last):
File "C:/Users/aio/AppData/Roaming/FreeCAD/Macro/CenterOfMass.FCMacro", line 41, in <module>
from freecad import app
<type 'exceptions.ImportError'>: cannot import name app
:roll:
This is strange, from freecad import app is used in a lot of macros.
What are your system informations ?

By the way, there are some bugs on the version provided via the addon manager. I did a pull request 5 days ago, I don't when it will be merge.
UR_
Posts: 1012
Joined: Tue Jan 03, 2017 8:42 pm

Re: Macro to compute center of mass

Postby UR_ » Sat Nov 17, 2018 12:25 pm

schupin wrote:
Sat Nov 17, 2018 11:45 am
This is strange,
Occurs on both versions:


OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15213 (Git)
Build type: Release
Branch: master
Hash: af36a78f7f333473b0c2541c4038d60017658f22
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)



OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15150 (Git)
Build type: Release
Branch: master
Hash: fe8f172ce1f725cbc5e7a1538beaaac6a6529ec2
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)




I had to do something like this, to get it to work

CenterOfMassUR.FCMacro
(30.76 KiB) Downloaded 63 times

EDIT: Perhaps for reference: https://forum.freecadweb.org/viewtopic. ... 62#p267686