assetApproxRatio function

Syntax

  • string assetApproxRatio(searchQuery, axisSelector, n )

Parameters

  1. searchQuerystring
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  2. axisSelectorstring
    { xy | xz | yz | xyz }—selector of axes for the current scope.
  3. nfloat
    Number (integer >= 1) of assets to consider (one is randomly picked out of the n best assets).

Returns

Asset with one of the best n size fits (according to axisSelector).

Description

The assetApproxRatio function returns one of the n best assets of the best ratio, from the file list specified in string, according to the specified axisSelector.

Note:

assetApproxRatio(string, axisSelector, 1) = assetBestRatio(string, axisSelector)

Related

Examples

Inserting assets based on their approximate ratio

The goal is to insert assets from a pool, depending on their (physical) size ratio. The pool of assets is seen in the following image. Colors are (only) used to visually emphasize the physical size ratio.

Asset ratio pool

CGA examples with n = 1

Since the assets are color coded with their ratio, it is visible that "long" and "wide" Lots utilize black and pink assets, while "square-ish" Lots utilize red and blue assets. The color variations in the next two images by using only the "best ratio" (n = 1) and "choose randomly one of the best three ratios" (n = 3).

n = 1:
Lot -->
	innerRectangle(scope) { shape : doInsert }
doInsert -->
	alignScopeToAxes(y)
	s('1,0,'1)
	i(assetApproxRatio("/myProject/assets/cube_*.obj", "xz", 1))
Asset ratio with ratio 1

CGA examples with n = 3

n = 3:
Lot -->
	innerRectangle(scope) { shape : doInsert }
doInsert -->
	alignScopeToAxes(y)
	s('1,0,'1)
	i(assetApproxRatio("/myProject/assets/cube_*.obj", "xz", 3))
Asset ratio with ratio 3

In this topic