FCMacro and moment of inertia of assembly

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
pinq
Posts: 6
Joined: Mon Aug 14, 2017 9:24 am

FCMacro and moment of inertia of assembly

Post by pinq »

Hi,
I have played with freecad all day and trying to get right values out.
The problem is that I have STEP file, that includes various bodes. Is there way to calculate moment of inertia from all the bodes combine? I know that you can fusion the parts, but if there is 26 small parts, it would be cool if I can calculate moment of inertia without fusion.
Other question is that is it possible to calculate moment of inertia from given point? I understood that inertia is calculated around center of mass, but sometimes I need to get inertia from different point.
Otherwise the FCInfo is really handy tool! Thanks Mario52!
Sorry for my bad English.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: FCMacro and moment of inertia of assembly

Post by Kunda1 »

Hey @pinq. congrats on your first post and welcome to the forum. Please take a moment to review the forum guidelines so that you're on the 'same page' in regards to what we've all agreed to when posting on the forum. For example it's important to include you full FC info so we know exactly what you are talking about. Thanks in advance.
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
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FCMacro and moment of inertia of assembly

Post by triplus »

Hi @pinq.

FCInfo and fusing things together likely is the easiest and working solution. Everything else would likely include math, Python code and lots of time invested to do it. ;)
pinq
Posts: 6
Joined: Mon Aug 14, 2017 9:24 am

Re: FCMacro and moment of inertia of assembly

Post by pinq »

Kunda1:
I'm talking about parts moment of inertia. I know that FC info gives inertia matrix without density( or it is 1(kg/dm?)). But I wonder is it possible to add some other coordinate to the body and calculate inertia around it. Example if I have box and now it calculates moment of inertia around center point or center of mass, but what I have to do that it would calculate moment of inertia around the corner of the box. I know that you can get parts inertia info with python console using

Code: Select all

MatrixOfInertia 
(I think that FC info is using same command), but is it possible to define in python console from where to calculate moment of inertia.

triplus:
So it is possible to do for loop that fusios all the parts to one? You can't really select all and then fusion it ^^
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FCMacro and moment of inertia of assembly

Post by triplus »

pinq wrote: Tue Aug 15, 2017 5:43 am triplus:
So it is possible to do for loop that fusios all the parts to one? You can't really select all and then fusion it ^^
Can you explain this in a bit more detail. As i have a feeling you can.
pinq
Posts: 6
Joined: Mon Aug 14, 2017 9:24 am

Re: FCMacro and moment of inertia of assembly

Post by pinq »

triplus wrote: Tue Aug 15, 2017 10:53 am
pinq wrote: Tue Aug 15, 2017 5:43 am triplus:
So it is possible to do for loop that fusios all the parts to one? You can't really select all and then fusion it ^^
Can you explain this in a bit more detail. As i have a feeling you can.
Sure.
I mean that is it possible to build a for loop in python that goes through all the parts and fusions them to one fusion. and how to you run python script?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FCMacro and moment of inertia of assembly

Post by triplus »

pinq wrote: Tue Aug 15, 2017 11:10 am I mean that is it possible to build a for loop in python that goes through all the parts and fusions them to one fusion. and how to you run python script?
Yes it is possible:

Code: Select all

import Part
import FreeCAD as App

shapes = []
for i in App.ActiveDocument.Objects:
    try:
        shapes.append(i.Shape)
    except:
        pass

if len(shapes) > 1:
    base = shapes.pop(0)
    try:  # multiple arguments (FreeCAD 0.17 + OCC 6.9.0+/OCE 0.18+)
        result = base.fuse(shapes)
    except:
        for i in shapes:
            base = base.fuse(i)
        result = base
    Part.show(result)
pinq
Posts: 6
Joined: Mon Aug 14, 2017 9:24 am

Re: FCMacro and moment of inertia of assembly

Post by pinq »

Triplus:
That works Perfectly! thanks!

I made some modifications on FC info and now it shows also units of the moment of inertia and it also changes when length unit is changed.
I also added second matrix where you get moment of inertia with mass and right units.
Image
If the FC info editor wants it, I can share this with him or if someone else wants it.

Still wondering how can you calculate inertia around some point.

By the way is it possible to set/add visually coordinate system that shows local coordinate and maybe center of mass?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FCMacro and moment of inertia of assembly

Post by triplus »

pinq wrote: Wed Aug 16, 2017 1:16 pm Triplus:
That works Perfectly! thanks!
You're welcome.
I made some modifications on FC info and now it shows also units of the moment of inertia and it also changes when length unit is changed.
I guess best to ask the author for the opinion. As for the rest that are specific questions. I am sure it could be done but ATM i don't have much time to invest in thinking about this. Maybe somebody else will provide assistance.
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: FCMacro and moment of inertia of assembly

Post by mario52 »

hi pinq

thanks for appreciate my macro i am interested for you modification
your modification is good for this tread ? Mass Moment of Inertia for Crankshaft

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply