Composite Recipes with Smart Components

Is it possible to write a composite recipe that combines smart components, but the recipe calls for specific Smart Component parameters?

Here is a macro that you can run in WindowMacro Panel:

recipes = """

for recipe in recipes.strip().split("\n"):
	sides = recipe.rsplit("=", 1)
	glyph_name = sides[1].strip()
	glyph = GSGlyph(glyph_name)

	component_codes = [x.strip() for x in sides[0].split("+")]
	component_specs = []

	for component_code in component_codes:
		code_split = component_code.split("[")
		component_name = code_split[0]
		parameter_specs = []

		if len(code_split) > 1:
			parameter_codes = code_split[1].strip("]").split(",")

			def parse_parameter_code(parameter_code):
				spec = parameter_code.split("=")
				name = spec[0].strip()
				value = float(sides[1].strip())
				return name, value

			parameter_specs = [parse_parameter_code(x) for x in parameter_codes]

		component_specs.append((component_name, parameter_specs))

	for layer in glyph.layers:
		for component_name, parameter_specs in component_specs:
			component = GSComponent(component_name)
			for name, value in parameter_specs:
				component.smartComponentValues[name] = value

You only need to change the code at the top between the """ and """. The recipes are written like so, one recipe per line:


where comp#, param#, and glyph# are placeholder for your component, parameter, and glyph names.

1 Like

thank you thank you Florian! I can’t to try this out!