Hi kandennti,
Thank you for the help! Here's the new code implementing the ParaMeshConvertCommand.
import adsk.core, adsk.fusion, adsk.cam, traceback
import os
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
test_name = '1test_file'
#Find project by name
# Get the root folder of the project
for data_file in app.activeDocument.dataFile.parentFolder.dataFiles:
#if data_file.fileExtension == 'stl':
if test_name == data_file.name:
msg = str(data_file.name)
ui.messageBox(msg)
app.documents.open(data_file)
des :adsk.fusion.Design = app.activeProduct
root :adsk.fusion.Component = des.rootComponent
sels :adsk.core.Selections = ui.activeSelections
sels.clear()
cmDefs = ui.commandDefinitions
for mesh in root.meshBodies:
msg = str(mesh.name)
ui.messageBox(msg)
sels.add(mesh)
# show ParaMeshConvertCommand Command dialog
app.executeTextCommand(u'Commands.Start ParaMeshConvertCommand')
# push OK button
app.executeTextCommand(u'NuCommands.CommitCmd')
#cmDef = cmDefs.itemById("ParaMeshConvertCommand")
#cmDef.controlDefinition.isEnabled
#cmDef.execute()
msg = 'brep conversion complete'
ui.messageBox(msg)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I looked at your other examples on how to select meshes. Before, I saw your most recent reply, I was actually trying to use the commandDefinitions to execute the ParaMeshConvert command. If you comment out the text commands and uncomment the commandDefinition lines, I got to the point where I just needed to press the enter key. Just out of curiosity, would you know how I can use keyboard events?
Again, thank you for the help!
Best,
Sounak