StyleRule

File Object Type

A Style Rule applies formatting to specified objects throughout a file or top level frame. Style rules are a one-stop shop for how your Blockpad file looks, so you don't have to set properties for everything individually.

A style rule can apply formatting to any kind of object in a file - normal text, equations, headings, cells, drawing lines, tables, etc.

A rule can be applied based on the type of object, like whether it's an equation or not, or it can be applied only to specific objects you designate.

For example, you can make it so that every equation in a file has a black border and shows 4 significant digits. Or, you can make it so that equations you designate as "inputs" are colored green, while equations you designate as "outputs" are colored orange.

Create a style rule

There are three ways to apply a style rule.

The first (and simplest) is to apply the rule based on the type of object. You specify the type of object and the properties you want it to have, and then every object of that type in the file (or top level frame) has those properties by default.

The second is to apply the rule to individual objects, for when you want only some objects to have that formatting.

The third is to apply the rule to a range of cells. This is actually done automatically when you manually apply formatting to a range of cells, but you can also do it throught he style manager.

All three of these methods are described below.

Apply a style by object type:
  1. Select Style>Manage Styles in the toolbar.
  2. Click the New Rule button in the window that appears.
  3. Click the dropdown labeled Objects of Type and choose an object type.
  4. (Optional) Click the dropdown labeled Container.
    • Choose "Frame Document" to apply the rule across the entire file.
    • Choose the other option to apply the rule only within the top level frame.
  5. Set property values.
  6. Close the Style Manager.
Apply a style to individual objects:
  1. Select Style>Manage Styles in the toolbar.
  2. Click the New Rule button in the window that appears.
  3. (Optional) Click the dropdown labeled Objects of Type and choose an object type.
  4. (Optional) Click the dropdown labeled Container.
    • Choose "Frame Document" to apply the rule across the entire file.
    • Choose the other option to apply the rule only within the top level frame.
  5. Click the bullet next to Apply individually.
  6. Under Name, type in a name for the style that you will recognize later.
  7. Set property values.
  8. Close the Style Manager.
  9. Select the object (or objects) that you wish to apply the style to.
  10. Open the properties window.
  11. Under the Style section click "Style" and choose the name of the style rule you want applied.
  • Note: you can apply multiple styles to one object by clicking More options for the Style property.
Apply a style to a range of cells:
  1. Select Style>Manage Styles in the toolbar.
  2. Click the New Rule button in the window that appears.
  3. Click the bullet next to Apply to table range.
  4. Type in the range of cells that you wish to apply the style to.
      E.g. C6:C10 or D3:G20
  5. Set property values.
  6. Close the Style Manager.

Use multiple style rules

You can create multiple style rules to specify different formatting for different kinds of objects or to layer rules applied individually.

For example, you can make all equations in one font, all other text in another font, all table cells have a blue background, and equations specified as "outputs" colored yellow.

To create multiple style rules, just click New Rule in the style manager and follow the instructions above.

When you open the style manager, all of the style rules that apply to that top level frame appear in a list to the left of the window. You can click on a rule to edit the properties or change what objects it applies to.

The list also shows what rules take priority over others. If two rules contradict each other, the rule higher up in the list is applied. Rules can be moved up and down in the list using the arrow buttons that appear when a style is selected.

Style rules and normal formatting

Whenever formatting is applied to an object in the normal way, either using the toolbar or the properties window, that formatting takes priority over the style rules.

In that sense, style rules are like customized file defaults. Manually formatting an object will override the defaults.

You can clear all direct formatting by selecting the object and clicking Style>Clear Styles in the toolbar. When you do this, the object formatting goes back to being controlled by style rules.

Conditional formatting with styles

With the "value condition" option, you can apply a style rule only if the object meets a criteria defined by a formula. Note that this only works with objects that contain a value, like equations, fields, or cells.

This can be used with all of the style rule methods, i.e. applied by object type, applied individually, or applied to a range of cells.

For example, say there's an output value that you want to highlight red if it's below a certain criteria. You can make an individually applied style with a value condition, and apply that style to that output.

Apply conditional formatting using styles:
  1. Follow one of the sets of instructions for creating a style rule.
  2. In the style rule, check Value condition.
  3. Enter a condition formula.
    • The style rule will apply only if the result is true.
    • Example: >10
  4. Close the style manager window.

Condition formulas are a special subset of formulas. For the conditional formatting to work properly, the result of the formula must be either true or false, so the formulas will typically have a boolean operator like <, ==, <=, or !=.

The simplest condition formulas implicitly treat the object value as the start of the equation. Below are some examples.

  • >10
  • <=20ft*lb
  • =="Machined Finish"
  • !=0

For more complicated condition formulas, you can use an in-line function with a single variable. The object value will be treated as the function variable. Below are some examples.

  • x => Abs(x) > 5
  • val => val^2 <= 100 in^2
  • num => Compatible(num, 1 ft)

Common applications

Style rules can be used for a lot of different purposes. Below are some common examples.

File-wide font

You can use style rules to change the font for the whole document.

To do so, follow the instructions above to "apply a style by object type". Set Object of Type to "Any", and set Container to "Frame Document". Then change the Font Family property to your desired font.

Headings and paragraphs

Combining Blockpad's heading tool with style rules makes it possible to format all of the headings and subheadings in a document at once.

