Set and Change Parameter Values in Chains

One of the great features in 12d Model for streamlining and automating repetitive processes is chains. They allow you to wrap up a set of processes, actions or steps, add some smarts and run them all as one entity. For more about what chains can do and how they can be used, I’d recommend reading my previous post, Introduction to Chains . In today’s post, I’ll be covering one of the advanced features of chains- parameters- and how we can set and change them.

If you’re already a chain expert, know all about parameters and just want to get your hands on the macro, you can jump ahead to the last page.

A brief introduction

Parameters are effectively variables that can be used to store values and then used in the chain. They are defined and stored in a Parameter Values File (PVF). Each Parameter is defined with a name, a type and a value. For example, you could create a parameter called “Source Model” of type “Model” and set the initial value to “ROAD DESIGN STRINGS”. Or, you could create a parameter called “Chg Interval” of type “Real” and leave the value field blank. The value of most parameters is optional.

Once you’ve defined some parameters in your PVF, you can select that PVF in your chain, and then use those parameters in the various commands of your chain. For example, you could use an Option command to capture and run the “X-Sections from Cuts Through Strings” panel (Design→X-Sections menu). Then, you could use the “Source Model” parameter in the Model field of the Source Box and the “Chg Interval” parameter in the Section separation field. You might be thinking, though, is why use parameters? These same values could be easily recorded when the panel was, but they then become hard-coded and written into the chain. Parameters allow you to modify or use different values without re-writing the chain. A good example of this can be found in this video post on how to Automate contouring with chains.

Screenshot showing an example of  using parameters to populate a panel in a chain
Screenshot showing an example of using parameters to populate a panel in a chain

A little fix to a little problem

Parameters, however, can only be set either initially in the PVF or by capturing a value from a panel. There is no way for a chain author to directly change a parameter’s value part-way through a chain process. We could prompt the user to fill in a chain prompt (or perhaps use the Chain Custom Prompt), but we don’t want to have to rely on the user to fill the value in correctly or even necessarily see these values. The parameter values could be temporary or intermediate and you generally don’t want to pause a chain for user interaction unless absolutely necessary. We also don’t want to keep editing the PVF or have multiple PVFs for each possible combination of values. Ideally, there would be a Set Parameter Value chain command, but that’s not currently available. To get around this, I wrote a macro Chain Custom Values.

Much like the Chain Custom Prompt macro, the Chain Custom Values macro builds a panel with custom fields at run-time based on details provided as command-line arguments. However, whereas the Chain Custom Prompt macro, expects the user to provide the values, the Chain Custom Values expects the chain author to provide the values. The values are displayed in a panel, which can then be captured into parameters.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.