CTRL-F in the parameters window would be great!
For anyone who is bothered enough to add a script for this here is mine:
(pops open a dialog asking for a regular expression and looks for it in components, bodies, sketches, dimensions, then prints the result in the shell)
import adsk.core, adsk.fusion, traceback
import re
# check bodies
def traverseBodies(breps, parentName, currentLevel, regex):
result = ''
for body in breps:
if re.match(regex, body.name):
result += ' ' + parentName + ' : ' + body.name + "(body)\n" + result;
return result
# check sketches
def traverseSketches(sketches, parentName, currentLevel, regex):
result = ''
for sketch in sketches:
if re.match(regex, sketch.name):
result = ' ' + parentName + ' : ' + sketch.name + "(sketch)\n" + result;
for i in range(sketch.sketchDimensions.count):
dim = sketch.sketchDimensions[i]
if dim and re.match(regex, dim.parameter.name):
result += ' ' + parentName + ' : ' + sketch.name + ' : ' + str(dim.parameter.name) + "\n"
return result
# Performs a recursive traversal of all components
def traverseAssembly(occurrences, parentName, currentLevel, inputString, regex):
for occ in occurrences:
# check bodies in component
bodyResult = traverseBodies(occ.component.bRepBodies, parentName + " : " + occ.name, currentLevel, regex)
#check sketches in component
sketchResult = traverseSketches(occ.component.sketches, parentName + " : " + occ.name, currentLevel, regex)
# check component name itself
if re.match(regex, occ.name) or sketchResult or bodyResult:
inputString += parentName + ' : ' + occ.name +'\n'+ bodyResult + sketchResult
# check children
if occ.childOccurrences:
inputString = traverseAssembly(occ.childOccurrences, parentName + " : " + occ.name, currentLevel + 1, inputString, regex)
return inputString
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
if not design:
ui.messageBox('No active Fusion design', 'No Design')
return
# regex search, eg. '(?i)' case insensitive, 'd100' dimension d100, '.*gears.*' anything with gears in the name, etc
searchTerm = ui.inputBox('search for', 'regex', '(?i)d[0-9]+')
# Get the root component of the active design.
rootComp = design.rootComponent
regex = re.compile(searchTerm[0])
#check root bodies
resultString = traverseSketches(rootComp.sketches, rootComp.name, 1, regex)
#check root sketches
resultString += traverseSketches(rootComp.sketches, rootComp.name, 1, regex)
# Call the recursive function to traverse the assembly and build the output string.
resultString = traverseAssembly(rootComp.occurrences.asList, rootComp.name, 1, resultString, regex)
if not resultString:
resultString = 'nothing found'
# Write the results to the TEXT COMMANDS window.
textPalette = ui.palettes.itemById('TextCommands')
if not textPalette.isVisible:
textPalette.isVisible = True
textPalette.writeText(resultString)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))