Hello @Anonymous I think maybe what you were looking for was a script that would determine if the parameter had ANY user defined name? Here is another example where I assume any name that is not a "d" followed by an integer is something custom and then will add it as a favorite. Also FYI @Olle_Eriksson .
Nice script though @kandennti !
# Author - Patrick Rainsberry
# Description - Simple script to make favorites out of named parameters
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
# This is not nnecessary but makes code complete work better
app: adsk.core.Application
document: adsk.fusion.FusionDocument
parameter: adsk.fusion.Parameter
try:
# Get various application objects
app = adsk.core.Application.get()
ui = app.userInterface
document = app.activeDocument
design = document.design
all_params = design.allParameters
# Lets count the number of favorites added
count = 0
# Iterate over all parameters in the design
# Note: Intentionally verbose to make it easier to follow.
for parameter in all_params:
is_named_parameter = True
# Check if first character is not a "d"
if parameter.name[0] == 'd':
# Check if the rest of the name is not a positive integer
if parameter.name[1:].isdigit():
is_named_parameter = False
# Check if it has a user defined name
if is_named_parameter:
# Only increment count if it wasn't already a favorite
if not parameter.isFavorite:
count += 1
# Set the parameter as a favorite
parameter.isFavorite = True
# Feedback message, uses Python Format String
ui.messageBox(f'All done! {count} parameters added to favorites')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Patrick Rainsberry
Developer Advocate, Fusion 360