Volume of a body in Mechanical

Indrajit
Indrajit Member Posts: 3
First Comment
edited June 2023 in Structures

Hello,

I am trying to get the volume of individual bodies in a Geometry assembly.

ExtAPI.DataModel.Project.Model.Geometry.Volume gave me the total volume of the model.

How should I get the volume of individual ones

Thanks,

Indrajit

Answers

  • Indrajit
    Indrajit Member Posts: 3
    First Comment

    The following works

    entity = ExtAPI.DataModel.GeoData.GeoEntityById(sel.Ids[i])

    Volume = entity.Volume


    Thanks!

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 734
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    Hi @Indrajit , happy to see you on the forum and thanks for sharing your knowledge! There's two ways you can retrieve that information.

    As it is some information that is shown in the details view of the "tree geometry" for each body:

    You can use the Model API to get that info:

    bodies = Model.Geometry.GetChildren(DataModelObjectCategory.Body, True)
    for body in bodies:
        print('Body volume is: ' + str(body.Volume))
    

    This returns:


    Another method is to use GeoData to retrieve that information:

    bodies = Model.Geometry.GetChildren(DataModelObjectCategory.Body, True)
    for body in bodies:
        geobody = body.GetGeoBody()
        print('Body volume is: ' + str(geobody.Volume))
    

    This returns:

    For an explanation of the difference between a body as seen from the Mechanical tree and as seen from Geodata, please refer to this post:

    https://discuss.ansys.com/discussion/2288/whats-the-difference-between-tree-geometry-and-geodata-in-mechanical-api/p1?new=1

  • Indrajit
    Indrajit Member Posts: 3
    First Comment

    Hi Pernelle,

    Thanks a lot.

    Lots of options to select from.

    Is there a Python command manual for Spaceclaim?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 734
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    Hi @Indrajit , sorry for the late answer, I am back in the office just today.

    You can find a Developers Guide in the SpaceClaim installation files. If you're using a standard installation path, for 2023R1 this would be: C:\Program Files\ANSYS Inc\v231\scdm\SpaceClaim.Api.V23.