Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

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!
PAS_Drafter
Posts: 339
Joined: Mon Aug 02, 2021 6:29 am
Location: California, USA

Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by PAS_Drafter »

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +99 (Git)
Build type: Release
Branch: Branch_0.19.3
Hash: 6530e364184ce05ccff39501e175cf2237e6ee4b
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United States (en_US)

I am trying to do a simple sheetmetal bend and all of the sudden I started getting this error and it won't finish the bend. I have a simple square part made from the parts workbench and am attempting to bend one edge.

It was working earlier and then I checked for updates for Sheetmetal and installed it and then the problem started happening.
Attachments
Weldcraft_Power_Box_Mount_Bracket.FCStd
(16.24 KiB) Downloaded 19 times
PAS_Drafter
Posts: 339
Joined: Mon Aug 02, 2021 6:29 am
Location: California, USA

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by PAS_Drafter »

Shalmeneser wrote: Tue Aug 02, 2022 5:50 pm A Std_Refresh is enough.
I've tried that multiple times myself (as well as again after you recommended it) and I'm still getting that error.

I've tried it in Version 0.20 and the error doesn't seem to happen there. So it must be something related to running on version 0.19.

Unfortunately, I've had to go back to using 0.19 as I have not had much luck with 0.20 being very stable when it comes to using Spreadsheets. I use a Master Spreadsheet. Each part I build links data from the Master Spreadsheet and imports the important measurements so that if I change a value in the master, it gets passed down to all the parts that require that change. In 0.19 when I made a change to the Master, I'd have to go to each open spreadsheet and manually update the imported cell for the changes to take effect which was a pain. However, once I did that, at least all the cells in that spreadsheet would automatically update. Unfortunately ever since 0.20, after I update the value for the imported data, I have to go and manually recompute each CELL in the linked spreadsheets for the changes to take place. Using the recompute all button doesn't seem to help. The only other choice I have is to close all the open documents every time I want to update and then reopen them which is also a pain.

So I'm stuck with 0.19 for now and would like to know what is causing this error in that version so I can avoid it.
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by Syres »

PAS_Drafter wrote: Tue Aug 02, 2022 6:03 pm So I'm stuck with 0.19 for now and would like to know what is causing this error in that version so I can avoid it.
You're not the first user that has had to stick with 0.19.x so I've not an issue with that but I'm not downgrading mine from 0.19.4 to 0.19.3 so I've attached my file after pressing F5. You are using the very latest version of Sheetmetal Wb (0.2.50)? Now I realise my Sheetmetal Wb hasn't upgraded properly so it must be a Sheetmetal change in the last few days that I'm guessing is the root cause.

OS: Windows 7 Version 6.1 (Build 7601: SP 1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United Kingdom (en_GB)


Edit: Sheetmetal Version issue
Attachments
Weldcraft_Power_Box_Mount_Bracket_Syres.FCStd
(20.73 KiB) Downloaded 12 times
PAS_Drafter
Posts: 339
Joined: Mon Aug 02, 2021 6:29 am
Location: California, USA

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by PAS_Drafter »

Syres wrote: Tue Aug 02, 2022 6:17 pm You're not the first user that has had to stick with 0.19.x
Thanks, glad I'm not the only one have a few bugs. Most of what I see in .20 is great. It just happens the Spreadsheet problem for me has caused me more grief than I care to deal with right now.

I downloaded your file and when I brought it into my v0.19 the error was gone, but as soon as I created another bend it was back again. I shouldn't have updated my Sheetmetal module this morning. :-(
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by Syres »

PAS_Drafter wrote: Tue Aug 02, 2022 6:36 pm I downloaded your file and when I brought it into my v0.19 the error was gone, but as soon as I created another bend it was back again. I shouldn't have updated my Sheetmetal module this morning. :-(
It's not a difficult fix (as long as it doesn't cause other regressions). Locate your Sheetmetal Wb folder usually in C:\Users\username\AppData\Roaming\FreeCAD\Mod\sheetmetal and open the file SheetMetalCmd.py (with FreeCAD closed)
Navigate down to line 363 and replace:

Code: Select all

    pThkDir1 = selFace.CenterOfGravity
    pThkDir2 = lenEdge.Curve.value(lenEdge.Curve.parameter(pThkDir1))
    thkDir = pThkDir1.sub(pThkDir2).normalize()
with:

Code: Select all

    if hasattr(lenEdge.Curve, "projectPoint") :
      pThkDir1 = selFace.CenterOfGravity
      pThkDir2 = lenEdge.Curve.projectPoint(pThkDir1, "NearestPoint")
      thkDir = pThkDir1.sub(pThkDir2).normalize()
    else:
      thkDir = Cface.normalAt(0,0) * -1
Save the file and start FreeCAD, open your original file and press F5, all should be OK now. I'll try and submit a proper fix to the author.
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by Syres »

Roy_043 wrote: ping
I know 0.19.x perhaps shouldn't be actively supported but I've tried to come up with a fix to allow multiple versions to still work correctly, your feedback would be welcome https://github.com/shaise/FreeCAD_Sheet ... al:patch-1
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by adrianinsaval »

Syres wrote: Tue Aug 02, 2022 7:12 pm
shouldn't you be adressing @shaise instead?
PAS_Drafter wrote: Tue Aug 02, 2022 6:03 pm Unfortunately ever since 0.20, after I update the value for the imported data, I have to go and manually recompute each CELL in the linked spreadsheets for the changes to take place. Using the recompute all button doesn't seem to help. The only other choice I have is to close all the open documents every time I want to update and then reopen them which is also a pain.
That sounds like a bug, please make a proper report, preferably with an example file, of this issue so that it can be addressed, it's hard for the devs to fix bugs they aren't aware of!
PAS_Drafter
Posts: 339
Joined: Mon Aug 02, 2021 6:29 am
Location: California, USA

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by PAS_Drafter »

Syres wrote: Tue Aug 02, 2022 6:41 pm It's not a difficult fix
Thanks. That did get my v0.19 working again.

adrianinsaval wrote: Tue Aug 02, 2022 7:56 pm That sounds like a bug, please make a proper report, preferably with an example file, of this issue so that it can be addressed, it's hard for the devs to fix bugs they aren't aware of!
You are correct and I understand how hard it is to solve a problem without data. Unfortunately, the files I'm having the problems with are proprietary and I can't upload them. I've tried a couple of times to duplicate the problem with some generic data, but I just haven't been able to duplicate it. I'm currently behind the gun and trying to complete a project so have just dealt with the limitation for the time being until I can get some time to try getting a sample file together that shows the problem.
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Sheetmetal gives "Part Face" object has no attribute "CenterOfGravity"

Post by Syres »

adrianinsaval wrote: Tue Aug 02, 2022 7:56 pm shouldn't you be adressing @shaise instead?
No, it's good manners to address the author of the PR that caused the bug first.
Post Reply