assetBestSize function

Syntax

  • string assetBestSize(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
    { x | y | z | xy | xz | yz | xyz }—selector of axes for the current scope.

Returns

Asset with the best size fit (according to axisSelector).

Description

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

Related

Examples

Inserting assets based on their (physical) size

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

Asset ratio pool
Note:

Note that small parts get blue assets while large parts get red assets.

Lot -->
	s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case scope.sx >= 1.5 && scope.sz >= 1.5:
		split(x){~scope.sx/3: split(z){~scope.sz/3: recursiveSplit(n+1)}*}*
	else: innerRectangle(scope) { shape : doInsert }
doInsert -->
	alignScopeToAxes(y)
	i(assetBestSize("/myProject/assets/cube_*.obj","xz"))
Insert small blue and large red assets

In this topic