Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have multiple bodies in a model all in the root component. I want to know the volume of each body. Display wise i am using the ui.messageBox but would like to export to excel or even just as text.
I have no problem getting and displaying the volume of any one body referenced individually:
body1 = rootComp.bRepBodies.item(0)
volume1 = body1.volume
v1 = str(volume1)
ui.messageBox('The volume is: ' + v1)
My struggle is trying to make a loop that iterates through all bodies to get each volume and display all on one message box (and later export to excel). I have tried multiple ways but this is an idea what i am trying below. Annoyingly the example code in the F360 reference document is really close but summates all the bodies together so i think avoids the need to store separately as a list maybe. I seem to keep come form trying to iterate with floats but struggling to convert to int like i have done before.
Hope that makes sense and thanks in advnace
Matt
for j in range(0, rootComp.bRepBodies.count😞
body = rootComp.bRepBodies.item(j)
volumelist = [body.volume]
# Format a string to display the volume using the default distance units.
result = design.unitsManager.formatValue(volumelist, design.unitsManager.defaultLengthUnits + '^3')
ui.messageBox('The volume list is: ' + result)
Solved! Go to Solution.