Print the Volume of a body from CATIA V5

4 Replies to “Print the Volume of a body from CATIA V5”

  1. Hi,
    I’m trying to get the center of gravity for a product by using this:

    a = doc.Analyze.GetGravityCenter

    But I only get the method of the object itself instead of the resulting x,y,z.
    Do you know how to make this work?

    Best regards
    Marcus

  2. I`m not sure, but perhaps GetGravityCenter is a Method? I would try:

    a = doc.Analyze.GetGravityCenter()

    Then I would expect the value of “a” as a tuple. Something like (100, 22.32, 98.12).

  3. Yeah, it’s a method and I agree with you that the expected value of “a” would be a tuple.
    I think the problem is that the method GetGravityCenter() in Catia needs an array variant as an argument (CATSafeArrayVariant oGravityCenterCoordinatesArray) to store the CoG values. I have run makepy in win32com and it generates the following function:

    def GetGravityCenter(self, oGravityCenterCoordinatesArray=defaultNamedNotOptArg):
    return self._ApplyTypes_(1610940419, 1, (24, 0), ((8204, 3),), ‘GetGravityCenter’, None,oGravityCenterCoordinatesArray)

    From what I have read the (24, 0) means the function returns “void” and (8204, 3) means the parameter is an IN/OUT parameter that is an array of variants.

    However, when trying to include anything (list, string, etc.) as a parameter to the method in Python it only returns the inputed argument…

    Any suggestion to get around this?

Leave a Reply