Hi @terry_fusion -San.
I don't think it is possible to customize the properties dialog.
Instead, I have created a script that displays the volume of the selected solid body in multiple units.
# Fusion360API Python script
import traceback
import adsk
import adsk.core as core
import adsk.fusion as fusion
_app: core.Application = None
_ui: core.UserInterface = None
_handlers = []
CMD_INFO = {
'id': 'kantoku_Multi_Units_Volume',
'name': 'Multi Units Volume',
'tooltip': 'Multi Units Volume'
}
_bodyIpt: core.SelectionCommandInput = None
_txtIpt: core.TextBoxCommandInput = None
UNITS_LIST = [
"mm^3",
"cm^3",
"ml",
"l",
"gal",
"qt",
"pt",
"cup",
"fl_oz",
]
class MyCommandCreatedHandler(core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: core.CommandCreatedEventArgs):
try:
global _handlers
cmd: core.Command = core.Command.cast(args.command)
inputs: core.CommandInputs = cmd.commandInputs
cmd.isOKButtonVisible = False
onDestroy = MyCommandDestroyHandler()
cmd.destroy.add(onDestroy)
_handlers.append(onDestroy)
onInputChanged = MyInputChangedHandler()
cmd.inputChanged.add(onInputChanged)
_handlers.append(onInputChanged)
global _bodyIpt
_bodyIpt = inputs.addSelectionInput(
"_bodyIptId",
"SolidBody",
"Select Solid Body",
)
_bodyIpt.addSelectionFilter(core.SelectionCommandInput.SolidBodies)
global _txtIpt
_txtIpt = inputs.addTextBoxCommandInput(
'_txtIptId',
'Volume',
'-',
len(UNITS_LIST)-1,
True
)
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
class MyInputChangedHandler(adsk.core.InputChangedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: adsk.core.InputChangedEventArgs):
global _bodyIpt
if args.input != _bodyIpt: return
global _txtIpt
if _bodyIpt.selectionCount < 1:
_txtIpt.text = "-"
return
body: fusion.BRepBody = _bodyIpt.selection(0).entity
volume = body.volume # cm^3
print(volume)
app: core.Application = core.Application.get()
des: fusion.Design = app.activeProduct
unitsMgr: core.UnitsManager = des.unitsManager
msgLst = [unitsMgr.formatInternalValue(volume, u, True) for u in UNITS_LIST]
_txtIpt.text = "\n".join(msgLst)
class MyCommandDestroyHandler(core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: core.CommandEventArgs):
adsk.terminate()
def run(context):
try:
global _app, _ui
_app = core.Application.get()
_ui = _app.userInterface
cmdDef: core.CommandDefinition = _ui.commandDefinitions.itemById(
CMD_INFO['id']
)
if not cmdDef:
cmdDef = _ui.commandDefinitions.addButtonDefinition(
CMD_INFO['id'],
CMD_INFO['name'],
CMD_INFO['tooltip']
)
global _handlers
onCommandCreated = MyCommandCreatedHandler()
cmdDef.commandCreated.add(onCommandCreated)
_handlers.append(onCommandCreated)
cmdDef.execute()
adsk.autoTerminate(False)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
