All posts by mike.vasiljevs

Global Attributes

Global attributes are very similar to alike a constant global value in a general programming language. Attributes assignment as follows:

attribute_name = attribute_value

  • attribute_name –  alphanumeric value, no spaces (should start with a letter).
  • attribute value – a double number, which can be treated as a real number or a boolean value (0 is false)

Random Ranges

Random Ranges

Random Integer Range

ri(min_value .. max_value)

Returns a randomly selected integer number from the [min_value, max_value] range at evaluation time using integer uniform distribution.

Random Real (Floating Number) Range
ru(min_value .. max_value)

Returns a randomly selected floating number from the [min_value, max_value] range at evaluation time using uniform distribution.

 

Insert Operator

Insert operator creates new geometry. Depending on the rule it is either ignored (e.g. Peel rule), optional (Centres of the Grid rule) or required (Insert and Place rules).

i(geometry_path)
i(geometry_path, r1)
i(geometry_path, r1, r2)
Parameters
  • geometry_path – a string that specifies new geometry to be inserted, either
    • builtin:<primtive_shape>” – a predefined shape based on primitives where <primitive_shape> is either circle, square or rhombus. r1 is the size of the shape. If r2 is specified, it is passed as size2 along y axis; in such case circle becomes an ellipse, and square – a rectangle.
    • iregion:shrink” – iregion is shrunk by r1 and used as the inserted shape
    • iregion:smoothen” – iregion is shrunk by r1 (see above) and then smoothed with r2 weight; if r1 is not given value 0.5 is used.
  • r1, r2 – extra parameters (mentioned above)
Examples

Insert a circle with radius 15% of the input region (provided rule accepts shape insertion) into a shape labelled InsertedCircle:

{ i("builtin:circle", %15) InsertedCircle }

…rhombus 20 wide and 15 high:

i("builtin:rhombus", 20, 15)

Label Selectors and Operators

Label Selector List

{ Selector1 | Selector2 | ... SelectorN }

One label selector is chosen for each shape at the rule output (derived shape). More than one may match, but only the first one matching is selected. The last selector SelectorN is expected to be a plain/default selector – otherwise, rule applications fails.

Label Selector

Evaluates to a label, matching condition and optimally additional operations (see below).

A plain selector is simply a label, and it always matches:

Label

Alternatively, if label selection should be limited to a particular condition:

MatchCondition: Label

Additional attribute modifications or shape insertion can be requested before the label:

MatchCondition: SelectorOperatorOperations Label
  • Label – label assigned to a derives shape
  • MatchCondition – a match condition expression should evaluate to true to match the label
  • SelectorOperatorOperations – operations based on selector operators.

Match Conditions

Border Keyword (NEW)
border

Regions that are touching a boundary at an edge are selected (however, regions sharing a vertex with iregion boundary are not!).

Index Match
idx(x_expr, y_expr)
  • x_expr, y_expr – integer expression that is either a number or a keyword, optionally prefixed with “!” which negates the meaning. Available keywords:
    • odd – all odd indices are selected. Even indices selected with “!odd”
Stochastic Match
percent%

Selector is chosen with a probability of percent value. For instance “50%” would accept the label roughly half of the time.

Default Match Keyword
else

Default match condition always matches (the keyword it can also be omitted).

Selector Operators

Insert Operator

Considered separately.

Set Operator

Creates a new attribute or changes a propagated attribute that is inherited from the rule input shape. For instance type attribute is assigned using set.

set(attribute_name, attribute_value)
  • attribute_name – an attribute name, of the same format as shape label.
  • attribute_value – a number or a string. The number is stored in double precision floating point format.

Examples

Selects Label2 half of the time, and Label1 and Label3 equally quarter of the time each:

{ 25%: Label1 | 50%: Label2 | else: Label3 }

Checkerboard pattern:

{ idx(odd, odd): LabelWhite | 
  idx(!odd, !odd): LabelWhite | LabelBlack }

Change path width to a third for any further productions on QuarterLabel:

{ set(path_width, %33.3) QuarterLabel }

Scatter Rule

Scatters objects within the input region.

“Place” an object at the centre of input region:

scatter(CENTRE) { ShapeSelector }

Scatter objects along the boundary selection (each edge treated separaely):

