FreeCAD as pre-post processor for MBDyn

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by bernd »

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
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FreeCAD as pre-post procesor for MBDyn

Post by vocx »

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.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Post by josegegas »

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

Re: FreeCAD as pre-post procesor for MBDyn

Post by UR_ »

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 2675 times
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by bernd »

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: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Post by josegegas »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: FreeCAD as pre-post procesor for MBDyn

Post by microelly2 »

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
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: FreeCAD as pre-post procesor for MBDyn

Post by chrisb »

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?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
josegegas
Posts: 241
Joined: Sat Feb 11, 2017 12:54 am
Location: New Zealand

Re: FreeCAD as pre-post procesor for MBDyn

Post by josegegas »

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
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: FreeCAD as pre-post procesor for MBDyn

Post by Kunda1 »

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/
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply