FreeCAD as pre-post procesor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
bernd
Posts: 8439
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FreeCAD as pre-post procesor for MBDyn

Postby bernd » Mon Oct 07, 2019 7:28 pm

vocx wrote:
Mon Oct 07, 2019 5:40 pm
By the way, when you are building paths, it's best to use Python's os.path functions. I would also avoid variables with double underscores as these are typically reserved for special internal properties.

Code: Select all

__dir__ + "/MBDyn/MBDynCase.mbd"

os.path.join(__dir__, "MBDyn/MBDynCase.mbd")
Found there is something even better a few weeks ago ... https://docs.python.org/3/library/pathlib.html On my own code I have switched to pathlib, but on such a big code base as FEM it would be quit some work and for sure some problems will come up. Thus I leave it for now with os.path even if we have in FEM on windows some paths with mixed slash and backslash. :o I works without problems but I do not like it ...

If I would do something new I would take pathlib right from the beginning.
vocx
Posts: 1652
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby vocx » Mon Oct 07, 2019 9:51 pm

bernd wrote:
Mon Oct 07, 2019 7:28 pm
...
If I would do something new I would take pathlib right from the beginning.
I guess that's fine if you know you won't use Python 2 at all. But also, pathlib looks a bit over engineered (object oriented of course). I guess it's fine if you are going to handle a lot of paths, but if you are doing simple concatenation to get just one file I think it's overkill, and os.path is simpler.
josegegas
Posts: 32
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Thu Oct 10, 2019 2:02 pm

Made some progress with my animation algorithm....

phpBB [video]

In a similar way as the reaction forces, I'd lice to animate the reaction torque over the joints. MBDyn gives the torque too, but i don't have many ideas on how to animate a torque. Forces are simple. Length of the line is force magnitude, and line direction is force direction. Does anyone have an idea how to animate a torque? Can one animate arcs with FreeCAD, as I do with the lines for the forces? Suggestions?

Cheers.
Last edited by Kunda1 on Thu Oct 10, 2019 5:15 pm, edited 1 time in total.
Reason: added video tags
UR_
Posts: 991
Joined: Tue Jan 03, 2017 8:42 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby UR_ » Thu Oct 10, 2019 4:42 pm

josegegas wrote:
Thu Oct 10, 2019 2:02 pm
Does anyone have an idea how to animate a torque?

Usually double headed arrows are used to visualize torque vectors

torque.png
torque.png (20.38 KiB) Viewed 564 times
User avatar
bernd
Posts: 8439
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FreeCAD as pre-post procesor for MBDyn

Postby bernd » Thu Oct 10, 2019 5:01 pm

UR_ wrote:
Thu Oct 10, 2019 4:42 pm
josegegas wrote:
Thu Oct 10, 2019 2:02 pm
Does anyone have an idea how to animate a torque?
Usually double headed arrows are used to visualize torque vectors
same for me in structural engineering

BTW: nice pic. Is this FreeCAD?
josegegas
Posts: 32
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Fri Oct 25, 2019 5:45 am

Hi. Couple of questions:

When the user changes a property of a scripted object, the "onChanged" method gets executed. Is there a way to change the values of other properties of the same object, from within the "onChanged" method? I want the "onChanged" to do some calculations using the value of the changed property, and update other properties with the results. How can I achieve this?

The second question is: there are:

App::PropertyDistance
App::PropertyLength
App::PropertySpeed
App::PropertyAcceleration
App::PropertyForce
App::PropertyPressure

But there is no App::PropertyMass? At least I get an error saying App::PropertyMass does not exist. I would like to store something like:

Quantity(self.volume*self.density,Unit('kg'))

in a property, but I don't want to use a simple string property...

Cheers!!
User avatar
microelly2
Posts: 4411
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Postby microelly2 » Fri Oct 25, 2019 6:35 am

josegegas wrote:
Fri Oct 25, 2019 5:45 am
When the user changes a property of a scripted object, the "onChanged" method gets executed. Is there a way to change the values of other properties of the same object, from within the "onChanged" method? I want the "onChanged" to do some calculations using the value of the changed property, and update other properties with the results. How can I achieve this?
You can do this but you have to add some code to stop recursive calls of the onChanged method.
chrisb
Posts: 18898
Joined: Tue Mar 17, 2015 9:14 am

Re: FreeCAD as pre-post procesor for MBDyn

Postby chrisb » Fri Oct 25, 2019 6:37 am

josegegas wrote:
Fri Oct 25, 2019 5:45 am
When the user changes a property of a scripted object, the "onChanged" method gets executed. Is there a way to change the values of other properties of the same object, from within the "onChanged" method? I want the "onChanged" to do some calculations using the value of the changed property, and update other properties with the results. How can I achieve this?
Is this an FEM question or a general python programming question?
josegegas
Posts: 32
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Postby josegegas » Fri Oct 25, 2019 10:17 pm

Simulating the tennis racket theorem with MBDyn + FreeCAD :D

https://www.youtube.com/watch?v=On72bOD ... e=youtu.be

Here's a video explaining this behavior:

https://www.youtube.com/watch?v=1VPfZ_XzisU

And the original MBDyn exercise:

https://www.sky-engin.jp/en/MBDynTutori ... hap09.html

Enjoy!!
User avatar
Kunda1
Posts: 5781
Joined: Thu Jan 05, 2017 9:03 pm

Re: FreeCAD as pre-post procesor for MBDyn

Postby Kunda1 » Fri Nov 01, 2019 1:22 pm

josegegas wrote:
Fri Oct 25, 2019 10:17 pm
Simulating the tennis racket theorem with MBDyn + FreeCAD :D
That's awesome!

BTW, is this something that you think eventually can be modeled ?

phpBB [video]

(we can't view .gifv :( )
https://www.reddit.com/r/Automate/comme ... _pendulum/
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features