To do this, you will make multiple rules applied by object type. Follow the instructions above for applying style by object type, using the following Objects of Type:

  • "Paragraph" - Applies to text in a paragraph, but not headings. Includes dynamic equations and fields (because they are always located inside a paragraph). Does not include table cells.
  • "Heading" - Applies to headings only.
  • "Heading 1", "Heading 2", etc - Applies to the specific heading numbers.
  • "Any Paragraph" - Applies to paragraphs and headings.
  • "Any" - Applies to all object types that use the formats specified. Use this to get table cell formats to match paragraphs.
Formatting equations

You can use style rules to create a "default" format for all equations file-wide.

For example, you can make all equations default to 4 significant digits using value formatting, or make it so that := the assignment operator on all equations using the Math layout property.

To do this, specify "dynamic equation" as the Object of Type. You can also use "Any" if you want cells and equations to show their results similarly (e.g. 3 significant digits).

Formatting input/output equations

Often engineers want to format equations used for inputs and equations regarded as outputs differently. For example, inputs might be colored green while outputs are colored orange and have a border around them.

To do this, use individually applied styles, described above. Below are some instructions specific to this use case.

  1. Select Style>Manage Styles in the toolbar.
  2. Click the New Rule button in the window that appears.
  3. Click the dropdown labeled Objects of Type and choose "Dynamic equation".
    • "Any" can also be used.
  4. Click the dropdown labeled Container and choose "Frame Document".
  5. Click the bullet next to Apply individually.
  6. Under Name, type in "Inputs".
  7. Set property values, e.g. set the background color as green.
  8. Repeat steps 2-5.
  9. Under Name, type in "Outputs".
  10. Set property values, e.g. set the background color as orange.
  11. Close the style manager window.
  12. Use Ctrl+click to select equations that are inputs.
  13. In the properties window, click the Style property and choose "Inputs".
  14. Use Ctrl+click to select equations that are outputs.
  15. In the properties window, click the Style property and choose "Outputs".

Now to change the formatting for inputs or outputs, go to the style manager and edit the style. The change will be applied to all equations that have that style.

If you have a new equation that is an input or output, you can get the right format by changing the Style property in the properties window.

Formatting drawing objects

You can also use styles to specify default properties for drawing objects like lines and shapes.

For example, you can make all drawing objects have thin, dark blue lines with a light blue fill.

You could also make it so that just arrow lines are red, while everything else is black.

To specify styles for drawings, follow the instructions above but choose one of the many drawing objects for Objects of Type. For example, "Any Geometry" will work for all drawing objects, and "Circle", "Arc", and "Rectangle" will apply the style to those shapes.

Object Types

When applying a style rule to objects based on type, it's important to get the "Objects of type" selection right. Understanding what the object type options are will help you to make style rules that do what you want them to do.

In the dropdown list, the options are listed alphabetically. Below they are listed categorically, along with a brief description of what that object type will apply to.

Note that when choosing a general type, like "Any", only the properties that an object can take will apply. For example, if "Any" is used and the line thickness property is changed, this will only affect drawing objects, it will have no effect on things like equations.

Any Applies to all objects.
Reports Applies to report top level frames.
Can also apply to objects located inside a report for some properties, like font.
Dynamic Equation Applies to dynamic equations - equations that calculate a formula and show in math notation.
Static Equation Applies to static equations - math display equations that don't calculate.
Field Applies to .
Any Paragraph Applies to all paragraphs and headers.
Can also apply to equations and fields for some properties, as they are located in paragraphs.
Paragraph Applies to regular paragraphs only. Basically the normal text in the document.
Can also apply to equations and fields for some properties, as they are located in paragraphs.
Heading Applies to text that has been specified as Heading 1, 2, or 3, etc
Heading 1 Applies only to text specified as Heading 1.
Options are also there for Heading 2-6.
Title Applies only to text specified as a title.
Spreadsheet Applies to spreadsheet top level frames.
Can also apply to cells in a spreadsheet for some properties, like font.
Table Applies to .
Can also apply to cells in the table for some properties, like font.
Any Table Cell Applies to all cells, whether in a spreadsheet or a table.
Value Cell Applies to non-empty value cells.
Does not apply to multiline cells.
Multiline cell Applies to multiline cells - cells that act more like they are in a word processor.
Any Section Applies to normal sections, step-by-step sections, and solver sections.
Section Applies only to regular sections.
Step-by-Step Sections Applies only to step-by-step sections.
Solver Section Applies only to solver sections.
2D Canvas Applies to top level drawings.
Any Geometry Applies to all drawing objects, including lines, circles, arcs, rectangles, etc.
Line set Applies to regular lines.
Also applies to freehand lines.
Line set with arrows Applies to lines with arrows.
Point Set Applies to points.
Arc/Circle/Rectangle Applies to the shape described.
Text Label Applies to text labels - floating text that act similar to spreadsheet cells.
Linear Dimension Applies to dimension labels.

You can refer to this file object type in any formula, macro, module, or other script in Blockpad. You can use either its name or its full path:

  • To refer to it by name, use StyleRule (make sure the library Library.Docs.Objects is included with Include Libaries)
  • To refer to it by its full path, use Library.Docs.Objects.StyleRule

 

See also: