AnsweredAssumed Answered

CreateMassProperty single body

Question asked by Bruno Frade on May 13, 2019
Latest reply on May 14, 2019 by Artem Taturevych

Hello, 

i cant find a way to get mass properties of  a single body in multibody part, my code looks like :

public class FBody2
{
    Body2 body;
    string document;
    View view;

    public Body2 Body { get => body; set => body = value; }
    public string Document { get => document; set => document = value; }
    public View View { get => view; set => view = value; }

    public FBody2(Body2 body,string document,View view)
    {
        Body = body;
        Document = document;
        View = view;
    }
}


...
oBodies = new object[] {(Body2)body.Body};//body is a custom object
DispatchWrapper[] bd = (DispatchWrapper[])ObjectArrayToDispatchWrapperArray(oBodies);
swMassProp.AddBodies((bd));
MassProperty swMassProp = swViewModel.Extension.CreateMassProperty();
double mass = swMassProp.Mass;
...

public  DispatchWrapper[] ObjectArrayToDispatchWrapperArray(object[] SwObjects)
{
    int arraySize = 0;
    arraySize = SwObjects.GetUpperBound(0);
    DispatchWrapper[] dispwrap = new DispatchWrapper[arraySize + 1];
    int arrayIndex = 0;
    for (arrayIndex = 0; arrayIndex <= arraySize; arrayIndex++)
    {
        dispwrap[arrayIndex] = new DispatchWrapper(SwObjects[arrayIndex]);
    }
    return dispwrap;
}

 

if i dont set bodies, i get all part mass, seems to be correct like this, but as soon as set some body, result will be always 0...

some help?

Outcomes