Hi @fusion360_Admin4QV4K .
Fusion360's internal unit of length is "Cm".
It is recommended to use the UnitsManager.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-9c2d17c1-70c6-4c2d-ae9e-c6f6f283b1a9
If you have set the unit of length to "mm", it will look like this.
# Fusion360API Python script
import traceback
import adsk.core as core
import adsk.fusion as fusion
def run(context):
ui = core.UserInterface.cast(None)
try:
app: core.Application = core.Application.get()
ui = app.userInterface
des: fusion.Design = app.activeProduct
root: fusion.Component = des.rootComponent
unitsMgr: core.UnitsManager = des.unitsManager
occ: fusion.Occurrence = None
for occ in root.allOccurrences:
props: fusion.PhysicalProperties = occ.physicalProperties
cog: core.Point3D = props.centerOfMass
infos = [
f'** {occ.name} - Center Of Mass**',
f'X:{unitsMgr.formatInternalValue(cog.x)}',
f'Y:{unitsMgr.formatInternalValue(cog.y)}',
f'Z:{unitsMgr.formatInternalValue(cog.z)}',
]
app.log('\n'.join(infos))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
If you want to specify the unit, you can change it to this.
f'X:{unitsMgr.formatInternalValue(cog.x, "mm")}',
f'Y:{unitsMgr.formatInternalValue(cog.y, "mm")}',
f'Z:{unitsMgr.formatInternalValue(cog.z, "mm")}',