Cannot get the physical properties of the body

Cannot get the physical properties of the body

2544173825
Enthusiast Enthusiast
343 Views
1 Reply
Message 1 of 2

Cannot get the physical properties of the body

2544173825
Enthusiast
Enthusiast

I am reading the part information from the .smt file, but I am having some problems using body.getPhysicalProperties.  The body_PhysicalProperties value I read is mostly 0 or NAN, which does not seem to be the correct value.

0 Likes
344 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi @2544173825 .

 

It would be helpful and easy to check if you could describe the actual code you tested.

 

I have tested it here.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        path = r'C:\temp\7778_3a9748b3_0005_1.smt'

        tmpMgr: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
        bodies = tmpMgr.createFromFile(path)
        dumpProp('CreateFromFile', bodies[0])

        importMgr: adsk.core.ImportManager = app.importManager
        smtOpt: adsk.core.SMTImportOptions = importMgr.createSMTImportOptions(path)
        bodies = importMgr.importToTarget2(smtOpt, root)
        dumpProp('ImportManager', bodies[0])

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def dumpProp(txt: str, body: adsk.fusion.BRepBody):
    prop: adsk.fusion.PhysicalProperties = body.physicalProperties

    msglist = [f'--{txt}--']
    msglist.append(f'area : {prop.area}')
    msglist.append(f'mass : {prop.mass}')
    msglist.append(f'volume : {prop.volume}')

    adsk.core.Application.get().log('\n'.join(msglist))

 

Here are the results.

 --CreateFromFile--
area : 0.0
mass : 0.0
volume : 0.0
 --ImportManager--
area : 27.332671396872968
mass : 0.03439073431815101
volume : 3.9989225951338385

I could not get any information from the BRepBody I got from the TemporaryBRepManager.createFromFile method.

 

In the past, MeasureManager could not be used with BRepBody created by TemporaryBRepManager.
The problem has been reported in this forum and has been fixed.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-DF2F5C84-57C7-4F61-BA05-D2978FFF2724 

 

In the future PhysicalProperties may be available as well, but I don't have the connections to tell you that.