scatter(EDGE_SELECTION, density, boundary_selection, offset) { ShapeSelector }

Scatter objects along the boundary boundary selection (continuous selection is not separated into edges):

scatter(BOUNDARY_SELECTION, density, boundary_selection, offset) { ShapeSelector }

Scatter using Poisson distribution (the same method used in Disperse Components plugin):

scatter(density, offset) { ShapeSelector }

Parameters

  • density – a floating number, which if prefixed with R will be a radius “R radius_value” (minimal distance between any two samples), and when not – is the desired number of samples to be scattered. It is recommended to give this parameter in the radius mode.
  • boundary_selection – subset of the input region boundary
  • offset – offset from the input region boundary. When 2D (Poisson) distribution is used – radius_value is passed as an offset.

Place Rule

Inserts new shapes at an offset distance from the boundary.

place(boundary_selection, offset, locations)
 { ExtrudedSelectorList } { ShapeSelectorList } 
 { SubstrateSelectorList }
place(CENTRE) 
 { ExtrudedSelectorList } { ShapeSelectorList
Parameters

When only a single argument “CENTRE” is given object is placed at the centre of the region.

  • boundary_selection (boundary selection) – subset of the input region boundary.
  • offset – how much to offset from the boundary – same parameter as to Peel rule. Can be an absolute value (floating number), a relative (in percent) or a random range.
  • locations – where to place inserted shapes. Either a list of floating numbers a repeat expression.
  • ExtrudedSelectorList, SubstrateSelectorList – label selector lists for extruded region and substrate region accordingly. Extruded region is the newly created region and the substrate region occupies the remaining space of the input region. SubstrateSelectorList is optional and when missing extruded selector list is used.

Because new shapes cannot be placed in the middle of the polygon the input region needs to be the subdivided along the line where the new shapes are inserted. Internally Place rule is implemented in terms of  Peel and Insert allowing to modify both peeled shapes at the same time.

Peel Rule

Extrude the subset of the boundary inwards in the input region.

peel(boundary_selection, offset)
 { ExtrudedRegionList } { SubstrateRegionList }
Parameters
  • boundary_selection (boundary selection) – subset of the input region boundary.
  • offset – how much to peel or extrude. Can be an absolute value, a relative (in percent) or a random range.
  • ExtrudedRegionList, SubstrateRegionList – label selector lists for extruded region and substrate region accordingly. Extruded region is the newly created region and the substrate region occupies the remaining space of the input region.

Grid Rule

Partitions an input region into quarters using a regular grid.

 grid(idx_x, idx_y)
 { RegionList } { PathList } { JunctionList }

Parameters

  • idx_x, idx_y – number of cell subdivisions along x and y axes (in xy layout projection) accordingly.  Can be either an integer or random integer range, for instance grid(2, ri(1..3)) can produce cell arrangements 2×1, 2×2, or 2×3.
  • RegionList, PathList, JunctionListlabel selector lists which derive labels for cell/quarter regions, path regions and junction regions accordingly. Cell index can be used to match against the label.

Park Generator updates 0.0.4, 0.0.5

Smooth Cell Partitioning (v0.0.4)

Splitting input region based on smoothed Voronoi Diagram cells works correctly now. Topological changes during reduction (edge collapse) is now handled correctly by the new algorithm.

Public Release on Extension Warehouse (v0.0.5)

The plugin is has now been officially released on SketchUp Warehouse!

Other rule changes

  • Rule rewrite/derivation sign is now same as in CGA, “- ->”.
  • Grid rule parameters are changed to the number of cells, rather than number of paths. Namely grid(2, 2) specifies 2×2 cell arrangement instead of 3×3.

Stochastic Rule Parameters

Random ranges have been added. The earlier version allowed only fixed numbers in rule parameters, for instance grid(2, 3), now it is possible to do grid(ri(2..3), ri(2..4)). “ri” is Random Integer range, which means grid can be anywhere between 2 and 3 cells wide and 2 and 4 cells high (in xy plane). Distribution is uniform.

Label Selector Enhancements

Label selector list is used to select the derived label. Index-based (idx(2, odd): Label2), or just plain selectors are possible. Plain label is always selected, it can be optionally preceded with “else” keyword (e.g. else: Label3).  Label selectors are separated with “|”.