ShaftDesign not fully functional on v0.20

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
User avatar
uwestoehr
Veteran
Posts: 4320
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: ShaftDesign not fully functional on v0.20

Post by uwestoehr »

There is now for me only this bug left:

- in the PD workbench go to menu Part Design -> Shaft design wizard
- in the appearing dialog click on the button "w [z]"

result:

Code: Select all

16:16:35  Traceback (most recent call last):
16:16:35    File "D:\FreeCAD-build\Mod\PartDesign\WizardShaft\WizardShaft.py", line 131, in slotWz
16:16:35      self.showDiagram("wz")
16:16:35    File "D:\FreeCAD-build\Mod\PartDesign\WizardShaft\WizardShaft.py", line 97, in showDiagram
16:16:35      self.shaft.showDiagram(diagram)
16:16:35    File "D:\FreeCAD-build\Mod\PartDesign\WizardShaft\Shaft.py", line 249, in showDiagram
16:16:35      self.diagrams[self.w[ax].name].close()
16:16:35    File "D:\FreeCAD-build\Mod\PartDesign\WizardShaft\ShaftDiagram.py", line 88, in close
16:16:35      self.win.parent().close()
16:16:35  RuntimeError: Internal C++ object (Plot) already deleted.
@johnwang, do you have an idea? It seems the code tried to close a plot that is not existent.
User avatar
Kuzma30
Posts: 139
Joined: Wed Oct 24, 2018 11:50 am
Location: Ukraine

Re: ShaftDesign not fully functional on v0.20

Post by Kuzma30 »

uwestoehr wrote: Wed Jun 01, 2022 2:15 pm
uwestoehr wrote: Wed Jun 01, 2022 11:57 am I removed it and restarted FC but the error persists.
Seems I had something cached somewhere. Now it works and I committed the fix:
https://github.com/FreeCAD/FreeCAD/commit/2de25dd04e

@Kuzma30 , please test if this works for you as well now.
Test on initial example. All works (Q[z], Mb[y], sigma[z] and sigmab[y]), except w[z]

Code: Select all

18:03:55  Traceback (most recent call last):
18:03:55    File "/home/aleksandr/test_crowdin/FreeCAD-build-master/Mod/PartDesign/WizardShaft/WizardShaft.py", line 131, in slotWz
18:03:55      self.showDiagram("wz")
18:03:55    File "/home/aleksandr/test_crowdin/FreeCAD-build-master/Mod/PartDesign/WizardShaft/WizardShaft.py", line 97, in showDiagram
18:03:55      self.shaft.showDiagram(diagram)
18:03:55    File "/home/aleksandr/test_crowdin/FreeCAD-build-master/Mod/PartDesign/WizardShaft/Shaft.py", line 253, in showDiagram
18:03:55      self.diagrams[self.w[ax].name].create(text[0], self.w[ax], self.getLengthTo(len(self.segments)) / 1000.0, text[1], text[2], 1000.0, text[3], text[4], 1000.0, 30)
18:03:55    File "/home/aleksandr/test_crowdin/FreeCAD-build-master/Mod/PartDesign/WizardShaft/ShaftDiagram.py", line 54, in create
18:03:55      self.plot()
18:03:55    File "/home/aleksandr/test_crowdin/FreeCAD-build-master/Mod/PartDesign/WizardShaft/ShaftDiagram.py", line 82, in plot
18:03:55      axes.set_xlim(right = max(self.xpoints) * 1.05)
18:03:55  ValueError: max() arg is an empty sequence
RealThunder's A3 Wiki translation, join the project https://crowdin.com/project/freecad-asm3-wiki
User avatar
chennes
Veteran
Posts: 2249
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: ShaftDesign not fully functional on v0.20

Post by chennes »

I get the same error as @Kuzma30 -- it seems to stem from the following comment in SegmentFunction.py:

