Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Python code generation for text dropdwn boxes in Autodesk Fusion 360 with AI Claude On-line.

Дата публикации: 02-08-2026 21:50:46

Hellow fellows. I´m experieced in CAD 2D & 3D, and familarized with AutoCAD, Inventor, SolidWorks, CATIA 5 modelling and customization, and a bit of NX11 APT  and Cimatron GPP. But new in Fusion environment and AI.  I know "chongas" (nothing) of Python coding, but I learnt Fortran in past, and a bit of C procedural, CATIA customization and Inventor Ilogic. I observed that Fusion don´t have way of put dropbox itens for text variables, directly in the "Change Parameters" command, and I feel lack of it. Then I ask Cloude  Online (acess 01.08.2026) and asked it to generate a Python code for permit a text user variable to be selected by a dropbox list.  After a first creation bugged, and a 2nd creation ok, it generated the list bellow/attached. Please test it and inform me if it´s ok for u or supply any need of yours. RegardsCarlos -------------------- init------- import adsk.core, adsk.fusion, traceback# Nome do parametro de usuario que sera alteradoPARAM_NAME = 'Material_peca'# Opcoes que aparecerao no dropdownOPCOES = ['Aço', 'Madeira', 'Alumínio']# Handlers precisam ser mantidos em memoria (referencia global)handlers = []app = adsk.core.Application.get()ui = app.userInterfacedef get_user_param(design: adsk.fusion.Design, name: str):"""Retorna o UserParameter pelo nome, ou None se nao existir."""for p in design.userParameters:if p.name == name:return preturn Noneclass CommandExecuteHandler(adsk.core.CommandEventHandler):def notify(self, args):try:cmd = args.commandinputs = cmd.commandInputsdropdown = inputs.itemById('materialDropdown')selecionado = dropdown.selectedItem.namedesign = adsk.fusion.Design.cast(app.activeProduct)if not design:ui.messageBox('Nenhum documento de Design ativo.')returnparam = get_user_param(design, PARAM_NAME)if not param:ui.messageBox(f'Parâmetro "{PARAM_NAME}" não encontrado no arquivo.')return# Parametros de texto usam a propriedade textValue, NAO expression/valueparam.textValue = selecionadoui.messageBox(f'Parâmetro "{PARAM_NAME}" atualizado para: {selecionado}')except:if ui:ui.messageBox('Falhou:\n{}'.format(traceback.format_exc()))class CommandCreatedHandler(adsk.core.CommandCreatedEventHandler):def notify(self, args):try:cmd = args.commandinputs = cmd.commandInputsdesign = adsk.fusion.Design.cast(app.activeProduct)valor_atual = Noneif design:param = get_user_param(design, PARAM_NAME)if param:# Le o valor atual usando textValue (parametro de texto)valor_atual = param.textValuedropdown = inputs.addDropDownCommandInput('materialDropdown','Material da Peça',adsk.core.DropDownStyles.TextListDropDownStyle)for opcao in OPCOES:is_selected = (opcao == valor_atual)dropdown.listItems.add(opcao, is_selected)# Se o valor atual nao estiver na lista de opcoes, seleciona o primeiroif valor_atual not in OPCOES and dropdown.listItems.count > 0:dropdown.listItems.item(0).isSelected = Trueon_execute = CommandExecuteHandler()cmd.execute.add(on_execute)handlers.append(on_execute)except:if ui:ui.messageBox('Falhou:\n{}'.format(traceback.format_exc()))def run(context):try:cmd_defs = ui.commandDefinitions# Remove definicao antiga, se existir, para evitar duplicidadeold_cmd_def = cmd_defs.itemById('cmdAlterarMaterialPeca')if old_cmd_def:old_cmd_def.deleteMe()cmd_def = cmd_defs.addButtonDefinition('cmdAlterarMaterialPeca','Alterar Material da Peça','Define o valor do parâmetro Material_peca a partir de uma lista.')on_created = CommandCreatedHandler()cmd_def.commandCreated.add(on_created)handlers.append(on_created)cmd_def.execute()# Mantem o script "vivo" ate o comando ser concluidoadsk.autoTerminate(False)except:if ui:ui.messageBox('Falhou:\n{}'.format(traceback.format_exc()))---------- end ------

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1How to create multiple of same object with different text from a list or table05.1602-08-2026
2Issue? Offset curves cannot properly identify internal profiles019.4502-08-2026
3BASIC FEATURES DON'T WORK --UNLOCK020.0202-08-2026
4Betreff: Sweeping unter Form bearbeiten013.6625-07-2026
5Tool Break Detection - Incorrect Tool Number07.1702-08-2026
6Useful ideas5627-06-2026
7[BUG] "Align to" on a UCS plane orients the view to the Default Coordinate System instead of UCS06.9425-07-2026
8Shared View does not respect the redefined ViewCube Top orientation05.1602-08-2026
9What's New? Rule-Driven Architectural Products in the Browser with Informed Design's APS Viewer Extension5618-03-2026
10Designing CherryScript: Optimizing Data-Driven Workflows via Custom Python-Based Interpreters​​​​‌‍​‍​‍‌‍‌​‍‌‍‍‌‌‍‌‌‍‍‌‌‍‍​‍​‍​‍‍​‍​‍‌​‌‍​‌‌‍‍‌‍‍‌‌‌​‌‍‌​‍‍‌‍‍‌‌‍​‍​‍​‍​​‍​‍‌‍‍​‌​‍‌‍‌‌‌‍‌‍​‍​‍​‍‍​‍​‍‌‍‍​‌‌​‌‌​‌​​‌​​‍‍​‍​‍‌‍​‌‍‌‌​​‍‍‌​‌‌​‌‍​‌‌‍​‌‍‍‌‍‌‌‍‌‍‌‌‌​‍‌‍‌‍‌‍​‌‍‌‌​‍‍‌‍​‌‍​‍‌‍‍‌‌‍‍‌‌​‌‍‌‌‌‍‍‌‌​​‍‌‍‌‌‌‍‌​‌‍‍‌‌‌​​‍‌‍‌‌‍‌‍‌​‌‍‌‌​‌‌​​‌​‍‌‍‌‌‌​‌‍‌‌‌‍‍‌‌​‌‍​‌‌‌​‌‍‍‌‌‍‌‍‍​‍‌‍‍‌‌‍‌​​‌​‌‌‌‍​‌‌‍‌‍​​‍​‍​​‌‍​​​​​​‍‌​​‍​‌​​‍‌​‌​​‍‌​‌​‌‍‌‌​​‌​‌​​‍‌‌‍​‍​‌​​‍‌‌‍​‍​‍‌​‍​​‌‍‌‍‌​‌‍​‍​‌‍‌‍​‍​​​‌‌​​​​‌‌‍​‌‌‍​‌​‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‍‌‍​‌‍‌‍‌‌‌​​‌‍‌​‌‌​​‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‌​‌‍‍‌‌‌​‌‍​‌‍‌‌​‌‍​‍‌‍​‌‌​‌‍‌‌‌‌‌‌‌​‍‌‍​​‌‌‍‍​‌‌​‌‌​‌​​‌​​‍‌‌​​‌​​‌​‍‌‌​​‍‌​‌‍​‍‌‌​​‍‌​‌‍‌‍​‌‍‌‌​​‍‍‌​‌‌​‌‍​‌‌‍​‌‍‍‌‍‌‌‍‌‍‌‌‌​‍‌‍‌‍‌‍​‌‍‌‌​‍‍‌‍​‌‍​‍‌‍‌‍‍‌‌‍‌​​‌​‌‌‌‍​‌‌‍‌‍​​‍​‍​​‌‍​​​​​​‍‌​​‍​‌​​‍‌​‌​​‍‌​‌​‌‍‌‌​​‌​‌​​‍‌‌‍​‍​‌​​‍‌‌‍​‍​‍‌​‍​​‌‍‌‍‌​‌‍​‍​‌‍‌‍​‍​​​‌‌​​​​‌‌‍​‌‌‍​‌​‍‌‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‍‌‍​‌‍‌‍‌‌‌​​‌‍‌​‌‌​​‍‌‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‌​‌‍‍‌‌‌​‌‍​‌‍‌‌​‍‌‍‌​​‌‍‌‌‌​‍‌​‌​​‌‍‌‌‌‍​‌‌​‌‍‍‌‌‌‍‌‍‌‌​‌‌​​‌‌‌‌‍​‍‌‍​‌‍‍‌‌​‌‍‍​‌‍‌‌‌‍‌​​‍​‍‌‌0512-06-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 7.7. Источник: forums.autodesk.com.