assetBestRatio function

Syntax

  • string assetBestRatio(searchQuery, axisSelector)

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.

Returns

Asset (according to axisSelector) with the best ratio.

Description

The assetBestRatio function returns the asset with the best fitting ratio, from the file list specified in searchQuery, according to the specified axisSelector.

Related

Examples

Inserting assets based on the best 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
Note:

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.

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

In this topic