What's the error ?
FreeCAD as pre-post processor for MBDyn
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: FreeCAD as pre-post procesor for MBDyn
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
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
Re: FreeCAD as pre-post procesor for MBDyn
[/quote]
What's the error ?
[/quote]
ImportError: No module named pandas. I'm sure pandas is installed aand works fine cause I don't have any issue using it from elsewhere than FreeCAD
What's the error ?
[/quote]
ImportError: No module named pandas. I'm sure pandas is installed aand works fine cause I don't have any issue using it from elsewhere than FreeCAD
Re: FreeCAD as pre-post procesor for MBDyn
How did you install pandas? If you installed it through pip or some virtual Python environment, it's possible the base FreeCAD system doesn't find it.
Usually for these big packages it's best to install it through the package manager, for example,
Code: Select all
sudo apt install python3-pandas
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: FreeCAD as pre-post procesor for MBDyn
os.system was working nicely but when I do:vocx wrote: ↑Wed Sep 11, 2019 4:22 pmMaybe that was a prototype. I presume jose is planning on setting this up from a single button press, just like the FEM Workbench does.
In any case, yes, Python can run arbitrary programs. The very old way of doing it, is usingBut the recommended way nowadays is with the subprocess module.Code: Select all
os.system("mbdyn -options input.file")
Code: Select all
import subprocess subprocess.run(["mbdyn", "-options", "input.file"], capture_output=True)
subprocess.run(["mbdyn", "-f",__dir__+"/MBDyn/MBDynCase.mbd"])
It just doesn't work, don't really know why. However when I do:
subprocess.call(["mbdyn", "-f",__dir__+"/MBDyn/MBDynCase.mbd"])
It executes MBDyn well, bit I'd like to capture the MBDyn output and show it in FreeCAD gui, any ideas?
Re: FreeCAD as pre-post procesor for MBDyn
"Just doesn't work" is not a good description of the problem. Please provide more information.
The subprocess functions have varied over the life of Python 3, so run() is not available before Python 3.5, but call() is. Maybe this is the problem?
Otherwise, check the different options in the manual.
In this very thread we already told you to check the FEM code. In that case, they use Popen() which is a bit of a lower level call. Both run() and call() essentially use Popen().It executes MBDyn well, bit I'd like to capture the MBDyn output and show it in FreeCAD gui, any ideas?
vocx wrote: ↑Thu Sep 12, 2019 12:23 amIt seems FEM uses Popen(). https://github.com/berndhahnebach/FreeC ... ks.py#L105Code: Select all
out = subprocess.run(["ls", "-l", "/usr/share/freecad"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8") print(out.stdout)
This is the internal class, while the high level functions are run() (for Python 3.5 and above), or the older call(), check_call(), and check_output() (for Python 3.4 and below).The standard output or standard error then can be printed in the terminal, the FreeCAD console, or used in some Qt dialogs.Code: Select all
process = subprocess.Popen(["ls", "-l", "/usr/share/freecad"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8") out, err = process.communicate() print(out) print(err)
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: FreeCAD as pre-post procesor for MBDyn
Hi all.
Solved the problem of calculating moments of inertia for complex bodies!! Now simulations can be done with any body/assembly. Have a look at my first try:
https://www.youtube.com/watch?v=BN07ZRm ... e=youtu.be
I know you've told me to have a loon at other workbenches, but I don't get the point of telling me where the answer is, if you probably already have the answer in mind and can save me time, time I can invest in getting this workbench done instead of reading someone else's code... So here goes the question: how do I put the messages MBDyn generates in the FreeCAD gui? Here's how I'm executing MBDyn:
process = subprocess.Popen(["mbdyn", "-f", __dir__+"/MBDyn/MBDynCase.mbd"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
print(out)
Cheers.
Solved the problem of calculating moments of inertia for complex bodies!! Now simulations can be done with any body/assembly. Have a look at my first try:
https://www.youtube.com/watch?v=BN07ZRm ... e=youtu.be
I know you've told me to have a loon at other workbenches, but I don't get the point of telling me where the answer is, if you probably already have the answer in mind and can save me time, time I can invest in getting this workbench done instead of reading someone else's code... So here goes the question: how do I put the messages MBDyn generates in the FreeCAD gui? Here's how I'm executing MBDyn:
process = subprocess.Popen(["mbdyn", "-f", __dir__+"/MBDyn/MBDynCase.mbd"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
print(out)
Cheers.
Re: FreeCAD as pre-post procesor for MBDyn
Here's another video, with the reaction force vector and the data plotted for both, the nodes (bodies) and the joints:
https://www.youtube.com/watch?v=75jERiv ... e=youtu.be
https://www.youtube.com/watch?v=75jERiv ... e=youtu.be
Re: FreeCAD as pre-post procesor for MBDyn
We just try to attrac your attention to FEM solver code. In this code all (most) probplem you have with your subprocess code are solved allready and thre are smart Task panels and python API commands already. You just need to add a new FEM solver object and add the FEM solver task and writer modules and could use all atvantages the FEM solver system has.
Eventually it is up to you to write you own solver code.
I try to avoid coding with subprocess because I have run in to trouble a few times (like you). Thus I am not of a big help if it comes to subprocess. Happily the FEM solver framework which uses subprocess was done by someone else.
Eventually it is up to you to write you own solver code.
I try to avoid coding with subprocess because I have run in to trouble a few times (like you). Thus I am not of a big help if it comes to subprocess. Happily the FEM solver framework which uses subprocess was done by someone else.
Re: FreeCAD as pre-post procesor for MBDyn
Well, this is a separate question. Your first question was how to get the output. Can you do this now? Okay. Now, how do we put this output inside a graphical interface? That depends. What type of interface? A message box, a task panel, a text editor? There are various ways. I think it would be good to put it in a task panel, just like FEM does.
Code: Select all
output="""
A bunch of output here.
A bunch of output here.
A bunch of output here.
A bunch of output here.
A bunch of output here.
A bunch of output here.
A bunch of output here.
A bunch of output here."""
import PySide
Text = PySide.QtGui.QTextEdit()
Text.setText(output)
Text.setFont(PySide.QtGui.QFont("Mono"))
Text.show()
Code: Select all
__dir__ + "/MBDyn/MBDynCase.mbd"
os.path.join(__dir__, "MBDyn/MBDynCase.mbd")
Last edited by vocx on Wed Oct 09, 2019 1:35 am, edited 1 time in total.
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.