Macro to compute center of mass

Show off your FreeCAD projects here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
schupin
Posts: 476
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Post by schupin »

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: 476
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Post by schupin »

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

Re: Macro to compute center of mass

Post by galou_breizh »

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: 476
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Post by schupin »

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: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Macro to compute center of mass

Post by galou_breizh »

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

Re: Macro to compute center of mass

Post by schupin »

Unfortunalty no :(

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

Re: Macro to compute center of mass

Post by mario52 »

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, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Macro to compute center of mass

Post by UR_ »

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: 476
Joined: Sun Jan 21, 2018 1:43 pm

Re: Macro to compute center of mass

Post by schupin »

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_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Macro to compute center of mass

Post by UR_ »

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 141 times

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