Code: Select all

        # Coverity has reported a problem that I_i, C_i0 or C_i1:
        # Bad use of null-like value (CIDs are 192609, 192611, 192616)
        # Since this code doesn't seem to be used anywhere the problematic
        # part will be commented out
        #for xval in sorted(xvals):
        #    if xval in divs:
        #        i = self.intfunc.index(xval)
        #        (begin,  length) = self.intfunc.interval(xval)
        #        I_i = self.intfunc.value(xval)
        #        C_i0 = self.boundaries[2 * i]
        #        C_i1 = self.boundaries[2 * i + 1]
        #        FreeCAD.Console.PrintMessage("Interval %u: %f to %f, I_i: %f, C_i0: %f, C_i1: %f\n" % (i,  begin, length,  I_i,  C_i0,  C_i1))
        #
        #    xresult.append(xval)
        #    # w(xval) = (transfunc(xval) + C_i0 * xval + C_i1) / (E * I_i)
        #    value = (self.transfunc.value(xval)  + C_i0 * xval + C_i1) / (E * I_i)
        #    yresult.append(value)
            
        return (xresult, yresult)
So the code that actually creates xresult and yresult has been commented out to appease the static analyzer. I've submitted a PR that reverts this change -- I don't know if Coverity is concerned about a case in which those array indices are out of bounds, but at any rate it seems to be it's better to have working code that might have a bug, than non-functional code that certainly has a bug!

https://github.com/FreeCAD/FreeCAD/pull/6954
Chris Hennes
Pioneer Library System
User avatar
Kunda1
Veteran
Posts: 12751
Joined: Thu Jan 05, 2017 9:03 pm

Re: ShaftDesign not fully functional on v0.20

Post by Kunda1 »

Merged in git commit d860c4b
Thanks @chennes!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
johnwang
Veteran
Posts: 1103
Joined: Sun Jan 27, 2019 12:41 am

Re: ShaftDesign not fully functional on v0.20

Post by johnwang »

uwestoehr wrote: Wed Jun 01, 2022 2:15 pm I committed the fix:
Thx.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
johnwang
Veteran
Posts: 1103
Joined: Sun Jan 27, 2019 12:41 am

Re: ShaftDesign not fully functional on v0.20

Post by johnwang »

user1234 wrote: Wed Jun 01, 2022 2:14 pm I would say that. Maybe a very dirty solution, remove the menu entry?
It is hard to get in, so if it is there for a long time, better keep it.
It is really a good example to do some design tools. Hope it will inspire others to get started
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
user1234
Veteran
Posts: 1750
Joined: Mon Jul 11, 2016 5:08 pm

Re: ShaftDesign not fully functional on v0.20

Post by user1234 »

johnwang wrote: Thu Jun 02, 2022 9:10 am It is really a good example to do some design tools. Hope it will inspire others to get started
I do not agree. Only plotting along an axis through a know section, gives never valid result (no factors of notches, surfaces, section areas, load variation ..... which are some each other braced). Even a simple stepped shaft will not be valid. I think this functions really dangerous, if some does not know more about constructing and looks only on the sigma (tension) or tau (shear).

Greetings
user1234

edit: blue
User avatar
uwestoehr
Veteran
Posts: 4320
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: ShaftDesign not fully functional on v0.20

Post by uwestoehr »

user1234 wrote: Thu Jun 02, 2022 12:53 pm Only plotting along an axis through a know section, gives never valid result (no factors of notches, surfaces, section areas, load variation
I agree. It is really dangerous when people would take these results. I mean the feature does not even allow you to set the material parameters. Now it is too late but for the next FreeCAD version, the feature should be moved to the FEM workbench so that one can set the material parameters and also use it for shafts in a custom design (e.g. D-shape tip like for many electric motors, holes etc.)
user1234
Veteran
Posts: 1750
Joined: Mon Jul 11, 2016 5:08 pm

Re: ShaftDesign not fully functional on v0.20

Post by user1234 »

uwestoehr wrote: Thu Jun 02, 2022 1:12 pm Now it is too late
I know, and agree with you. If it is now in it, it is no bonebreaker. I just wanted to point it out, why it is no good function.


Greetings
user1234
Post Reply